전특 초기화에서 '쿨'을 감안함

This commit is contained in:
2020-06-25 23:45:09 +09:00
parent 22f856668f
commit cd9a4887fd
@@ -1,130 +1,130 @@
<?php <?php
namespace sammo\Command\General; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
ActionLogger, ActionLogger,
GameConst, GameUnitConst, GameConst, GameUnitConst,
LastTurn, LastTurn,
Command Command
}; };
use function \sammo\{ use function \sammo\{
tryUniqueItemLottery tryUniqueItemLottery
}; };
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
class che_전투특기초기화 extends Command\GeneralCommand{ class che_전투특기초기화 extends Command\GeneralCommand{
static protected $actionName = '전투 특기 초기화'; static protected $actionName = '전투 특기 초기화';
static protected $specialType = 'special2'; static protected $specialType = 'special2';
static protected $speicalAge = 'specage2'; static protected $speicalAge = 'specage2';
static protected $specialText = '전투 특기'; static protected $specialText = '전투 특기';
protected function argTest():bool{ protected function argTest():bool{
$this->arg = null; $this->arg = null;
return true; return true;
} }
protected function init(){ protected function init(){
$general = $this->generalObj; $general = $this->generalObj;
$env = $this->env; $env = $this->env;
$yearMonth = Util::joinYearMonth($env['year'], $env['month']); $yearMonth = Util::joinYearMonth($env['year'], $env['month']);
$auxYearMonth = $general->getAuxVar('used_'.$this->getName())??-999; $auxYearMonth = $general->getAuxVar('used_'.$this->getName())??-999;
if($yearMonth < $auxYearMonth + 60){ if($yearMonth < $auxYearMonth + 60 - $this->getPreReqTurn()){
$this->minConditionConstraints=[ $this->minConditionConstraints=[
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다') ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
]; ];
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다') ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
]; ];
return; return;
} }
$this->minConditionConstraints=[ $this->minConditionConstraints=[
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'), ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
]; ];
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.') ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
]; ];
} }
public function getCommandDetailTitle():string{ public function getCommandDetailTitle():string{
$name = $this->getName(); $name = $this->getName();
if($this->getPreReqTurn()){ if($this->getPreReqTurn()){
$reqTurn = ($this->getPreReqTurn()+1).'턴, '; $reqTurn = ($this->getPreReqTurn()+1).'턴, ';
} }
else{ else{
$reqTurn = 0; $reqTurn = 0;
} }
$title = "{$name}({$reqTurn}5년마다 1회)"; $title = "{$name}({$reqTurn}5년마다 1회)";
return $title; return $title;
} }
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 1; return 1;
} }
public function getPostReqTurn():int{ public function getPostReqTurn():int{
return 0; return 0;
} }
public function getTermString():string{ public function getTermString():string{
$term = $this->getResultTurn()->getTerm(); $term = $this->getResultTurn()->getTerm();
$termMax = $this->getPreReqTurn() + 1; $termMax = $this->getPreReqTurn() + 1;
return "새로운 적성을 찾는 중... ({$term}/{$termMax})"; return "새로운 적성을 찾는 중... ({$term}/{$termMax})";
} }
public function run():bool{ public function run():bool{
if(!$this->hasFullConditionMet()){ if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
} }
$db = DB::db(); $db = DB::db();
$general = $this->generalObj; $general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM); $date = $general->getTurnTime($general::TURNTIME_HM);
$oldTypeKey = 'prev_types_'.static::$specialType; $oldTypeKey = 'prev_types_'.static::$specialType;
$specialName = static::$specialText; $specialName = static::$specialText;
$env = $this->env; $env = $this->env;
$yearMonth = Util::joinYearMonth($env['year'], $env['month']); $yearMonth = Util::joinYearMonth($env['year'], $env['month']);
$oldSpecialList = $general->getAuxVar($oldTypeKey)??[]; $oldSpecialList = $general->getAuxVar($oldTypeKey)??[];
$oldSpecialList[] = $general->getVar(static::$specialType); $oldSpecialList[] = $general->getVar(static::$specialType);
$general->setAuxVar($oldTypeKey, $oldSpecialList); $general->setAuxVar($oldTypeKey, $oldSpecialList);
$general->setVar(static::$specialType, 'None'); $general->setVar(static::$specialType, 'None');
$general->setVar(static::$speicalAge, $general->getVar('age') + 1); $general->setVar(static::$speicalAge, $general->getVar('age') + 1);
$general->setAuxVar('used_'.$this->getName(), $yearMonth); $general->setAuxVar('used_'.$this->getName(), $yearMonth);
$logger = $general->getLogger(); $logger = $general->getLogger();
$logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>"); $logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
tryUniqueItemLottery($general); tryUniqueItemLottery($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }