feat(WIP): process 국가선택 추가

This commit is contained in:
2021-12-18 23:14:04 +09:00
parent e2ed918437
commit 9bd151cdc2
9 changed files with 307 additions and 110 deletions
@@ -157,23 +157,4 @@ class che_국호변경 extends Command\NationCommand
$general->applyDB($db);
return true;
}
public function getJSPlugins(): array
{
return [
'colorSelect'
];
}
public function getForm(): string
{
ob_start();
?>
나라의 이름을 바꿉니다. 황제가 된 후 1회 가능합니다.<br>
국명 : <input type='text' class='formInput' name="nationName" id="nationName" size='18' maxlength='18' style='color:white;background-color:black;'> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<?php
return ob_get_clean();
}
}
+25 -30
View File
@@ -196,48 +196,43 @@ class che_급습 extends Command\NationCommand
return true;
}
public function getJSPlugins(): array
{
return [
'defaultSelectNationByMap'
];
}
public function getForm(): string
public function exportJSVars(): array
{
$generalObj = $this->generalObj;
$nationID = $generalObj->getNationID();
$nationList = [];
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
foreach (getAllNationStaticInfo() as $destNation) {
if ($destNation['nation'] == $nationID) {
/*if ($destNation['nation'] == $nationID) {
continue;
}
}*/
$testTurn->setArg(['destNationID' => $destNation['nation']]);
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
if ($testCommand->hasFullConditionMet()) {
$destNation['availableCommand'] = true;
} else {
$destNation['availableCommand'] = false;
$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[] = $destNation;
$nationList[] = $nationTarget;
}
ob_start();
?>
<?= \sammo\getMapHtml() ?><br>
선택된 국가에 급습을 발동합니다.<br>
선포, 전쟁중인 상대국에만 가능합니다.<br>
상대 국가를 목록에서 선택하세요.<br>
배경색은 현재 급습 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<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['availableCommand'] ? '' : 'background-color:red;' ?>'>【<?= $nation['name'] ?> 】</option>
<?php endforeach; ?>
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
<?php
return ob_get_clean();
return [
'mapTheme' => \sammo\getMapTheme(),
'procRes' => [
'nations' => $nationList
],
];
}
}
-53
View File
@@ -187,57 +187,4 @@ class che_발령 extends Command\NationCommand
]
];
}
public function getJSPlugins(): array
{
return [
'defaultSelectCityByMap'
];
}
public function getForm(): string
{
$db = DB::db();
$nationID = $this->generalObj->getNationID();
$troops = Util::convertArrayToDict($db->query('SELECT * FROM troop WHERE nation=%i', $nationID), 'troop_leader');
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice,leadership,strength,intel,city,crew,train,atmos,troop FROM general WHERE nation = %i ORDER BY npc,binary(name)', $nationID);
$destGeneralList = [];
foreach ($destRawGenerals as $destGeneral) {
$nameColor = \sammo\getNameColor($destGeneral['npc']);
if ($nameColor) {
$nameColor = " style='color:{$nameColor}'";
}
$name = $destGeneral['name'];
if ($destGeneral['officer_level'] >= 5) {
$name = "*{$name}*";
}
$destGeneral['name'] = $name;
$destGeneral['color'] = $nameColor;
$destGeneralList[] = $destGeneral;
}
ob_start();
?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시로 아국 장수를 발령합니다.<br>
아국 도시로만 발령이 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
<?php foreach ($destGeneralList as $destGeneral) : ?>
<option value='<?= $destGeneral['no'] ?>' <?= $destGeneral['color'] ?>><?= $destGeneral['name'] ?>[<?= CityConst::byID($destGeneral['city'])->name ?>]
(<?= $destGeneral['leadership'] ?>/<?= $destGeneral['strength'] ?>/<?= $destGeneral['intel'] ?>)
&lt;병<?= number_format($destGeneral['crew']) ?>/훈<?= $destGeneral['train'] ?>/사<?= $destGeneral['atmos'] ?>/<?= $destGeneral['troop'] ? $troops[$destGeneral['troop']]['name'] : '-' ?>&gt;
</option>
<?php endforeach; ?>
</select>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
<?= \sammo\optionsForCities() ?><br>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<?php
return ob_get_clean();
}
}