From 17d9853e9062a5e61af0f7e2d3124ff89dfb934d Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 19 Apr 2020 05:38:25 +0900 Subject: [PATCH] =?UTF-8?q?=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/b_currentCity.php | 2 +- hwe/func_time_event.php | 26 +++++++++++++------------- hwe/j_getChiefTurn.php | 2 +- hwe/j_simulate_battle.php | 2 +- hwe/join_post.php | 6 ++++-- hwe/sammo/Command/General/che_화계.php | 2 +- hwe/sammo/General.php | 2 +- hwe/sammo/GeneralAI.php | 24 ++++++++++-------------- hwe/sammo/Scenario/NPC.php | 6 ++++-- hwe/sammo/TurnExecutionHelper.php | 3 ++- 10 files changed, 38 insertions(+), 37 deletions(-) diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php index fa0c8d9a..1b757fbd 100644 --- a/hwe/b_currentCity.php +++ b/hwe/b_currentCity.php @@ -254,7 +254,7 @@ for($j=0; $j < $gencount; $j++) { $officerLevel = $general['officer_level']; $officerLevelText = getOfficerLevelText($officerLevel); - $lerdershipBonus = calcLeadershipBonus($officerLevel, $nationInfo['level']); + $leadershipBonus = calcLeadershipBonus($officerLevel, $nationInfo['level']); $leadershipBonusText = formatLeadershipBonus($leadershipBonus); if($ourGeneral){ diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 04f01011..71bfb36d 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -93,7 +93,7 @@ function processGoldIncome() { // 각 장수들에게 지급 foreach ($generalRawList as $rawGeneral) { - $generalObj = new General($rawGeneral, null, $year, $month, false); + $generalObj = new General($rawGeneral, null, null, $year, $month, false); $gold = Util::round(getBill($generalObj->getVar('dedication'))*$ratio); $generalObj->increaseVar('gold', $gold); @@ -236,7 +236,7 @@ function getGoldIncome(int $nationID, int $nationLevel, float $taxRate, int $cap $cityIncome = 0; foreach($cityList as $rawCity){ $cityID = $rawCity['city']; - $cityIncome += calcCityGoldIncome($rawCity, $officersCnt[$cityID], $capitalID == $cityID, $nationLevel, $nationTypeObj); + $cityIncome += calcCityGoldIncome($rawCity, $officersCnt[$cityID]??0, $capitalID == $cityID, $nationLevel, $nationTypeObj); } $cityIncome *= ($taxRate / 20); @@ -365,7 +365,7 @@ function processRiceIncome() { // 각 장수들에게 지급 foreach ($generalRawList as $rawGeneral) { - $generalObj = new General($rawGeneral, null, $year, $month, false); + $generalObj = new General($rawGeneral, null, null, $year, $month, false); $rice = Util::round(getBill($generalObj->getVar('dedication'))*$ratio); $generalObj->increaseVar('rice', $rice); @@ -403,7 +403,7 @@ function getRiceIncome(int $nationID, int $nationLevel, float $taxRate, int $cap foreach($cityList as $rawCity){ $cityID = $rawCity['city']; - $cityIncome += calcCityRiceIncome($rawCity, $officersCnt[$cityID], $capitalID == $cityID, $nationLevel, $nationTypeObj); + $cityIncome += calcCityRiceIncome($rawCity, $officersCnt[$cityID]??0, $capitalID == $cityID, $nationLevel, $nationTypeObj); } $cityIncome *= ($taxRate / 20); @@ -429,7 +429,7 @@ function getWallIncome(int $nationID, int $nationLevel, float $taxRate, int $cap foreach($cityList as $rawCity){ $cityID = $rawCity['city']; - $cityIncome += calcCityWallRiceIncome($rawCity, $officersCnt[$cityID], $capitalID == $cityID, $nationLevel, $nationTypeObj); + $cityIncome += calcCityWallRiceIncome($rawCity, $officersCnt[$cityID]??0, $capitalID == $cityID, $nationLevel, $nationTypeObj); } $cityIncome *= ($taxRate / 20); @@ -584,7 +584,7 @@ function disaster() { $generalList = array_map( function($rawGeneral) use ($city, $year, $month){ - return new General($rawGeneral, $city, $year, $month, false); + return new General($rawGeneral, null, $city, $year, $month, false); }, $generalListByCity[$city['city']]??[] ); @@ -599,13 +599,13 @@ function disaster() { $db->update('city', [ 'state'=>$stateCode, - 'pop'=>$db->sqleval('greatest(pop * %d, pop_max)', $affectRatio), - 'trust'=>$db->sqleval('greatest(trust * %d, 100)', $affectRatio), - 'agri'=>$db->sqleval('greatest(agri * %d, agri_max)', $affectRatio), - 'comm'=>$db->sqleval('greatest(comm * %d, comm_max)', $affectRatio), - 'secu'=>$db->sqleval('greatest(secu * %d, secu_max)', $affectRatio), - 'def'=>$db->sqleval('greatest(def * %d, def_max)', $affectRatio), - 'wall'=>$db->sqleval('greatest(wall * %d, wall_max)', $affectRatio), + 'pop'=>$db->sqleval('least(pop * %d, pop_max)', $affectRatio), + 'trust'=>$db->sqleval('least(trust * %d, 100)', $affectRatio), + 'agri'=>$db->sqleval('least(agri * %d, agri_max)', $affectRatio), + 'comm'=>$db->sqleval('least(comm * %d, comm_max)', $affectRatio), + 'secu'=>$db->sqleval('least(secu * %d, secu_max)', $affectRatio), + 'def'=>$db->sqleval('least(def * %d, def_max)', $affectRatio), + 'wall'=>$db->sqleval('least(wall * %d, wall_max)', $affectRatio), ], 'city = %i', $city['city']); diff --git a/hwe/j_getChiefTurn.php b/hwe/j_getChiefTurn.php index e630df0a..dc7fcbc0 100644 --- a/hwe/j_getChiefTurn.php +++ b/hwe/j_getChiefTurn.php @@ -50,7 +50,7 @@ $turn = []; $generals = []; foreach($db->query('SELECT no,name,turntime,npc,city,nation,officer_level FROM general WHERE nation = %i AND officer_level >= 5',$nationID) as $rawGeneral){ - $generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, $year, $month, false); + $generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, null, $year, $month, false); } $nationTurnList = []; diff --git a/hwe/j_simulate_battle.php b/hwe/j_simulate_battle.php index dbb803ca..4b0a0bec 100644 --- a/hwe/j_simulate_battle.php +++ b/hwe/j_simulate_battle.php @@ -146,7 +146,7 @@ foreach($rawDefenderList as $idx=>$rawDefenderGeneral){ 'reason'=>"[수비자{$idx}]".$v->errorStr() ]); } - $defenderList[] = new General($rawDefenderGeneral, $rawDefenderCity, $year, $month, true); + $defenderList[] = new General($rawDefenderGeneral, null, $rawDefenderCity, $year, $month, true); } diff --git a/hwe/join_post.php b/hwe/join_post.php index 86bd486f..b1d365f8 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -265,14 +265,16 @@ foreach(Util::range(GameConst::$maxTurn) as $turnIdx){ } $db->insert('general_turn', $turnRows); +$rank_data = []; foreach(array_keys(General::RANK_COLUMN) as $rankColumn){ - $db->insert('rank_data', [ + $rank_data[] = [ 'general_id'=>$generalID, 'nation_id'=>0, 'type'=>$rankColumn, 'value'=>0 - ]); + ]; } +$db->insert('rank_data', $rank_data); $cityname = CityConst::byID($city)->name; $me = [ diff --git a/hwe/sammo/Command/General/che_화계.php b/hwe/sammo/Command/General/che_화계.php index 128e6727..0ff9132f 100644 --- a/hwe/sammo/Command/General/che_화계.php +++ b/hwe/sammo/Command/General/che_화계.php @@ -250,7 +250,7 @@ class che_화계 extends Command\GeneralCommand{ $destCityID, $destNationID ) as $rawDestCityGeneral){ - $destCityGeneralList[] = new General($rawDestCityGeneral, $destCity, $year, $month, true); + $destCityGeneralList[] = new General($rawDestCityGeneral, null, $destCity, $year, $month, true); //계략에 성공할 경우 logger를 사용해야 하므로 해야하므로, 미리 초기화한다. //실패하면 날리는거지 뭐~ }; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 68217369..794cc64d 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -93,7 +93,7 @@ class General implements iAction{ } $this->resultTurn = new LastTurn(); - if($year !== null || $month !== null){ + if($year !== null && $month !== null){ $this->initLogger($year, $month); } diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 25b9abe5..43a98814 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -2849,8 +2849,8 @@ class GeneralAI $this->categorizeNationGeneral(); $this->categorizeNationCities(); + $month = $this->env['month']; if($general->getVar('officer_level') == 12){ - $month = $this->env['month']; if (in_array($month, [1, 4, 7, 10])) { $this->choosePromotion(); } else if ($month == 12) { @@ -3252,28 +3252,24 @@ class GeneralAI $nationID = $nation['nation']; + $rate = 15; //도시 - if(!$this->supplyCities){ - $db->update('nation', [ - 'war' => 0, - 'rate' => 15 - ], 'nation=%i', $nationID); - } else { + if($this->supplyCities){ $devRate = $this->calcNationDevelopedRate(); - $avg = ($devRate['pop'] + $devRate['all_p']) / 2; + $avg = ($devRate['pop'] + $devRate['all']) / 2; if ($avg > 0.95) $rate = 25; elseif ($avg > 0.70) $rate = 20; elseif ($avg > 0.50) $rate = 15; else $rate = 10; - - $db->update('nation', [ - 'war' => 0, - 'rate' => $rate - ], 'nation=%i', $nationID); - return $rate; } + + $db->update('nation', [ + 'war' => 0, + 'rate' => $rate + ], 'nation=%i', $nationID); + return $rate; } protected function chooseGoldBillRate(): int diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index 8dbfceca..6c8a2b3b 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -358,14 +358,16 @@ class NPC{ } $db->insert('general_turn', $turnRows); + $rank_data = []; foreach(array_keys(\sammo\General::RANK_COLUMN) as $rankColumn){ - $db->insert('rank_data', [ + $rank_data[] = [ 'general_id'=>$this->generalID, 'nation_id'=>0, 'type'=>$rankColumn, 'value'=>0 - ]); + ]; } + $db->insert('rank_data', $rank_data); return true; //생성되었다. } diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index e2fed614..b767c7d1 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -224,6 +224,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', $currentTurn = null; $gameStor = KVStorage::getStorage($db, 'game_env'); + $autorun_user = $gameStor->autorun_user; foreach($generalsTodo as $rawGeneral){ $generalCommand = $rawGeneral['action']; @@ -261,7 +262,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', } - if($general->getVar('npc') >= 2){ + if($general->getVar('npc') >= 2 || ($autorun_user['limit_minutes']??false)){ $ai = new GeneralAI($turnObj->getGeneral()); if($hasNationTurn){ $nationCommandObj = $ai->chooseNationTurn($nationCommandObj);