전투 시뮬레이션 구현 (동작)
This commit is contained in:
@@ -43,6 +43,16 @@ class ActionLogger{
|
||||
}
|
||||
|
||||
public function rollback(){
|
||||
$backup = [
|
||||
'generalHistoryLog'=>$this->generalHistoryLog,
|
||||
'generalActionLog'=>$this->generalActionLog,
|
||||
'generalBattleResultLog'=>$this->generalBattleResultLog,
|
||||
'generalBattleDetailLog'=>$this->generalBattleDetailLog,
|
||||
'nationalHistoryLog'=>$this->nationalHistoryLog,
|
||||
'globalHistoryLog'=>$this->globalHistoryLog,
|
||||
'globalActionLog'=>$this->globalActionLog,
|
||||
];
|
||||
|
||||
$this->generalHistoryLog = [];
|
||||
$this->generalActionLog = [];
|
||||
$this->generalBattleResultLog = [];
|
||||
@@ -50,6 +60,8 @@ class ActionLogger{
|
||||
$this->nationalHistoryLog = [];
|
||||
$this->globalHistoryLog = [];
|
||||
$this->globalActionLog = [];
|
||||
|
||||
return $backup;
|
||||
}
|
||||
|
||||
public function flush(){
|
||||
|
||||
+23
-2
@@ -28,11 +28,32 @@ class WarUnit{
|
||||
protected $warPowerMultiply = 1.0;
|
||||
|
||||
protected $activatedSkill = [];
|
||||
protected $logActivatedSkill = [];
|
||||
protected $isFinished = false;
|
||||
|
||||
private function __construct(){
|
||||
}
|
||||
|
||||
protected function clearActivatedSkill(){
|
||||
foreach($this->activatedSkill as $skillName=>$state){
|
||||
if(!$state){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!key_exists($skillName, $this->logActivatedSkill)){
|
||||
$this->logActivatedSkill[$skillName] = 1;
|
||||
}
|
||||
else{
|
||||
$this->logActivatedSkill[$skillName] += 1;
|
||||
}
|
||||
}
|
||||
$this->activatedSkill = [];
|
||||
}
|
||||
|
||||
function getActivatedSkillLog():array{
|
||||
return $this->logActivatedSkill;
|
||||
}
|
||||
|
||||
function getRaw():array{
|
||||
return $this->raw;
|
||||
}
|
||||
@@ -183,7 +204,7 @@ class WarUnit{
|
||||
$this->oppose = $oppose;
|
||||
$this->killedCurr = 0;
|
||||
$this->deadCurr = 0;
|
||||
$this->activatedSkill = [];
|
||||
$this->clearActivatedSkill();
|
||||
}
|
||||
|
||||
function getOppose():?WarUnit{
|
||||
@@ -312,7 +333,7 @@ class WarUnit{
|
||||
}
|
||||
|
||||
function beginPhase():void{
|
||||
$this->activatedSkill = [];
|
||||
$this->clearActivatedSkill();
|
||||
$this->computeWarPower();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ class WarUnitCity extends WarUnit{
|
||||
if($this->isFinished){
|
||||
return;
|
||||
}
|
||||
$this->clearActivatedSkill();
|
||||
$this->isFinished = true;
|
||||
|
||||
$this->updateVar('def', Util::round($this->getHP() / 10));
|
||||
|
||||
@@ -954,6 +954,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
if($this->isFinished){
|
||||
return;
|
||||
}
|
||||
$this->clearActivatedSkill();
|
||||
$this->isFinished = true;
|
||||
|
||||
$this->increaseVar('killcrew', $this->killed);
|
||||
|
||||
Reference in New Issue
Block a user