- 기존의 랜덤 코드는 deprecated 처리 - 서버 시작 시 랜덤하게 정해진 hiddenSeed를 활용 - 랜덤 생성 단위 - 월 실행 - 사령턴 실행 결과 - 커맨드 실행 결과 - 작위 보상 - 부대장 생성 - 유니크 획득 시도 - 설문 조사 - 장수 생성 - NPC국 생성, NPC 생성, NPC의 토너먼트 베팅 - 전투 - 도시 점령 - 자율 행동 선택 - 랜덤 턴 변경 - 거래장, 토너먼트 등 구 랜덤 코드를 이용하는 잔여 코드 있음
129 lines
3.6 KiB
PHP
129 lines
3.6 KiB
PHP
<?php
|
|
namespace sammo\Command\General;
|
|
|
|
use \sammo\{
|
|
DB, Util, JosaUtil,
|
|
General,
|
|
ActionLogger,
|
|
GameConst, GameUnitConst,
|
|
LastTurn,
|
|
Command,
|
|
Json,
|
|
KVStorage
|
|
};
|
|
|
|
|
|
use \sammo\Constraint\Constraint;
|
|
use \sammo\Constraint\ConstraintHelper;
|
|
use sammo\CityConst;
|
|
use sammo\Event\EventHandler;
|
|
|
|
use function sammo\refreshNationStaticInfo;
|
|
use function sammo\deleteNation;
|
|
use function sammo\tryRollbackInheritUniqueItem;
|
|
|
|
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(\Sammo\RandUtil $rng):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);
|
|
}
|
|
tryRollbackInheritUniqueItem($rng, $general);
|
|
$general->applyDB($db);
|
|
|
|
// 이벤트 핸들러 동작
|
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
|
$e_env = null;
|
|
foreach (DB::db()->query('SELECT * FROM event WHERE target = "DESTROY_NATION" ORDER BY `priority` DESC, `id` ASC') as $rawEvent) {
|
|
if ($e_env === null) {
|
|
$e_env = $gameStor->getAll(false);
|
|
}
|
|
$eventID = $rawEvent['id'];
|
|
$cond = Json::decode($rawEvent['condition']);
|
|
$action = Json::decode($rawEvent['action']);
|
|
$event = new EventHandler($cond, $action);
|
|
$e_env['currentEventID'] = $eventID;
|
|
|
|
$event->tryRunEvent($e_env);
|
|
}
|
|
|
|
if ($e_env !== null) {
|
|
$gameStor->resetCache();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
} |