General에 iActionTrigger 활성화

This commit is contained in:
2018-09-13 02:38:27 +09:00
parent b89d37c8c5
commit dd73d8fc69
2 changed files with 201 additions and 11 deletions
+201 -10
View File
@@ -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);
}
}
-1
View File
@@ -1 +0,0 @@
Deny from all