From 42310fa170c9fb18e08ac8e776a99f798a2f8383 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 24 Oct 2018 01:17:03 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9E=9C=EC=9E=84=20=EA=B0=9C=EC=9B=94=20?= =?UTF-8?q?=EC=88=98=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_process_personnel.php | 2 +- hwe/processing.php | 2 +- src/sammo/TimeUtil.php | 22 +++++++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hwe/func_process_personnel.php b/hwe/func_process_personnel.php index d3e6e984..2ffbfe02 100644 --- a/hwe/func_process_personnel.php +++ b/hwe/func_process_personnel.php @@ -134,7 +134,7 @@ function process_25(&$general) { $allGen = array_sum($generals); $genLimit = GameConst::$defaultMaxGeneral; - if($admin['join_mode'] == 'onlyRandom' && $admin['init_year'] == $admin['year'] && in_array($admin['month'], [$admin['init_month'], ($admin['init_month'] + 1) %12])){ + if($admin['join_mode'] == 'onlyRandom' && TimeUtil::IsRangeMonth($admin['init_year'], $admin['init_month'], 1, $admin['year'], $admin['month'])){ $genLimit = GameConst::$initialNationGenLimitForRandInit; } else if($admin['year'] < $admin['startyear'] + 3){ diff --git a/hwe/processing.php b/hwe/processing.php index fa7284bf..a6f664e1 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -704,7 +704,7 @@ function command_25($turn, $command) { $nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg,gennum FROM nation ORDER BY rand()'); foreach($nationList as $nation){ - if ($gameStor->year == $gameStor->init_year && $gameStor->month <= $gameStor->init_month && $nation['gennum'] >= GameConst::$initialNationGenLimitForRandInit) { + if ($onlyRandom && TimeUtil::IsRangeMonth($gameStor->init_year, $gameStor->init_month, 1, $gameStor->year, $gameStor->month) && $nation['gennum'] >= GameConst::$initialNationGenLimitForRandInit) { $nation['availableJoin'] = false; } else if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){ diff --git a/src/sammo/TimeUtil.php b/src/sammo/TimeUtil.php index 58bd50ec..29c8a5b9 100644 --- a/src/sammo/TimeUtil.php +++ b/src/sammo/TimeUtil.php @@ -65,16 +65,28 @@ class TimeUtil } /** - * $year년, $month월 부터 $afterMonth 개월 이내인지. $afterMonth 포함. + * $baseYear, $baseMonth 부터 $afterMonth 개월 이내인지. $afterMonth 포함. * */ - public static function IsRangeMonth(int $baseYear, int $baseMonth, int $askYear, int $askMonth, int $afterMonth):bool{ - if($month < 1 || $month > 12){ + public static function IsRangeMonth(int $baseYear, int $baseMonth, int $afterMonth, int $askYear, int $askMonth):bool{ + if($baseMonth < 1 || $baseMonth > 12){ throw new \InvalidArgumentException('개월이 올바르지 않음'); } - if($afterMonth < 0){ - throw new \InvalidArgumentException('기간이 올바르지 않음'); + if($askMonth < 1 || $askMonth > 12){ + throw new \InvalidArgumentException('개월이 올바르지 않음'); } + $minMonth = $baseYear * 12 + $baseMonth; + if($afterMonth < 0){ + $maxMonth = $minMonth; + $minMonth = $maxMonth - $afterMonth; + } + + $maxMonth = $minMonth + $afterMonth; + $askMonth = $askYear * 12 + $askMonth; + if($askMonth < $minMonth || $maxMonth < $askMonth){ + return false; + } + return true; } }