코드 중간 반영

This commit is contained in:
2018-08-18 20:45:59 +09:00
parent ef8c9e3968
commit 5979273a64
5 changed files with 123 additions and 36 deletions
+44 -7
View File
@@ -7,14 +7,13 @@ class WarUnitCity extends WarUnit{
protected $logger;
protected $crewType;
protected $hp;
protected $trainAtmos;
protected $rice = 0;
protected $updatedVar = [];
protected $def;
protected $wall;
function __construct($raw, $rawNation, $year, $month){
$this->raw = $raw;
$this->rawNation = $rawNation;
@@ -24,11 +23,12 @@ class WarUnitCity extends WarUnit{
$this->logger = new ActionLogger(0, $raw['nation'], $year, $month);
$this->crewType = GameUnitConst::byID($raw['crewtype']);
$this->def = $raw['def'] * 10;
$this->wall = $raw['wall'] * 10;
$this->rice = $this->rawNation['rice'];
$this->crewType = GameUnitConst::byID(GameUnitConst::T_CASTLE);
$this->hp = $this->raw['def'] * 10;;
$this->trainAtmos = $this->raw['wall'] * 10;
}
function getRaw():array{
@@ -44,10 +44,27 @@ class WarUnitCity extends WarUnit{
$warPower *= Util::randRange(0.9, 1.1);
}
function increaseKilled(int $damage):int{
$this->killed += $damage;
return $this->killed;
}
function getHP():int{
return $this->hp;
}
function decreaseHP(int $damage):int{
$damage = min($damage, $this->hp);
$this->dead += $damage;
$this->hp -= $damage;
}
function continueWar(&$noRice):bool{
//전투가 가능하면 true
$noRice = false;
if($this->def <= 0){
if($this->getHP() <= 0){
return false;
}
@@ -55,6 +72,26 @@ class WarUnitCity extends WarUnit{
return true;
}
function finishBattle(){
$this->raw['def'] = Util::round($this->hp / 10);
$this->updatedVar['def'] = true;
$this->raw['wall'] = Util::round($this->trainAtmos / 10);
$this->updatedVar['wall'] = true;
$this->raw['dead'] += $this->dead;
$this->updatedVar['dead'] = true;
$decWealth = $this->dead / 10;
$this->raw['agri'] = max(0, Util::round($this->raw['agri'] - $decWealth));
$this->updatedVar['agri'] = true;
$this->raw['comm'] = max(0, Util::round($this->raw['comm'] - $decWealth));
$this->updatedVar['comm'] = true;
$this->raw['secu'] = max(0, Util::round($this->raw['secu'] - $decWealth));
$this->updatedVar['secu'] = true;
}
function applyDB($db):bool{
$updateVals = [];
foreach(array_keys($this->updatedVar) as $key){