General의 통합 interface 간소화

This commit is contained in:
2018-09-15 00:38:28 +09:00
parent 9fc10e0f65
commit ed24a721ed
+80 -138
View File
@@ -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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $chain[] = $iObj->onPreTurnExecute($general, $nation);
$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); 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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $value = $iObj->onCalcDomestic($turnType, $varType, $value);
$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; 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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $value = $iObj->onPreGeneralStatUpdate($this, $statName, $value);
$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; 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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $value = $iObj->onCalcStrategic($turnType, $varType, $value);
$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; 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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $amount = $iObj->onCalcNationalIncome($type, $amount);
$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; 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,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ [$attV, $defV] = $iObj->getWarPowerMultiplier($unit);
[$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; $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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $chain[] = $iObj->getBattleInitSkillTriggerList($unit);
$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); 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,
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
} }
if($this->levelObj){ $chain[] = $iObj->getBattlePhaseSkillTriggerList($unit);
$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); return array_merge([], ...$chain);
} }