feat(WIP): 증여,헌납,백성동원,수몰,천도,초토화,허보

This commit is contained in:
2021-12-22 02:23:06 +09:00
parent 507fa102b9
commit b0c7d60d5a
13 changed files with 253 additions and 201 deletions
+15 -33
View File
@@ -177,40 +177,22 @@ class che_증여 extends Command\GeneralCommand
return true;
}
public function getForm(): string
public function exportJSVars(): array
{
//TODO: 암행부처럼 보여야...
$db = DB::db();
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)', $this->generalObj->getNationID(), $this->generalObj->getID());
ob_start();
?>
자신의 자금이나 군량을 다른 장수에게 증여합니다.<br>
장수를 선택하세요.<br>
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
<?php foreach ($destRawGenerals as $destGeneral) :
$color = \sammo\getNameColor($destGeneral['npc']);
if ($color) {
$color = " style='color:{$color}'";
}
$name = $destGeneral['name'];
if ($destGeneral['officer_level'] >= 5) {
$name = "*{$name}*";
}
?>
<option value='<?= $destGeneral['no'] ?>' <?= $color ?>><?= $name ?>(금:<?= $destGeneral['gold'] ?>, 쌀:<?= $destGeneral['rice'] ?>)</option>
<?php endforeach; ?>
</select>
<select class='formInput' name="isGold" id="isGold" size='1' style='color:white;background-color:black;'>
<option value="true">금</option>
<option value="false">쌀</option>
</select>
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
<?php foreach (GameConst::$resourceActionAmountGuide as $amount) : ?>
<option value='<?= $amount ?>'><?= $amount ?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<?php
return ob_get_clean();
$nationID = $this->getNationID();
$troops = Util::convertArrayToDict($db->query('SELECT * FROM troop WHERE nation=%i', $nationID), 'troop_leader');
$destRawGenerals = $db->queryAllLists('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);
return [
'procRes' => [
'troops' => $troops,
'generals' => $destRawGenerals,
'generalsKey' => ['no', 'name', 'officerLevel', 'npc', 'gold', 'rice', 'leadership', 'strength', 'intel', 'cityID', 'crew', 'train', 'atmos', 'troopID'],
'cities' => \sammo\JSOptionsForCities(),
'minAmount' => 100,
'maxAmount' => GameConst::$maxResourceActionAmount,
'amountGuide' => GameConst::$resourceActionAmountGuide,
]
];
}
}
+11
View File
@@ -152,6 +152,17 @@ class che_헌납 extends Command\GeneralCommand
return true;
}
public function exportJSVars(): array
{
return [
'procRes' => [
'minAmount' => 100,
'maxAmount' => GameConst::$maxResourceActionAmount,
'amountGuide' => GameConst::$resourceActionAmountGuide,
]
];
}
public function getForm(): string
{
ob_start();
+41 -41
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -18,30 +22,33 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Event\Action;
class che_백성동원 extends Command\NationCommand{
class che_백성동원 extends Command\NationCommand
{
static protected $actionName = '백성동원';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(CityConst::byID($this->arg['destCityID']) === null){
if (CityConst::byID($this->arg['destCityID']) === null) {
return false;
}
$destCityID = $this->arg['destCityID'];
$this->arg = [
'destCityID'=>$destCityID,
'destCityID' => $destCityID,
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -49,7 +56,7 @@ class che_백성동원 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->minConditionConstraints=[
$this->minConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand()
@@ -61,7 +68,7 @@ class che_백성동원 extends Command\NationCommand{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation']);
$this->fullConditionConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::OccupiedDestCity(),
@@ -69,38 +76,44 @@ class che_백성동원 extends Command\NationCommand{
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
$reqTurn = $this->getPreReqTurn()+1;
$reqTurn = $this->getPreReqTurn() + 1;
$postReqTurn = $this->getPostReqTurn();
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
$nextTerm = Util::round(sqrt($genCount*4)*10);
$nextTerm = Util::round(sqrt($genCount * 4) * 10);
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
return $nextTerm;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
return "{$destCityName}】에 {$commandName}";
}
public function run():bool{
if(!$this->hasFullConditionMet()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -132,7 +145,7 @@ class che_백성동원 extends Command\NationCommand{
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.";
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
foreach($targetGeneralList as $targetGeneralID){
foreach ($targetGeneralList as $targetGeneralID) {
$targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month);
$targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
$targetLogger->flush();
@@ -159,27 +172,14 @@ class che_백성동원 extends Command\NationCommand{
return true;
}
public function getJSPlugins(): array
public function exportJSVars(): array
{
return [
'defaultSelectCityByMap'
'mapTheme' => \sammo\getMapTheme(),
'procRes' => [
'cities' => \sammo\JSOptionsForCities(),
'distanceList' => new \stdClass(),
],
];
}
public function getForm(): string
{
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시에 백성을 동원해 성벽을 쌓습니다.<br>
아국 도시만 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<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();
}
}
}
+45 -44
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -20,30 +24,33 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Event\Action;
class che_수몰 extends Command\NationCommand{
class che_수몰 extends Command\NationCommand
{
static protected $actionName = '수몰';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(CityConst::byID($this->arg['destCityID']) === null){
if (CityConst::byID($this->arg['destCityID']) === null) {
return false;
}
$destCityID = $this->arg['destCityID'];
$this->arg = [
'destCityID'=>$destCityID,
'destCityID' => $destCityID,
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -51,7 +58,7 @@ class che_수몰 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->minConditionConstraints=[
$this->minConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand(),
@@ -63,7 +70,7 @@ class che_수몰 extends Command\NationCommand{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation']);
$this->fullConditionConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::NotNeutralDestCity(),
@@ -73,39 +80,45 @@ class che_수몰 extends Command\NationCommand{
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
$reqTurn = $this->getPreReqTurn()+1;
$reqTurn = $this->getPreReqTurn() + 1;
$postReqTurn = $this->getPostReqTurn();
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 2;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
$nextTerm = Util::round(sqrt($genCount*4)*10);
$nextTerm = Util::round(sqrt($genCount * 4) * 10);
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
return $nextTerm;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
$josaUl = JosaUtil::pick($destCityName, '을');
return "{$destCityName}{$josaUl} {$commandName}";
}
public function run():bool{
if(!$this->hasFullConditionMet()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -140,7 +153,7 @@ class che_수몰 extends Command\NationCommand{
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동하였습니다.";
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
foreach($targetGeneralList as $targetGeneralID){
foreach ($targetGeneralList as $targetGeneralID) {
$targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month);
$targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
$targetLogger->flush();
@@ -150,12 +163,13 @@ class che_수몰 extends Command\NationCommand{
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i', $destNationID);
$destNationLogged = false;
foreach($targetGeneralList as $targetGeneralID){
foreach ($targetGeneralList as $targetGeneralID) {
$targetLogger = new ActionLogger($targetGeneralID, $destNationID, $year, $month);
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
if(!$destNationLogged){
if (!$destNationLogged) {
$targetLogger->pushNationalHistoryLog(
"<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국의 <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동", ActionLogger::PLAIN
"<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국의 <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동",
ActionLogger::PLAIN
);
$destNationLogged = true;
}
@@ -182,27 +196,14 @@ class che_수몰 extends Command\NationCommand{
return true;
}
public function getJSPlugins(): array
public function exportJSVars(): array
{
return [
'defaultSelectCityByMap'
'mapTheme' => \sammo\getMapTheme(),
'procRes' => [
'cities' => \sammo\JSOptionsForCities(),
'distanceList' => new \stdClass(),
],
];
}
public function getForm(): string
{
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시에 수몰을 발동합니다.<br>
전쟁중인 상대국 도시만 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<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();
}
}
}
+6 -19
View File
@@ -230,27 +230,14 @@ class che_천도 extends Command\NationCommand
return true;
}
public function getJSPlugins(): array
public function exportJSVars(): array
{
return [
'defaultSelectCityByMap'
'mapTheme' => \sammo\getMapTheme(),
'procRes' => [
'cities' => \sammo\JSOptionsForCities(),
'distanceList' => new \stdClass(),
],
];
}
public function getForm(): string
{
ob_start();
?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시로 천도합니다.<br>
현재 수도에서 연결된 도시만 가능하며, 1+2×거리만큼의 턴이 필요합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<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();
}
}
+6 -30
View File
@@ -196,38 +196,14 @@ class che_초토화 extends Command\NationCommand{
return true;
}
public function getJSPlugins(): array
public function exportJSVars(): array
{
return [
'defaultSelectCityByMap'
'mapTheme' => \sammo\getMapTheme(),
'procRes' => [
'cities' => \sammo\JSOptionsForCities(),
'distanceList' => new \stdClass(),
],
];
}
public function getForm(): string
{
$cities = Util::convertArrayToDict(DB::db()->query('SELECT * FROM city WHERE nation =%i', $this->generalObj->getNationID()), 'city');
$calc = function(CityInitialDetail $constCity)use($cities){
if(!key_exists($constCity->id, $cities)){
return null;
}
$amount = $this->calcReturnAmount($cities[$constCity->id]);
$amountText = number_format($amount);
return "금쌀 각 {$amountText} 회수";
};
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시를 초토화 시킵니다.<br>
도시가 공백지가 되며, 도시의 인구, 내정 상태에 따라 상당량의 국고가 확보됩니다.<br>
국가의 수뇌들은 명성을 잃고, 모든 장수들은 배신 수치가 1 증가합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
<?=\sammo\optionsForCities($calc)?><br>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<br>
<?php
return ob_get_clean();
}
}
+6 -19
View File
@@ -199,27 +199,14 @@ class che_허보 extends Command\NationCommand
return true;
}
public function getJSPlugins(): array
public function exportJSVars(): array
{
return [
'defaultSelectCityByMap'
'mapTheme' => \sammo\getMapTheme(),
'procRes' => [
'cities' => \sammo\JSOptionsForCities(),
'distanceList' => new \stdClass(),
],
];
}
public function getForm(): string
{
ob_start();
?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시에 허보를 발동합니다.<br>
전쟁중인 상대국 도시만 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<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();
}
}