From dd73d8fc695393b023892b133e761ec1f50a88c7 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 13 Sep 2018 02:38:27 +0900 Subject: [PATCH] =?UTF-8?q?General=EC=97=90=20iActionTrigger=20=ED=99=9C?= =?UTF-8?q?=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/General.php | 211 +++++++++++++++++++++++++++++++++++++++-- hwe/scenario/.htaccess | 1 - 2 files changed, 201 insertions(+), 11 deletions(-) delete mode 100644 hwe/scenario/.htaccess diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index a0eb37ce..a68d59fb 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -2,7 +2,7 @@ namespace sammo; -class General{ +class General implements iActionTrigger{ use LazyVarUpdater; /** @@ -21,10 +21,12 @@ class General{ protected $isFinished = false; - protected $nationType; - protected $levelObj; - protected $specialDomesticObj; - protected $characteristicObj; + protected $nationType = null; + protected $levelObj = null; + protected $specialDomesticObj = null; + protected $specialWarObj = null; + protected $personalityObj = null; + protected $itemObjs = []; public function __construct(array $raw, ?array $city, int $year, int $month){ //TODO: 밖에서 가져오도록 하면 버그 확률이 높아짐. 필요한 raw 값을 직접 구해야함. @@ -46,7 +48,8 @@ class General{ $nationTypeClass = getNationTypeClass($staticNation['type']); $this->nationType = new $nationTypeClass; $this->levelObj = new TriggerGeneralLevel($this->raw, $city); - $this->levelObj = new TriggerGeneralLevel($this->raw, $city); + $personalityClass = getPersonalityClass($raw['personal']); + $this->personalityObj = new $personalityClass; } protected function clearActivatedSkill(){ @@ -116,10 +119,6 @@ class General{ return $this->levelObj; } - public function onCalcDomestic(string $turnType, string $varType, float $value){ - - } - //TODO: 장기적으로 General 클래스로 모두 옮겨와야함. function getLeadership($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{ return getGeneralLeadership($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor); @@ -148,4 +147,196 @@ class General{ $this->getLogger()->flush(); return $db->affectedRows() > 0; } + + public function onPreTurnExecute(General $general, ?array $nation):array{ + $chain = []; + if($this->nationType){ + $chain[] = $nationType->onPreTurnExecute($general, $nation); + } + if($this->levelObj){ + $chain[] = $levelObj->onPreTurnExecute($general, $nation); + } + if($this->specialDomesticObj){ + $chain[] = $specialDomesticObj->onPreTurnExecute($general, $nation); + } + if($this->specialWarObj){ + $chain[] = $specialWarObj->onPreTurnExecute($general, $nation); + } + if($this->personalityObj){ + $chain[] = $personalityObj->onPreTurnExecute($general, $nation); + } + foreach($this->itemObjs as $itemObj){ + $chain[] = $itemObj->onPreTurnExecute($general, $nation); + } + return array_merge([], ...$chain); + } + public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + if($this->nationType){ + $value = $nationType->onCalcDomestic($turnType, $varType, $value); + } + if($this->levelObj){ + $value = $levelObj->onCalcDomestic($turnType, $varType, $value); + } + if($this->specialDomesticObj){ + $value = $specialDomesticObj->onCalcDomestic($turnType, $varType, $value); + } + if($this->specialWarObj){ + $value = $specialWarObj->onCalcDomestic($turnType, $varType, $value); + } + if($this->personalityObj){ + $value = $personalityObj->onCalcDomestic($turnType, $varType, $value); + } + foreach($this->itemObjs as $itemObj){ + $value = $itemObj->onCalcDomestic($turnType, $varType, $value); + } + return $value; + } + + public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + //xxx: $general? + if($this->nationType){ + $value = $nationType->onPreGeneralStatUpdate($this, $statName, $value); + } + if($this->levelObj){ + $value = $levelObj->onPreGeneralStatUpdate($this, $statName, $value); + } + if($this->specialDomesticObj){ + $value = $specialDomesticObj->onPreGeneralStatUpdate($this, $statName, $value); + } + if($this->specialWarObj){ + $value = $specialWarObj->onPreGeneralStatUpdate($this, $statName, $value); + } + if($this->personalityObj){ + $value = $personalityObj->onPreGeneralStatUpdate($this, $statName, $value); + } + foreach($this->itemObjs as $itemObj){ + $value = $itemObj->onPreGeneralStatUpdate($this, $statName, $value); + } + return $value; + } + + public function onCalcStrategic(string $turnType, string $varType, $value){ + if($this->nationType){ + $value = $nationType->onCalcStrategic($turnType, $varType, $value); + } + if($this->levelObj){ + $value = $levelObj->onCalcStrategic($turnType, $varType, $value); + } + if($this->specialDomesticObj){ + $value = $specialDomesticObj->onCalcStrategic($turnType, $varType, $value); + } + if($this->specialWarObj){ + $value = $specialWarObj->onCalcStrategic($turnType, $varType, $value); + } + if($this->personalityObj){ + $value = $personalityObj->onCalcStrategic($turnType, $varType, $value); + } + foreach($this->itemObjs as $itemObj){ + $value = $itemObj->onCalcStrategic($turnType, $varType, $value); + } + return $value; + } + + public function onCalcNationalIncome(string $type, int $amount):int{ + if($this->nationType){ + $amount = $nationType->onCalcNationalIncome($type, $amount); + } + if($this->levelObj){ + $amount = $levelObj->onCalcNationalIncome($type, $amount); + } + if($this->specialDomesticObj){ + $amount = $specialDomesticObj->onCalcNationalIncome($type, $amount); + } + if($this->specialWarObj){ + $amount = $specialWarObj->onCalcNationalIncome($type, $amount); + } + if($this->personalityObj){ + $amount = $personalityObj->onCalcNationalIncome($type, $amount); + } + foreach($this->itemObjs as $itemObj){ + $amount = $itemObj->onCalcNationalIncome($type, $amount); + } + return $amount; + } + + public function getWarPowerMultiplier(WarUnit $unit):array{ + //xxx:$unit + $att = 1; + $def = 1; + if($this->nationType){ + [$attV, $defV] = $nationType->getWarPowerMultiplier($unit); + $att *= $attV; + $def *= $defV; + } + if($this->levelObj){ + [$attV, $defV] = $levelObj->getWarPowerMultiplier($unit); + $att *= $attV; + $def *= $defV; + } + if($this->specialDomesticObj){ + [$attV, $defV] = $specialDomesticObj->getWarPowerMultiplier($unit); + $att *= $attV; + $def *= $defV; + } + if($this->specialWarObj){ + [$attV, $defV] = $specialWarObj->getWarPowerMultiplier($unit); + $att *= $attV; + $def *= $defV; + } + if($this->personalityObj){ + [$attV, $defV] = $personalityObj->getWarPowerMultiplier($unit); + $att *= $attV; + $def *= $defV; + } + foreach($this->itemObjs as $itemObj){ + [$attV, $defV] = $itemObj->getWarPowerMultiplier($unit); + $att *= $attV; + $def *= $defV; + } + return [$att, $def]; + } + public function getBattleInitSkillTriggerList(WarUnit $unit):array{ + $chain = []; + if($this->nationType){ + $chain[] = $nationType->getBattleInitSkillTriggerList($unit); + } + if($this->levelObj){ + $chain[] = $levelObj->getBattleInitSkillTriggerList($unit); + } + if($this->specialDomesticObj){ + $chain[] = $specialDomesticObj->getBattleInitSkillTriggerList($unit); + } + if($this->specialWarObj){ + $chain[] = $specialWarObj->getBattleInitSkillTriggerList($unit); + } + if($this->personalityObj){ + $chain[] = $personalityObj->getBattleInitSkillTriggerList($unit); + } + foreach($this->itemObjs as $itemObj){ + $chain[] = $itemObj->getBattleInitSkillTriggerList($unit); + } + return array_merge([], ...$chain); + } + public function getBattlePhaseSkillTriggerList(WarUnit $unit):array{ + $chain = []; + if($this->nationType){ + $chain[] = $nationType->getBattlePhaseSkillTriggerList($unit); + } + if($this->levelObj){ + $chain[] = $levelObj->getBattlePhaseSkillTriggerList($unit); + } + if($this->specialDomesticObj){ + $chain[] = $specialDomesticObj->getBattlePhaseSkillTriggerList($unit); + } + if($this->specialWarObj){ + $chain[] = $specialWarObj->getBattlePhaseSkillTriggerList($unit); + } + if($this->personalityObj){ + $chain[] = $personalityObj->getBattlePhaseSkillTriggerList($unit); + } + foreach($this->itemObjs as $itemObj){ + $chain[] = $itemObj->getBattlePhaseSkillTriggerList($unit); + } + return array_merge([], ...$chain); + } } \ No newline at end of file diff --git a/hwe/scenario/.htaccess b/hwe/scenario/.htaccess deleted file mode 100644 index 698196ae..00000000 --- a/hwe/scenario/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all \ No newline at end of file