From 1e485a3883e3c727451c4cb8c6a005258e5ea50b Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 18 May 2020 23:17:16 +0900 Subject: [PATCH] =?UTF-8?q?onCalcNationalIncome=20=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_time_event.php | 4 ++++ hwe/sammo/ActionNationType/che_덕가.php | 8 ++++---- hwe/sammo/ActionNationType/che_도가.php | 6 +++--- hwe/sammo/ActionNationType/che_도적.php | 4 ++-- hwe/sammo/ActionNationType/che_명가.php | 8 ++++---- hwe/sammo/ActionNationType/che_법가.php | 8 ++++---- hwe/sammo/ActionNationType/che_병가.php | 6 +++--- hwe/sammo/ActionNationType/che_불가.php | 4 ++-- hwe/sammo/ActionNationType/che_오두미도.php | 8 ++++---- hwe/sammo/ActionNationType/che_유가.php | 4 ++-- hwe/sammo/ActionNationType/che_음양가.php | 6 +++--- hwe/sammo/ActionNationType/che_종횡가.php | 4 ++-- hwe/sammo/ActionNationType/che_태평도.php | 6 +++--- hwe/sammo/DefaultAction.php | 2 +- hwe/sammo/General.php | 2 +- hwe/sammo/GeneralAI.php | 9 +++++++-- hwe/sammo/iAction.php | 2 +- 17 files changed, 50 insertions(+), 41 deletions(-) diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index c5275904..2e9234c4 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -87,6 +87,8 @@ function processGoldIncome() { $incomeText = number_format($income); $incomeLog = "이번 수입은 금 $incomeText입니다."; + $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); + $nationStor->prev_income_gold = $income; $db->update('nation', [ 'gold'=>$nation['gold'] @@ -362,6 +364,8 @@ function processRiceIncome() { $incomeText = number_format($income); $incomeLog = "이번 수입은 쌀 $incomeText입니다."; + $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); + $nationStor->prev_income_rice = $income; $db->update('nation', [ 'rice'=>$nation['rice'] diff --git a/hwe/sammo/ActionNationType/che_덕가.php b/hwe/sammo/ActionNationType/che_덕가.php index 7b0c486f..f5697ec4 100644 --- a/hwe/sammo/ActionNationType/che_덕가.php +++ b/hwe/sammo/ActionNationType/che_덕가.php @@ -29,12 +29,12 @@ class che_덕가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'rice'){ - return Util::toInt($amount * 0.9); + return $amount * 0.9; } - if($type == 'pop'){ - return Util::toInt($amount * 1.2); + if($type == 'pop' && $amount > 0){ + return $amount * 1.2; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_도가.php b/hwe/sammo/ActionNationType/che_도가.php index 30eeeb4e..a27ebbca 100644 --- a/hwe/sammo/ActionNationType/che_도가.php +++ b/hwe/sammo/ActionNationType/che_도가.php @@ -24,9 +24,9 @@ class che_도가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ - if($type == 'pop'){ - return Util::toInt($amount * 1.2); + public function onCalcNationalIncome(string $type, $amount){ + if($type == 'pop' && $amount > 0){ + return $amount * 1.2; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_도적.php b/hwe/sammo/ActionNationType/che_도적.php index 981f1f74..30d2f80e 100644 --- a/hwe/sammo/ActionNationType/che_도적.php +++ b/hwe/sammo/ActionNationType/che_도적.php @@ -28,9 +28,9 @@ class che_도적 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'gold'){ - return Util::toInt($amount * 0.9); + return $amount * 0.9; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_명가.php b/hwe/sammo/ActionNationType/che_명가.php index 68bae153..843f0392 100644 --- a/hwe/sammo/ActionNationType/che_명가.php +++ b/hwe/sammo/ActionNationType/che_명가.php @@ -25,12 +25,12 @@ class che_명가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'rice'){ - return Util::toInt($amount * 0.9); + return $amount * 0.9; } - if($type == 'pop'){ - return Util::toInt($amount * 1.2); + if($type == 'pop' && $amount > 0){ + return $amount * 1.2; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_법가.php b/hwe/sammo/ActionNationType/che_법가.php index 81d414d3..c4b56394 100644 --- a/hwe/sammo/ActionNationType/che_법가.php +++ b/hwe/sammo/ActionNationType/che_법가.php @@ -25,12 +25,12 @@ class che_법가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'gold'){ - return Util::toInt($amount * 1.1); + return $amount * 1.1; } - if($type == 'pop'){ - return Util::toInt($amount * 0.8); + if($type == 'pop' && $amount > 0){ + return $amount * 0.8; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_병가.php b/hwe/sammo/ActionNationType/che_병가.php index 8eff57ec..401dc1fc 100644 --- a/hwe/sammo/ActionNationType/che_병가.php +++ b/hwe/sammo/ActionNationType/che_병가.php @@ -29,9 +29,9 @@ class che_병가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ - if($type == 'pop'){ - return Util::toInt($amount * 0.8); + public function onCalcNationalIncome(string $type, $amount):int{ + if($type == 'pop' && $amount > 0){ + return $amount * 0.8; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_불가.php b/hwe/sammo/ActionNationType/che_불가.php index 6fc210ae..7d369c46 100644 --- a/hwe/sammo/ActionNationType/che_불가.php +++ b/hwe/sammo/ActionNationType/che_불가.php @@ -24,9 +24,9 @@ class che_불가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'gold'){ - return Util::toInt($amount * 0.9); + return $amount * 0.9; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_오두미도.php b/hwe/sammo/ActionNationType/che_오두미도.php index 8b1dd72a..33003e46 100644 --- a/hwe/sammo/ActionNationType/che_오두미도.php +++ b/hwe/sammo/ActionNationType/che_오두미도.php @@ -29,12 +29,12 @@ class che_오두미도 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'rice'){ - return Util::toInt($amount * 1.1); + return $amount * 1.1; } - if($type == 'pop'){ - return Util::toInt($amount * 1.2); + if($type == 'pop' && $amount > 0){ + return $amount * 1.2; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_유가.php b/hwe/sammo/ActionNationType/che_유가.php index b427ce51..b160e641 100644 --- a/hwe/sammo/ActionNationType/che_유가.php +++ b/hwe/sammo/ActionNationType/che_유가.php @@ -24,9 +24,9 @@ class che_유가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'rice'){ - return Util::toInt($amount * 0.9); + return $amount * 0.9; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_음양가.php b/hwe/sammo/ActionNationType/che_음양가.php index 45c3e3f4..edda2a98 100644 --- a/hwe/sammo/ActionNationType/che_음양가.php +++ b/hwe/sammo/ActionNationType/che_음양가.php @@ -25,9 +25,9 @@ class che_음양가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ - if($type == 'pop'){ - return Util::toInt($amount * 1.2); + public function onCalcNationalIncome(string $type, $amount){ + if($type == 'pop' && $amount > 0){ + return $amount * 1.2; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_종횡가.php b/hwe/sammo/ActionNationType/che_종횡가.php index 81030bc3..344895df 100644 --- a/hwe/sammo/ActionNationType/che_종횡가.php +++ b/hwe/sammo/ActionNationType/che_종횡가.php @@ -25,9 +25,9 @@ class che_종횡가 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ if($type == 'gold'){ - return Util::toInt($amount * 0.9); + return $amount * 0.9; } return $amount; diff --git a/hwe/sammo/ActionNationType/che_태평도.php b/hwe/sammo/ActionNationType/che_태평도.php index 96f4d4bf..ec14a4d3 100644 --- a/hwe/sammo/ActionNationType/che_태평도.php +++ b/hwe/sammo/ActionNationType/che_태평도.php @@ -29,9 +29,9 @@ class che_태평도 extends \sammo\BaseNation{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ - if($type == 'pop'){ - return Util::toInt($amount * 1.2); + public function onCalcNationalIncome(string $type, $amount){ + if($type == 'pop' && $amount > 0){ + return $amount * 1.2; } return $amount; diff --git a/hwe/sammo/DefaultAction.php b/hwe/sammo/DefaultAction.php index 6fbde710..8b8f2c9d 100644 --- a/hwe/sammo/DefaultAction.php +++ b/hwe/sammo/DefaultAction.php @@ -29,7 +29,7 @@ trait DefaultAction{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ return $amount; } diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 25355008..d43ce199 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -821,7 +821,7 @@ class General implements iAction{ return $value; } - public function onCalcNationalIncome(string $type, int $amount):int{ + public function onCalcNationalIncome(string $type, $amount){ foreach(array_merge([ $this->nationType, $this->officerLevelObj, diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 4028bc1e..a8c877fa 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -48,6 +48,9 @@ class GeneralAI protected $warRoute; + protected $prevIncomeGold; + protected $prevIncomeRice; + /** @var General[] */ protected $nationGenerals; /** @var General[] */ @@ -112,13 +115,15 @@ class GeneralAI 'color' => '#000000', 'name' => '재야', ]; - - $gameStor = KVStorage::getStorage($db, 'game_env'); $nationStor = KVStorage::getStorage($db, $this->nation['nation'], 'nation_env'); + $nationStor->cacheValues(['npc_nation_policy','npc_general_policy','prev_income_gold','prev_income_rice']); $this->nationPolicy = new AutorunNationPolicy($general, $this->env['autorun_user']['options'], $nationStor->getValue('npc_nation_policy'), $gameStor->getValue('npc_nation_policy'), $this->nation, $this->env); $this->generalPolicy = new AutorunGeneralPolicy($general, $this->env['autorun_user']['options'], $nationStor->getValue('npc_general_policy'), $gameStor->getValue('npc_general_policy'), $this->nation, $this->env); + $this->prevIncomeGold = $nationStor->prev_income_gold??1000; + $this->prevIncomeRice = $nationStor->prev_income_rice??1000; + $this->nation['aux'] = Json::decode($this->nation['aux']??'{}'); $this->leadership = $general->getLeadership(); diff --git a/hwe/sammo/iAction.php b/hwe/sammo/iAction.php index 53c7437e..bad753b7 100644 --- a/hwe/sammo/iAction.php +++ b/hwe/sammo/iAction.php @@ -11,7 +11,7 @@ interface iAction{ public function onCalcStat(General $general, string $statName, $value, $aux=null); public function onCalcStrategic(string $turnType, string $varType, $value); - public function onCalcNationalIncome(string $type, int $amount):int; + public function onCalcNationalIncome(string $type, $amount); public function getWarPowerMultiplier(WarUnit $unit):array; public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller;