방랑시 버그 수정

This commit is contained in:
2020-07-20 23:24:15 +09:00
parent 923cac5408
commit 325f890a0b
+134 -134
View File
@@ -1,135 +1,135 @@
<?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;
use sammo\CityConst; use sammo\CityConst;
use function sammo\DeleteConflict; use function sammo\DeleteConflict;
use function sammo\refreshNationStaticInfo; use function sammo\refreshNationStaticInfo;
class che_방랑 extends Command\GeneralCommand{ class che_방랑 extends Command\GeneralCommand{
static protected $actionName = '방랑'; static protected $actionName = '방랑';
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;
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation();
$relYear = $env['year'] - $env['startyear']; $relYear = $env['year'] - $env['startyear'];
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::BeLord(), ConstraintHelper::BeLord(),
ConstraintHelper::NotWanderingNation(), ConstraintHelper::NotWanderingNation(),
ConstraintHelper::NotOpeningPart($relYear), ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [ ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
2, 7 2, 7
], '방랑할 수 없는 외교상태입니다.'), ], '방랑할 수 없는 외교상태입니다.'),
]; ];
} }
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
public function getPostReqTurn():int{ public function getPostReqTurn():int{
return 0; return 0;
} }
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();
$env = $this->env; $env = $this->env;
$general = $this->generalObj; $general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM); $date = $general->getTurnTime($general::TURNTIME_HM);
$generalName = $general->getName(); $generalName = $general->getName();
$josaYi = JosaUtil::pick($generalName, '이'); $josaYi = JosaUtil::pick($generalName, '이');
$josaUn = JosaUtil::pick($generalName, '은'); $josaUn = JosaUtil::pick($generalName, '은');
$nationID = $general->getNationID(); $nationID = $general->getNationID();
$nationName = $this->nation['name']; $nationName = $this->nation['name'];
$josaUl = JosaUtil::pick($nationName, '을'); $josaUl = JosaUtil::pick($nationName, '을');
$logger = $general->getLogger(); $logger = $general->getLogger();
$logger->pushGeneralActionLog("영토를 버리고 방랑의 길을 떠납니다. <1>$date</>"); $logger->pushGeneralActionLog("영토를 버리고 방랑의 길을 떠납니다. <1>$date</>");
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 방랑의 길을 떠납니다."); $logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 방랑의 길을 떠납니다.");
$logger->pushGlobalHistoryLog("<R><b>【방랑】</b></><D><b>{$generalName}</b></>{$josaUn} <R>방랑</>의 길을 떠납니다."); $logger->pushGlobalHistoryLog("<R><b>【방랑】</b></><D><b>{$generalName}</b></>{$josaUn} <R>방랑</>의 길을 떠납니다.");
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 버리고 방랑"); $logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 버리고 방랑");
//분쟁기록 모두 지움 //분쟁기록 모두 지움
DeleteConflict($nationID); DeleteConflict($nationID);
// 국명, 색깔 바꿈 국가 레벨 0, 성향리셋, 기술0 // 국명, 색깔 바꿈 국가 레벨 0, 성향리셋, 기술0
$db->update('nation', [ $db->update('nation', [
'name'=>$generalName, 'name'=>$generalName,
'color'=>'#330000', //TODO: 기본 방랑군색 별도 지정 'color'=>'#330000', //TODO: 기본 방랑군색 별도 지정
'level'=>0, 'level'=>0,
'type'=>0, 'type'=>'None',
'tech'=>0, 'tech'=>0,
'capital'=>0 'capital'=>0
], 'nation=%i', $nationID); ], 'nation=%i', $nationID);
$db->update('general', [ $db->update('general', [
'makelimit'=>12 'makelimit'=>12
], 'nation=%i', $nationID); ], 'nation=%i', $nationID);
$general->setVar('makelimit', 12); $general->setVar('makelimit', 12);
$general->setVar('officer_city', 0); $general->setVar('officer_city', 0);
$db->update('general', [ $db->update('general', [
'officer_level'=>1, 'officer_level'=>1,
'officer_city'=>0, 'officer_city'=>0,
], 'nation=%i AND officer_level < 12', $nationID); ], 'nation=%i AND officer_level < 12', $nationID);
$db->update('city', [ $db->update('city', [
'nation'=>0, 'nation'=>0,
'front'=>0, 'front'=>0,
'conflict'=>'{}' 'conflict'=>'{}'
], 'nation=%i', $nationID); ], 'nation=%i', $nationID);
$db->update('diplomacy', [ $db->update('diplomacy', [
'state'=>2, 'state'=>2,
'term'=>0, 'term'=>0,
], 'me=%i OR you=%i', $nationID, $nationID); ], 'me=%i OR you=%i', $nationID, $nationID);
refreshNationStaticInfo(); refreshNationStaticInfo();
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }