setCity(); $this->setNation(['gold','rice','aux']); $this->fullConditionConstraints=[]; $name = static::$actionName; [$reqGold, $reqRice] = $this->getCost(); $this->minConditionConstraints = [ ConstraintHelper::OccupiedCity(), ConstraintHelper::BeChief(), ConstraintHelper::ReqNationAuxValue(static::$auxType->value, 0, "<", 1, "{$name}가 이미 완료되었습니다."), ConstraintHelper::ReqNationGold(GameConst::$basegold + $reqGold), ConstraintHelper::ReqNationRice(GameConst::$baserice + $reqRice), ]; $this->fullConditionConstraints = $this->minConditionConstraints; } public function getCommandDetailTitle():string{ $name = $this->getName(); [$reqGold, $reqRice] = $this->getCost(); $reqTurn = $this->getPreReqTurn()+1; $reqGoldD5 = number_format($reqGold / 10000); $reqRiceD5 = number_format($reqRice / 10000); return "{$name}/{$reqTurn}턴(금/쌀 {$reqGoldD5}만)"; } public function getPreReqTurn():int{ return 23; } public function getPostReqTurn():int{ return 0; } public function getCost():array{ return [100000, 100000]; } public function run(\Sammo\RandUtil $rng):bool{ if(!$this->hasFullConditionMet()){ throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); } $db = DB::db(); $general = $this->generalObj; $nationID = $general->getNationID(); $actionName = static::$actionName; $aux = $this->nation['aux']; $aux[static::$auxType->value] = 1; [$reqGold, $reqRice] = $this->getCost(); $logger = $general->getLogger(); $general->addExperience(5 * ($this->getPreReqTurn() + 1)); $general->addDedication(5 * ($this->getPreReqTurn() + 1)); $generalName = $general->getName(); $josaYi = JosaUtil::pick($generalName, '이'); $db->update('nation', [ 'gold' => $db->sqleval('gold - %i', $reqGold), 'rice' => $db->sqleval('rice - %i', $reqRice), 'aux' => Json::encode($aux), ], 'nation=%i', $nationID); $logger->pushGeneralActionLog("{$actionName} 완료"); $logger->pushGeneralHistoryLog("{$actionName} 완료"); $logger->pushNationalHistoryLog("{$generalName}{$josaYi} {$actionName} 완료"); $general->increaseInheritancePoint(InheritanceKey::active_action, 1); StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg ?? []); $this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0)); $general->applyDB($db); return true; } }