- eslint에 prettier 조합 - prettierrc에 width 120, tabWidth 2 - gameStor->map_theme 제거 - map_theme, mapTheme를 GameConst::$mapName으로 대체 - eslint에서 vue/vue3-essential 대신 vue3-recommended 적용 - vue/max-attributes-per-line 완화 - vue/v-on-event-hyphenation 해제 - vue/attribute-hyphenation 해제 - 일부 tsc import type warning 해결 - 일부 vue template type warning 해결 - 일부 vue SFC를 script setup으로 변경 - TipTap - TopBackBar - BottomBackBar - BoardArticle - ProcessCity
202 lines
5.7 KiB
PHP
202 lines
5.7 KiB
PHP
<?php
|
|
namespace sammo\Command\Nation;
|
|
|
|
use \sammo\{
|
|
DB, Util, JosaUtil,
|
|
General, DummyGeneral,
|
|
ActionLogger,
|
|
GameConst,
|
|
LastTurn,
|
|
GameUnitConst,
|
|
Command,
|
|
MessageTarget,
|
|
DiplomaticMessage,
|
|
Message,
|
|
};
|
|
|
|
use function \sammo\getAllNationStaticInfo;
|
|
use function \sammo\getNationStaticInfo;
|
|
use function \sammo\GetImageURL;
|
|
|
|
use \sammo\Constraint\Constraint;
|
|
use \sammo\Constraint\ConstraintHelper;
|
|
|
|
class che_종전제의 extends Command\NationCommand{
|
|
static protected $actionName = '종전 제의';
|
|
static public $reqArg = true;
|
|
|
|
protected function argTest():bool{
|
|
if($this->arg === null){
|
|
return false;
|
|
}
|
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
|
if(!key_exists('destNationID', $this->arg)){
|
|
return false;
|
|
}
|
|
$destNationID = $this->arg['destNationID'];
|
|
if(!is_int($destNationID)){
|
|
return false;
|
|
}
|
|
if($destNationID < 1){
|
|
return false;
|
|
}
|
|
|
|
$this->arg = [
|
|
'destNationID'=>$destNationID,
|
|
];
|
|
return true;
|
|
}
|
|
|
|
protected function init(){
|
|
$general = $this->generalObj;
|
|
|
|
$env = $this->env;
|
|
|
|
$this->setCity();
|
|
$this->setNation();
|
|
|
|
|
|
$this->minConditionConstraints=[
|
|
ConstraintHelper::BeChief(),
|
|
ConstraintHelper::NotBeNeutral(),
|
|
ConstraintHelper::OccupiedCity(),
|
|
ConstraintHelper::SuppliedCity(),
|
|
];
|
|
}
|
|
|
|
protected function initWithArg()
|
|
{
|
|
$this->setDestNation($this->arg['destNationID'], null);
|
|
|
|
$this->fullConditionConstraints=[
|
|
ConstraintHelper::BeChief(),
|
|
ConstraintHelper::NotBeNeutral(),
|
|
ConstraintHelper::OccupiedCity(),
|
|
ConstraintHelper::SuppliedCity(),
|
|
ConstraintHelper::ExistsDestNation(),
|
|
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
|
[0, 1],
|
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
|
),
|
|
];
|
|
}
|
|
|
|
public function getCost():array{
|
|
return [0, 0];
|
|
}
|
|
|
|
public function getPreReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function getPostReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function getBrief():string{
|
|
$commandName = $this->getName();
|
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
|
return "【{$destNationName}】에게 {$commandName}";
|
|
}
|
|
|
|
|
|
public function run():bool{
|
|
if(!$this->hasFullConditionMet()){
|
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
|
}
|
|
|
|
$db = DB::db();
|
|
$env = $this->env;
|
|
|
|
$general = $this->generalObj;
|
|
$generalName = $general->getName();
|
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
|
|
$nation = $this->nation;
|
|
$nationID = $nation['nation'];
|
|
$nationName = $nation['name'];
|
|
|
|
$destNation = $this->destNation;
|
|
$destNationID = $destNation['nation'];
|
|
$destNationName = $destNation['name'];
|
|
|
|
$logger = $general->getLogger();
|
|
$destLogger = new ActionLogger(0, $destNationID, $env['year'], $env['month']);
|
|
|
|
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>으로 종전 제의 서신을 보냈습니다.<1>$date</>");
|
|
|
|
// 상대에게 발송
|
|
$src = new MessageTarget(
|
|
$general->getID(),
|
|
$general->getName(),
|
|
$nationID,
|
|
$nationName,
|
|
$nation['color'],
|
|
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
|
);
|
|
$dest = new MessageTarget(
|
|
0,
|
|
'',
|
|
$destNationID,
|
|
$destNationName,
|
|
$destNation['color']
|
|
);
|
|
|
|
$now = new \DateTime($date);
|
|
$validUntil = new \DateTime($date);
|
|
$validMinutes = max(30, $env['turnterm']*3);
|
|
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
|
|
|
$msg = new DiplomaticMessage(
|
|
Message::MSGTYPE_DIPLOMACY,
|
|
$src,
|
|
$dest,
|
|
"{$nationName}의 종전 제의 서신",
|
|
$now,
|
|
$validUntil,
|
|
[
|
|
'action'=>DiplomaticMessage::TYPE_STOP_WAR,
|
|
'deletable'=>false,
|
|
]
|
|
);
|
|
$msg->send();
|
|
|
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
$general->applyDB($db);
|
|
$destLogger->flush();
|
|
|
|
return true;
|
|
}
|
|
|
|
public function exportJSVars(): array
|
|
{
|
|
$generalObj = $this->generalObj;
|
|
$nationID = $generalObj->getNationID();
|
|
$nationList = [];
|
|
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
|
foreach (getAllNationStaticInfo() as $destNation) {
|
|
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
|
|
|
$nationTarget = [
|
|
'id' => $destNation['nation'],
|
|
'name' => $destNation['name'],
|
|
'color' => $destNation['color'],
|
|
'power' => $destNation['power'],
|
|
];
|
|
if (!$testCommand->hasFullConditionMet()) {
|
|
$nationTarget['notAvailable'] = true;
|
|
}
|
|
if ($destNation['nation'] == $nationID) {
|
|
$nationTarget['notAvailable'] = true;
|
|
}
|
|
|
|
$nationList[] = $nationTarget;
|
|
}
|
|
return [
|
|
'procRes' => [
|
|
'nationList' => $nationList,
|
|
'startYear' => $this->env['startyear'],
|
|
],
|
|
];
|
|
}
|
|
} |