Files
core/hwe/sammo/Command/General/che_소집해제.php
T

91 lines
2.1 KiB
PHP

<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_소집해제 extends Command\GeneralCommand{
static protected $actionName = '소집해제';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->fullConditionConstraints=[
ConstraintHelper::ReqGeneralCrew(),
];
}
public function getCommandDetailTitle():string{
$name = $this->getName();
return "{$name}(병사↓, 인구↑)";
}
public function getCost():array{
return [0, 0];
}
public function getPreReqTurn():int{
return 0;
}
public function getPostReqTurn():int{
return 0;
}
public function run(\Sammo\RandUtil $rng):bool{
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
$db = DB::db();
$general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM);
$logger = $general->getLogger();
$logger->pushGeneralActionLog("병사들을 <R>소집해제</>하였습니다. <1>$date</>");
$exp = 70;
$ded = 100;
$crewUp = $general->onCalcDomestic('징집인구', 'score', $general->getVar('crew'));
$db->update('city', [
'pop'=>$db->sqleval('pop + %i', $crewUp)
], 'city=%i', $general->getCityID());
$general->setVar('crew', 0);
$general->addExperience($exp);
$general->addDedication($ded);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg ?? []);
$general->applyDB($db);
return true;
}
}