forked from devsam/core
- null && key_exists 버그 - or assign이 integer 대상이므로 직접 연산 - false 대신 0 입력한 곳 수정 - 자체 Deprecate 처리한 함수 회피 - 초기화되지 않은 [] 확인하여 처리 - sleep은 정수만 받으므로 usleep으로 변경 - 선언하지 않고 그냥 사용하던 member 변수 선언 - boolean operation 순서 틀린 부분 수정
106 lines
2.7 KiB
PHP
106 lines
2.7 KiB
PHP
<?php
|
|
namespace sammo\Command\General;
|
|
|
|
use \sammo\{
|
|
DB, Util, JosaUtil,
|
|
General,
|
|
ActionLogger,
|
|
GameConst, GameUnitConst,
|
|
LastTurn,
|
|
Command
|
|
};
|
|
|
|
|
|
use \sammo\Constraint\Constraint;
|
|
use \sammo\Constraint\ConstraintHelper;
|
|
use sammo\CityConst;
|
|
use function sammo\refreshNationStaticInfo;
|
|
use function sammo\deleteNation;
|
|
|
|
|
|
|
|
class che_해산 extends Command\GeneralCommand{
|
|
static protected $actionName = '해산';
|
|
|
|
protected function argTest():bool{
|
|
$this->arg = [];
|
|
|
|
return true;
|
|
}
|
|
|
|
protected function init(){
|
|
|
|
$general = $this->generalObj;
|
|
$env = $this->env;
|
|
|
|
$this->setCity();
|
|
$this->setNation(['gennum']);
|
|
|
|
$this->fullConditionConstraints=[
|
|
ConstraintHelper::BeLord(),
|
|
ConstraintHelper::WanderingNation(),
|
|
];
|
|
}
|
|
|
|
public function getCost():array{
|
|
return [0, 0];
|
|
}
|
|
|
|
public function getPreReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function getPostReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function run():bool{
|
|
if(!$this->hasFullConditionMet()){
|
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
|
}
|
|
|
|
$db = DB::db();
|
|
$env = $this->env;
|
|
|
|
$general = $this->generalObj;
|
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
|
|
$generalName = $general->getName();
|
|
$josaYi = JosaUtil::pick($generalName, '이');
|
|
|
|
$nation = $this->nation;
|
|
$nationID = $nation['nation'];
|
|
$nationName = $nation['name'];
|
|
$josaUl = JosaUtil::pick($nationName, '을');
|
|
|
|
$db->update('general', [
|
|
'gold'=>GameConst::$defaultGold
|
|
], 'nation=%i AND gold>%i', $nationID, GameConst::$defaultGold);
|
|
$db->update('general', [
|
|
'rice'=>GameConst::$defaultRice
|
|
], 'nation=%i AND gold>%i', $nationID, GameConst::$defaultRice);
|
|
|
|
$general->increaseVarWithLimit('gold', 0, 0, GameConst::$defaultGold);
|
|
$general->increaseVarWithLimit('rice', 0, 0, GameConst::$defaultRice);
|
|
|
|
refreshNationStaticInfo();
|
|
|
|
$logger = $general->getLogger();
|
|
$logger->pushGeneralActionLog("세력을 해산했습니다. <1>$date</>");
|
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 세력을 해산했습니다.");
|
|
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 해산");
|
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
|
|
$nationGenerals = deleteNation($general, false);
|
|
foreach($nationGenerals as $oldGeneral){
|
|
$oldGeneral->setVar('makelimit', 12);
|
|
$oldGeneral->applyDB($db);
|
|
}
|
|
|
|
$general->applyDB($db);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
} |