사기진작 추가

This commit is contained in:
2018-10-15 02:09:19 +09:00
parent 2ee06eab2d
commit 928e8a200b
2 changed files with 107 additions and 1 deletions
@@ -0,0 +1,106 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx,
LastTurn
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
use sammo\GameUnitConst;
class che_사기진작 extends Command\GeneralCommand{
static protected $actionName = '사기진작';
protected function init(){
$general = $this->generalObj;
$this->setCity();
$this->setNation();
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['OccupiedCity'],
['ReqGeneralCrew'],
['ReqGeneralGold', $reqGold],
['ReqGeneralRice', $reqRice],
['ReqGeneralAtmosMargin'],
];
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [Util::round($this->getVar('crew')/100), 0];
}
public function getPreReqTurn():int{
return 0;
}
public function getPostReqTurn():int{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
$db = DB::db();
$general = $this->generalObj;
$date = substr($general->getVar('turntime'),11,5);
$score = Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$atmosDelta);
$scoreText = number_format($score, 0);
$sideEffect = Util::valueFit(intval($general->getVar('train') * GameConst::$trainSideEffectByAtmosTurn), 0);
$logger = $general->getLogger();
$logger->pushGeneralActionLog("사기치가 <C>$scoreText</> 상승했습니다. <1>$date</>");
$exp = 100;
$ded = 70;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maAtmosByCommand);
$general->setVar('train', $sideEffect);
$general->addDex($general->getVar('crew')/100, $score, false);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
$general->increaseVar('leader2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
$this->checkStatChange();
uniqueItemEx($general->getVar('no'), $logger);
}
}
@@ -27,7 +27,7 @@ class ReqGeneralAtmosMargin extends Constraint{
return true;
}
$this->reason = "병사들은 이미 정예병사들입니다.";
$this->reason = "이미 사기는 하늘을 찌를듯 합니다.";
return false;
}
}