General의 통합 interface 간소화
This commit is contained in:
+88
-146
@@ -192,111 +192,81 @@ class General implements iActionTrigger{
|
|||||||
|
|
||||||
public function onPreTurnExecute(General $general, ?array $nation):array{
|
public function onPreTurnExecute(General $general, ?array $nation):array{
|
||||||
$chain = [];
|
$chain = [];
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$chain[] = $nationType->onPreTurnExecute($general, $nation);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$chain[] = $levelObj->onPreTurnExecute($general, $nation);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$chain[] = $specialDomesticObj->onPreTurnExecute($general, $nation);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$chain[] = $specialWarObj->onPreTurnExecute($general, $nation);
|
$chain[] = $iObj->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);
|
return array_merge([], ...$chain);
|
||||||
}
|
}
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value):float{
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$value = $nationType->onCalcDomestic($turnType, $varType, $value);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$value = $levelObj->onCalcDomestic($turnType, $varType, $value);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$value = $specialDomesticObj->onCalcDomestic($turnType, $varType, $value);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$value = $specialWarObj->onCalcDomestic($turnType, $varType, $value);
|
$value = $iObj->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;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
|
public function onPreGeneralStatUpdate(General $general, string $statName, $value){
|
||||||
//xxx: $general?
|
//xxx: $general?
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$value = $nationType->onPreGeneralStatUpdate($this, $statName, $value);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$value = $levelObj->onPreGeneralStatUpdate($this, $statName, $value);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$value = $specialDomesticObj->onPreGeneralStatUpdate($this, $statName, $value);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$value = $specialWarObj->onPreGeneralStatUpdate($this, $statName, $value);
|
$value = $iObj->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;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCalcStrategic(string $turnType, string $varType, $value){
|
public function onCalcStrategic(string $turnType, string $varType, $value){
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$value = $nationType->onCalcStrategic($turnType, $varType, $value);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$value = $levelObj->onCalcStrategic($turnType, $varType, $value);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$value = $specialDomesticObj->onCalcStrategic($turnType, $varType, $value);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$value = $specialWarObj->onCalcStrategic($turnType, $varType, $value);
|
$value = $iObj->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;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$amount = $nationType->onCalcNationalIncome($type, $amount);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$amount = $levelObj->onCalcNationalIncome($type, $amount);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$amount = $specialDomesticObj->onCalcNationalIncome($type, $amount);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$amount = $specialWarObj->onCalcNationalIncome($type, $amount);
|
$amount = $iObj->onCalcNationalIncome($type, $amount);
|
||||||
}
|
|
||||||
if($this->personalityObj){
|
|
||||||
$amount = $personalityObj->onCalcNationalIncome($type, $amount);
|
|
||||||
}
|
|
||||||
foreach($this->itemObjs as $itemObj){
|
|
||||||
$amount = $itemObj->onCalcNationalIncome($type, $amount);
|
|
||||||
}
|
}
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
@@ -305,33 +275,17 @@ class General implements iActionTrigger{
|
|||||||
//xxx:$unit
|
//xxx:$unit
|
||||||
$att = 1;
|
$att = 1;
|
||||||
$def = 1;
|
$def = 1;
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
[$attV, $defV] = $nationType->getWarPowerMultiplier($unit);
|
$this->nationType,
|
||||||
$att *= $attV;
|
$this->levelObj,
|
||||||
$def *= $defV;
|
$this->specialDomesticObj,
|
||||||
}
|
$this->specialWarObj,
|
||||||
if($this->levelObj){
|
$this->personalityObj,
|
||||||
[$attV, $defV] = $levelObj->getWarPowerMultiplier($unit);
|
], $this->itemObjs) as $iObj){
|
||||||
$att *= $attV;
|
if(!$iObj){
|
||||||
$def *= $defV;
|
continue;
|
||||||
}
|
}
|
||||||
if($this->specialDomesticObj){
|
[$attV, $defV] = $iObj->getWarPowerMultiplier($unit);
|
||||||
[$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;
|
$att *= $attV;
|
||||||
$def *= $defV;
|
$def *= $defV;
|
||||||
}
|
}
|
||||||
@@ -339,45 +293,33 @@ class General implements iActionTrigger{
|
|||||||
}
|
}
|
||||||
public function getBattleInitSkillTriggerList(WarUnit $unit):array{
|
public function getBattleInitSkillTriggerList(WarUnit $unit):array{
|
||||||
$chain = [];
|
$chain = [];
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$chain[] = $nationType->getBattleInitSkillTriggerList($unit);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$chain[] = $levelObj->getBattleInitSkillTriggerList($unit);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$chain[] = $specialDomesticObj->getBattleInitSkillTriggerList($unit);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$chain[] = $specialWarObj->getBattleInitSkillTriggerList($unit);
|
$chain[] = $iObj->getBattleInitSkillTriggerList($unit);
|
||||||
}
|
|
||||||
if($this->personalityObj){
|
|
||||||
$chain[] = $personalityObj->getBattleInitSkillTriggerList($unit);
|
|
||||||
}
|
|
||||||
foreach($this->itemObjs as $itemObj){
|
|
||||||
$chain[] = $itemObj->getBattleInitSkillTriggerList($unit);
|
|
||||||
}
|
}
|
||||||
return array_merge([], ...$chain);
|
return array_merge([], ...$chain);
|
||||||
}
|
}
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):array{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):array{
|
||||||
$chain = [];
|
$chain = [];
|
||||||
if($this->nationType){
|
foreach(array_merge([
|
||||||
$chain[] = $nationType->getBattlePhaseSkillTriggerList($unit);
|
$this->nationType,
|
||||||
}
|
$this->levelObj,
|
||||||
if($this->levelObj){
|
$this->specialDomesticObj,
|
||||||
$chain[] = $levelObj->getBattlePhaseSkillTriggerList($unit);
|
$this->specialWarObj,
|
||||||
}
|
$this->personalityObj,
|
||||||
if($this->specialDomesticObj){
|
], $this->itemObjs) as $iObj){
|
||||||
$chain[] = $specialDomesticObj->getBattlePhaseSkillTriggerList($unit);
|
if(!$iObj){
|
||||||
}
|
continue;
|
||||||
if($this->specialWarObj){
|
}
|
||||||
$chain[] = $specialWarObj->getBattlePhaseSkillTriggerList($unit);
|
$chain[] = $iObj->getBattlePhaseSkillTriggerList($unit);
|
||||||
}
|
|
||||||
if($this->personalityObj){
|
|
||||||
$chain[] = $personalityObj->getBattlePhaseSkillTriggerList($unit);
|
|
||||||
}
|
|
||||||
foreach($this->itemObjs as $itemObj){
|
|
||||||
$chain[] = $itemObj->getBattlePhaseSkillTriggerList($unit);
|
|
||||||
}
|
}
|
||||||
return array_merge([], ...$chain);
|
return array_merge([], ...$chain);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user