불가침 외교 커맨드 부활. 버그 수정

This commit is contained in:
2020-03-12 15:58:14 +09:00
parent 59f7448aa7
commit d1bc434ced
13 changed files with 440 additions and 88 deletions
@@ -18,6 +18,8 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
GetImageURL
};
@@ -87,7 +89,13 @@ class che_불가침제의 extends Command\NationCommand{
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
$reqMonth = $year *12 + $month - 1;
$nationID = $this->nation['nation'];
if ($reqMonth < $currentMonth + 12) {
$this->reservableConstraints = [
ConstraintHelper::AlwaysFail('기한은 1년 이상이어야 합니다.')
];
$this->runnableConstraints = [
ConstraintHelper::AlwaysFail('기한은 1년 이상이어야 합니다.')
];
@@ -100,6 +108,14 @@ class che_불가침제의 extends Command\NationCommand{
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::DisallowDiplomacyBetweenStatus([
0 => '아국과 이미 교전중입니다.',
1 => '아국과 이미 선포중입니다.',
3 => '아국과 외교 진행중입니다.',
4 => '아국과 외교 진행중입니다.',
5 => '아국과 외교 진행중입니다.',
6 => '아국과 외교 진행중입니다.',
]),
];
}
@@ -116,6 +132,14 @@ class che_불가침제의 extends Command\NationCommand{
return 0;
}
public function getBrief():string{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
$year = $this->arg['year'];
$month = $this->arg['month'];
return "{$destNationName}】에게 {$year}{$month}월까지 {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
@@ -171,7 +195,7 @@ class che_불가침제의 extends Command\NationCommand{
Message::MSGTYPE_DIPLOMACY,
$src,
$dest,
"{$nationName} {$year}{$month}까지 불가침 제의 서신",
"{$nationName} {$year}{$month}까지 불가침 제의 서신",
$now,
$validUntil,
[
@@ -188,4 +212,80 @@ class che_불가침제의 extends Command\NationCommand{
return true;
}
public function getJSFiles(): array
{
return [
'js/defaultSelectNationByMap.js'
];
}
public function getForm(): string
{
$generalObj = $this->generalObj;
$nationID = $generalObj->getNationID();
$db = DB::db();
$currYear = $this->env['year'];
$diplomacyStatus = Util::convertArrayToDict(
$db->query('SELECT * FROM diplomacy WHERE me = %i', $nationID),
'you'
);
$nationList = [];
foreach(getAllNationStaticInfo() as $destNation){
if($destNation['nation'] == $nationID){
continue;
}
$testCommand = new static($generalObj, $this->env, $this->getLastTurn(), [
'destNationID'=>$destNation['nation'],
'year'=>$currYear+1,
'month'=>12
]);
if(!$testCommand->isRunnable()){
$destNation['cssBgColor'] = 'background-color:red;';
}
else if($diplomacyStatus[$destNation['nation']]['state'] == 7){
$destNation['cssBgColor'] = 'background-color:blue;';
}
else{
$destNation['cssBgColor'] = '';
}
$nationList[] = $destNation;
}
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
타국에게 불가침을 제의합니다.<br>
제의할 국가를 목록에서 선택하세요.<br>
불가침 기한 다음 달부터 선포 가능합니다.<br>
배경색은 현재 제의가 불가능한 국가는 <font color=red>붉은색</font>, 현재 불가침중인 국가는 <font color=blue>푸른색</font>으로 표시됩니다.<br>
<br>
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
<?php foreach($nationList as $nation): ?>
<option
value='<?=$nation['nation']?>'
style='color:<?=$nation['color']?>;<?=$nation['cssBgColor']?>'
>【<?=$nation['name']?> 】</option>
<?php endforeach; ?>
</select>에게
<select class='formInput' name="year" id="year" size='1' style='color:white;background-color:black;'>
<?php foreach(range($currYear+1, $currYear+20) as $formYear): ?>
<option value='<?=$formYear?>'><?=$formYear?></option>
<?php endforeach; ?>
</select>년
<select class='formInput' name="month" id="month" size='1' style='color:white;background-color:black;'>
<?php foreach(range(1, 12) as $formMonth): ?>
<option value='<?=$formMonth?>'><?=$formMonth?></option>
<?php endforeach; ?>
</select>월까지
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
<?php
return ob_get_clean();
}
}