커맨드 유효성을 2개에서 3개구성으로 변경

This commit is contained in:
2020-05-04 19:51:11 +09:00
parent dbba6fa942
commit 76ac6cf5b5
100 changed files with 4124 additions and 3420 deletions
+5 -6
View File
@@ -29,7 +29,6 @@ use sammo\Event\Action;
class che_감축 extends Command\NationCommand{
static protected $actionName = '감축';
static public $reqArg = false;
protected function argTest():bool{
$this->arg = [];
@@ -43,10 +42,10 @@ class che_감축 extends Command\NationCommand{
$env = $this->env;
if($general->getNationID()===0){
$this->reservableConstraints=[
$this->permissionConstraints=[
ConstraintHelper::NotBeNeutral(),
];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
];
return;
@@ -54,13 +53,13 @@ class che_감축 extends Command\NationCommand{
$this->setCity();
$this->setNation(['gold', 'rice', 'capset', 'capital']);
$this->setDestCity($this->nation['capital'], null);
$this->setDestCity($this->nation['capital']);
[$reqGold, $reqRice] = $this->getCost();
$origCityLevel = CityConst::byID($this->nation['capital'])->level;
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
@@ -136,7 +135,7 @@ class che_감축 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+76 -55
View File
@@ -1,20 +1,25 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
GameUnitConst,
Command,
Message, MessageTarget
Message,
MessageTarget
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -24,34 +29,37 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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;
}
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID
'destNationID' => $destNationID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -59,54 +67,71 @@ class che_급습 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->minConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand(),
];
}
protected function initWithArg()
{
$this->setDestNation($this->arg['destNationID'], null);
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::AllowDiplomacyWithTerm(
1, 12,
1,
12,
'선포 12개월 이상인 상대국에만 가능합니다.'
),
ConstraintHelper::AvailableStrategicCommand(),
];
}
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*16)*10);
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
return $nextTerm;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
return "{$destNationName}】에 {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -144,7 +169,7 @@ class che_급습 extends Command\NationCommand{
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
foreach($nationGeneralList as $nationGeneralID){
foreach ($nationGeneralList as $nationGeneralID) {
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
$nationGeneralLogger->flush();
@@ -155,7 +180,7 @@ class che_급습 extends Command\NationCommand{
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
foreach($destNationGeneralList as $destNationGeneralID){
foreach ($destNationGeneralList as $destNationGeneralID) {
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
$destNationGeneralLogger->flush();
@@ -166,12 +191,12 @@ class che_급습 extends Command\NationCommand{
$destNationLogger->flush();
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
$db->update('nation', [
'strategic_cmd_limit' => $this->getPostReqTurn()
], 'nation=%i', $nationID);
$db->update('diplomacy', [
'term'=>$db->sqleval('`term` - %i', 3),
'term' => $db->sqleval('`term` - %i', 3),
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
$general->applyDB($db);
@@ -192,39 +217,35 @@ class che_급습 extends Command\NationCommand{
$nationID = $generalObj->getNationID();
$nationList = [];
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
foreach(getAllNationStaticInfo() as $destNation){
if($destNation['nation'] == $nationID){
foreach (getAllNationStaticInfo() as $destNation) {
if ($destNation['nation'] == $nationID) {
continue;
}
$testTurn->setArg(['destNationID'=>$destNation['nation']]);
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]);
if($testCommand->isRunnable()){
$testTurn->setArg(['destNationID' => $destNation['nation']]);
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
if ($testCommand->hasFullConditionMet()) {
$destNation['availableCommand'] = true;
}
else{
} else {
$destNation['availableCommand'] = false;
}
$nationList[] = $destNation;
}
ob_start();
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
<?= \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();
}
}
}
+96 -70
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -13,9 +17,9 @@ use \sammo\{
Message
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
GetImageURL
};
@@ -23,56 +27,59 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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;
}
//NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('isGold', $this->arg)){
if (!key_exists('isGold', $this->arg)) {
return false;
}
if(!key_exists('amount', $this->arg)){
if (!key_exists('amount', $this->arg)) {
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_numeric($amount)){
if (!is_numeric($amount)) {
return false;
}
$amount = Util::round($amount, -2);
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
if($amount <= 0){
if ($amount <= 0) {
return false;
}
if(!is_bool($isGold)){
if (!is_bool($isGold)) {
return false;
}
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount,
'destGeneralID'=>$destGeneralID
'isGold' => $isGold,
'amount' => $amount,
'destGeneralID' => $destGeneralID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -80,13 +87,27 @@ class che_몰수 extends Command\NationCommand{
$this->setCity();
$this->setNation(['gold', 'rice']);
$relYear = $env['year'] - $env['startyear'];
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], 1);
$this->setDestGeneral($destGeneral);
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(),
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::NotOpeningPart($relYear),
@@ -95,32 +116,37 @@ class che_몰수 extends Command\NationCommand{
ConstraintHelper::FriendlyDestGeneral()
];
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$amountText = number_format($amount, 0);
$resName = $isGold?'금':'쌀';
$resName = $isGold ? '금' : '쌀';
$destGeneral = $this->destGeneralObj;
$commandName = $this->getName();
return "{$destGeneral->getName()}{$resName} $amountText {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -134,10 +160,10 @@ class che_몰수 extends Command\NationCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$resKey = $isGold?'gold':'rice';
$resName = $isGold?'금':'쌀';
$resKey = $isGold ? 'gold' : 'rice';
$resName = $isGold ? '금' : '쌀';
$destGeneral = $this->destGeneralObj;
$amount = Util::valueFit(
$amount,
0,
@@ -145,17 +171,17 @@ class che_몰수 extends Command\NationCommand{
);
$amountText = number_format($amount, 0);
if($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)){
if ($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)) {
$npcTexts = [
'몰수를 하다니... 이것이 윗사람이 할 짓이란 말입니까...',
'사유재산까지 몰수해가면서 이 나라가 잘 될거라 믿습니까? 정말 이해할 수가 없군요...',
'내 돈 내놔라! 내 돈! 몰수가 왠 말이냐!',
'몰수해간 내 자금... 언젠가 몰래 다시 빼내올 것이다...',
'몰수로 인한 사기 저하는 몰수로 얻은 물자보다 더 손해란걸 모른단 말인가!'
'몰수로 인한 사기 저하는 몰수로 얻은 물자보다 더 손해란걸 모른단 말인가!'
];
$text = Util::choiceRandom($npcTexts);
$src = new MessageTarget(
$destGeneral->getID(),
$destGeneral->getID(),
$destGeneral->getName(),
$nationID,
$nation['name'],
@@ -163,7 +189,7 @@ class che_몰수 extends Command\NationCommand{
GetImageURL($destGeneral->getVar('imgsvr'), $destGeneral->getVar('picture'))
);
$msg = new Message(
Message::MSGTYPE_PUBLIC,
Message::MSGTYPE_PUBLIC,
$src,
$src,
$text,
@@ -173,12 +199,12 @@ class che_몰수 extends Command\NationCommand{
);
$msg->send();
}
$logger = $general->getLogger();
$destGeneral->increaseVarWithLimit($resKey, -$amount, 0);
$db->update('nation', [
$resKey=>$db->sqleval('%b + %i', $resKey, $amount)
$resKey => $db->sqleval('%b + %i', $resKey, $amount)
], 'nation=%i', $nationID);
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}을 몰수 당했습니다.", ActionLogger::PLAIN);
@@ -196,48 +222,48 @@ class che_몰수 extends Command\NationCommand{
//TODO: 암행부처럼 보여야...
$db = DB::db();
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID());
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation = %i AND no != %i ORDER BY npc,binary(name)', $this->generalObj->getNationID(), $this->generalObj->getID());
$destGeneralList = [];
foreach($destRawGenerals as $destGeneral){
foreach ($destRawGenerals as $destGeneral) {
$nameColor = \sammo\getNameColor($destGeneral['npc']);
if($nameColor){
if ($nameColor) {
$nameColor = " style='color:{$nameColor}'";
}
$name = $destGeneral['name'];
if($destGeneral['officer_level'] >= 5){
if ($destGeneral['officer_level'] >= 5) {
$name = "*{$name}*";
}
$destGeneralList[] = [
'no'=>$destGeneral['no'],
'color'=>$nameColor,
'name'=>$name,
'gold'=>$destGeneral['gold'],
'rice'=>$destGeneral['rice']
'no' => $destGeneral['no'],
'color' => $nameColor,
'name' => $name,
'gold' => $destGeneral['gold'],
'rice' => $destGeneral['rice']
];
}
ob_start();
?>
장수의 자금이나 군량을 몰수합니다.<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']?>(금:<?=$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>
<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>
<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'] ?>(금:<?= $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>
<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>
<br>
<?php
return ob_get_clean();
}
}
}
+14 -4
View File
@@ -80,6 +80,16 @@ class che_물자원조 extends Command\NationCommand{
$this->setCity();
$this->setNation(['gold', 'rice', 'surlimit']);
$this->minConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
];
}
protected function initWithArg()
{
$destNationID = $this->arg['destNationID'];
$this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']);
@@ -87,13 +97,13 @@ class che_물자원조 extends Command\NationCommand{
$limit = $this->nation['level'] * GameConst::$coefAidAmount;
if($goldAmount > $limit || $riceAmount > $limit){
$this->runnableConstraints[
$this->fullConditionConstraints[
ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.')
];
return;
}
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
@@ -128,7 +138,7 @@ class che_물자원조 extends Command\NationCommand{
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+15 -5
View File
@@ -59,13 +59,23 @@ class che_발령 extends Command\NationCommand{
$this->setCity();
$this->setNation();
$this->minConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
}
$this->setDestCity($this->arg['destCityID'], null);
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, 1);
$this->setDestGeneral($destGeneral);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
@@ -79,7 +89,7 @@ class che_발령 extends Command\NationCommand{
public function getFailString():string{
$commandName = $this->getName();
$failReason = $this->testRunnable();
$failReason = $this->testFullConditionMet();
if($failReason === null){
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
}
@@ -109,7 +119,7 @@ class che_발령 extends Command\NationCommand{
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+14 -4
View File
@@ -56,10 +56,20 @@ class che_백성동원 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->setDestCity($this->arg['destCityID'], null);
$this->setDestNation($this->destCity['nation']);
$this->runnableConstraints=[
$this->minConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand()
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation']);
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
@@ -101,7 +111,7 @@ class che_백성동원 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -14,9 +18,9 @@ use \sammo\{
Message,
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -26,75 +30,85 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
if(!key_exists('year', $this->arg) || !key_exists('month', $this->arg) ){
if (!key_exists('year', $this->arg) || !key_exists('month', $this->arg)) {
return false;
}
$year = $this->arg['year'];
$month = $this->arg['month'];
if(!is_int($year) || !is_int($month)){
if (!is_int($year) || !is_int($month)) {
return false;
}
if($month < 1 || 12 < $month){
if ($month < 1 || 12 < $month) {
return false;
}
if($year < $this->env['startyear']){
if ($year < $this->env['startyear']) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID,
'destGeneralID'=>$destGeneralID,
'year'=>$year,
'month'=>$month,
'destNationID' => $destNationID,
'destGeneralID' => $destGeneralID,
'year' => $year,
'month' => $month,
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$this->setCity();
$this->setNation();
$this->permissionConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
}
protected function initWithArg()
{
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
$this->setDestGeneral($destGeneral);
$this->setDestNation($this->arg['destNationID']);
@@ -104,24 +118,20 @@ class che_불가침수락 extends Command\NationCommand{
$month = $this->arg['month'];
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
$reqMonth = $year *12 + $month - 1;
$reqMonth = $year * 12 + $month - 1;
$nationID = $this->nation['nation'];
$this->reservableConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
if ($reqMonth <= $currentMonth) {
$this->runnableConstraints = [
$this->fullConditionConstraints = [
ConstraintHelper::AlwaysFail('이미 기한이 지났습니다.')
];
return;
}
}
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ExistsDestNation(),
@@ -136,22 +146,25 @@ class che_불가침수락 extends Command\NationCommand{
6 => '아국과 외교 진행중입니다.',
]),
];
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
$year = $this->arg['year'];
@@ -159,8 +172,9 @@ class che_불가침수락 extends Command\NationCommand{
return "{$year}{$month}월까지 불가침 합의";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -182,17 +196,22 @@ class che_불가침수락 extends Command\NationCommand{
$logger = $general->getLogger();
$destLogger = $this->destGeneralObj->getLogger();
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
$reqMonth = $year *12 + $month - 1;
$db->update('diplomacy',[
'state'=>7,
'term'=>$reqMonth - $currentMonth
],
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
$nationID, $destNationID,
$nationID, $destNationID);
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
$reqMonth = $year * 12 + $month - 1;
$db->update(
'diplomacy',
[
'state' => 7,
'term' => $reqMonth - $currentMonth
],
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
$nationID,
$destNationID,
$nationID,
$destNationID
);
$josaWa = JosaUtil::pick($destNationName, '와');
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaWa} <C>$year</>년 <C>{$month}</>월까지 불가침에 성공했습니다.", ActionLogger::PLAIN);
@@ -208,4 +227,4 @@ class che_불가침수락 extends Command\NationCommand{
return true;
}
}
}
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -14,9 +18,9 @@ use \sammo\{
Message,
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -26,85 +30,98 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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;
}
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
if(!key_exists('year', $this->arg) || !key_exists('month', $this->arg) ){
if (!key_exists('year', $this->arg) || !key_exists('month', $this->arg)) {
return false;
}
$year = $this->arg['year'];
$month = $this->arg['month'];
if(!is_int($year) || !is_int($month)){
if (!is_int($year) || !is_int($month)) {
return false;
}
if($month < 1 || 12 < $month){
if ($month < 1 || 12 < $month) {
return false;
}
if($year < $this->env['startyear']){
if ($year < $this->env['startyear']) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID,
'year'=>$year,
'month'=>$month,
'destNationID' => $destNationID,
'year' => $year,
'month' => $month,
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$this->setCity();
$this->setNation();
$this->minConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
];
}
protected function initWithArg()
{
$this->setDestNation($this->arg['destNationID'], null);
//NOTE: 개월에서 기한으로 바뀜
$year = $this->arg['year'];
$month = $this->arg['month'];
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
$reqMonth = $year *12 + $month - 1;
$reqMonth = $year * 12 + $month - 1;
$nationID = $this->nation['nation'];
if ($reqMonth < $currentMonth + 12) {
$this->reservableConstraints = [
$this->permissionConstraints = [
ConstraintHelper::AlwaysFail('기한은 1년 이상이어야 합니다.')
];
$this->runnableConstraints = [
$this->fullConditionConstraints = [
ConstraintHelper::AlwaysFail('기한은 1년 이상이어야 합니다.')
];
return;
}
}
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::DisallowDiplomacyBetweenStatus([
0 => '아국과 이미 교전중입니다.',
@@ -115,22 +132,25 @@ class che_불가침제의 extends Command\NationCommand{
6 => '아국과 외교 진행중입니다.',
]),
];
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
$year = $this->arg['year'];
@@ -139,8 +159,9 @@ class che_불가침제의 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -169,7 +190,7 @@ class che_불가침제의 extends Command\NationCommand{
// 상대에게 발송
$src = new MessageTarget(
$general->getID(),
$general->getID(),
$general->getName(),
$nationID,
$nationName,
@@ -186,7 +207,7 @@ class che_불가침제의 extends Command\NationCommand{
$now = new \DateTime($date);
$validUntil = new \DateTime($date);
$validMinutes = max(30, $env['turnterm']*3);
$validMinutes = max(30, $env['turnterm'] * 3);
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
$josaWa = JosaUtil::pick($nationName, '와');
@@ -199,9 +220,9 @@ class che_불가침제의 extends Command\NationCommand{
$now,
$validUntil,
[
'action'=>DiplomaticMessage::TYPE_NO_AGGRESSION,
'year'=>$year,
'month'=>$month,
'action' => DiplomaticMessage::TYPE_NO_AGGRESSION,
'year' => $year,
'month' => $month,
]
);
$msg->send();
@@ -224,7 +245,7 @@ class che_불가침제의 extends Command\NationCommand{
{
$generalObj = $this->generalObj;
$nationID = $generalObj->getNationID();
$db = DB::db();
$currYear = $this->env['year'];
@@ -235,57 +256,52 @@ class che_불가침제의 extends Command\NationCommand{
);
$nationList = [];
foreach(getAllNationStaticInfo() as $destNation){
if($destNation['nation'] == $nationID){
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
'destNationID' => $destNation['nation'],
'year' => $currYear + 1,
'month' => 12
]);
if(!$testCommand->isRunnable()){
if (!$testCommand->hasFullConditionMet()) {
$destNation['cssBgColor'] = 'background-color:red;';
}
else if($diplomacyStatus[$destNation['nation']]['state'] == 7){
} else if ($diplomacyStatus[$destNation['nation']]['state'] == 7) {
$destNation['cssBgColor'] = 'background-color:blue;';
}
else{
} else {
$destNation['cssBgColor'] = '';
}
$nationList[] = $destNation;
}
ob_start();
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(Util::range($currYear+1, $currYear+20+1) 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(Util::range(1, 12+1) as $formMonth): ?>
<option value='<?=$formMonth?>'><?=$formMonth?></option>
<?php endforeach; ?>
</select>월까지
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
<?= \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 (Util::range($currYear + 1, $currYear + 20 + 1) 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 (Util::range(1, 12 + 1) as $formMonth) : ?>
<option value='<?= $formMonth ?>'><?= $formMonth ?></option>
<?php endforeach; ?>
</select>월까지
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
<?php
return ob_get_clean();
}
}
}
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -14,9 +18,9 @@ use \sammo\{
Message,
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -26,69 +30,69 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID,
'destGeneralID'=>$destGeneralID,
'destNationID' => $destNationID,
'destGeneralID' => $destGeneralID,
];
return true;
}
protected function init(){
$general = $this->generalObj;
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
protected function init()
{
$this->setCity();
$this->setNation();
$this->permissionConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
$this->setDestGeneral($destGeneral);
$this->setDestNation($this->arg['destNationID']);
$nationID = $this->nation['nation'];
$this->reservableConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::ExistsDestGeneral(),
ConstraintHelper::ReqDestNationValue('nation', '소속', '==', $this->destGeneralObj->getNationID(), '제의 장수가 국가 소속이 아닙니다'),
@@ -97,29 +101,33 @@ class che_불가침파기수락 extends Command\NationCommand{
'불가침 중인 상대국에게만 가능합니다.'
),
];
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
return "{$destNationName}국과 불가침 파기 합의";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -140,13 +148,18 @@ class che_불가침파기수락 extends Command\NationCommand{
$logger = $general->getLogger();
$destLogger = $this->destGeneralObj->getLogger();
$db->update('diplomacy',[
'state'=>2,
'term'=>0
],
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
$nationID, $destNationID,
$nationID, $destNationID);
$db->update(
'diplomacy',
[
'state' => 2,
'term' => 0
],
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
$nationID,
$destNationID,
$nationID,
$destNationID
);
$josaYiGeneral = JosaUtil::pick($generalName, '이');
$josaYiNation = JosaUtil::pick($nationName, '이');
@@ -168,4 +181,4 @@ class che_불가침파기수락 extends Command\NationCommand{
return true;
}
}
}
@@ -60,9 +60,21 @@ class che_불가침파기제의 extends Command\NationCommand{
$this->setCity();
$this->setNation();
$this->minConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$this->setDestNation($this->arg['destNationID'], null);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
@@ -96,7 +108,7 @@ class che_불가침파기제의 extends Command\NationCommand{
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+77 -61
View File
@@ -1,20 +1,25 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
GameUnitConst,
Command,
Message, MessageTarget
Message,
MessageTarget
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -24,56 +29,67 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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;
}
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID
'destNationID' => $destNationID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$this->setCity();
$this->setNation();
$this->setDestNation($this->arg['destNationID'], null);
if($relYear < 3 - 2){
$this->runnableConstraints = [
ConstraintHelper::AlwaysFail('초반제한 해제 2년전부터 가능합니다.')
];
return;
}
$this->runnableConstraints=[
$startYear = $this->env['startyear'];
$this->minConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ReqEnvValue('year', '>=', $startYear + 1, '초반제한 해제 2년전부터 가능합니다.'),
];
}
protected function initWithArg()
{
$startYear = $this->env['startyear'];
$this->setDestNation($this->arg['destNationID'], null);
$this->fullConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ReqEnvValue('year', '>=', $startYear + 1, '초반제한 해제 2년전부터 가능합니다.'),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::NearNation(),
ConstraintHelper::DisallowDiplomacyBetweenStatus([
@@ -86,30 +102,34 @@ class che_선전포고 extends Command\NationCommand{
5 => '상대국이 외교 진행중입니다.'
]),
];
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
return "{$destNationName}】에 {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -143,15 +163,15 @@ class che_선전포고 extends Command\NationCommand{
$logger->pushGlobalHistoryLog("<R><b>【선포】</b></><D><b>{$nationName}</b></>{$josaYiNation} <D><b>{$destNationName}</b></>에 선전 포고 하였습니다.");
$db->update('diplomacy', [
'state'=>1,
'term'=>24
'state' => 1,
'term' => 24
], '(me=%i AND you=%i) OR (me=%i AND you=%i)', $nationID, $destNationID, $destNationID, $nationID);
//국메로 저장
$text = "【외교】{$env['year']}{$env['month']}월:{$nationName}에서 {$destNationName}에 선전포고";
$src = new MessageTarget(
$general->getID(),
$general->getID(),
$general->getName(),
$nationID,
$nationName,
@@ -166,7 +186,7 @@ class che_선전포고 extends Command\NationCommand{
$destNation['color']
);
$msg = new Message(
Message::MSGTYPE_NATIONAL,
Message::MSGTYPE_NATIONAL,
$src,
$dest,
$text,
@@ -197,40 +217,36 @@ class che_선전포고 extends Command\NationCommand{
$startYear = $this->env['startyear'];
$availableYear = $startYear + 1;
$nationList = [];
foreach(getAllNationStaticInfo() as $destNation){
if($destNation['nation'] == $nationID){
foreach (getAllNationStaticInfo() as $destNation) {
if ($destNation['nation'] == $nationID) {
continue;
}
$testCommand = new static($generalObj, $this->env, $this->getLastTurn(), ['destNationID'=>$destNation['nation']]);
if($testCommand->isRunnable()){
$testCommand = new static($generalObj, $this->env, $this->getLastTurn(), ['destNationID' => $destNation['nation']]);
if ($testCommand->hasFullConditionMet()) {
$destNation['availableWar'] = true;
}
else{
} else {
$destNation['availableWar'] = false;
}
$nationList[] = $destNation;
}
ob_start();
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
타국에게 선전 포고합니다.<br>
선전 포고할 국가를 목록에서 선택하세요.<br>
고립되지 않은 아국 도시에서 인접한 국가에 선포 가능합니다.<br>
초반제한 해제 2년전부터 선포가 가능합니다. (<?=$availableYear?>년 1월부터 가능)<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['availableWar']?'':'background-color:red;'?>'
>【<?=$nation['name']?> 】</option>
<?php endforeach; ?>
</select>
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
<?= \sammo\getMapHtml() ?><br>
타국에게 선전 포고합니다.<br>
선전 포고할 국가를 목록에서 선택하세요.<br>
고립되지 않은 아국 도시에서 인접한 국가에 선포 가능합니다.<br>
초반제한 해제 2년전부터 선포가 가능합니다. (<?= $availableYear ?>년 1월부터 가능)<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['availableWar'] ? '' : 'background-color:red;' ?>'>【<?= $nation['name'] ?> 】</option>
<?php endforeach; ?>
</select>
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
<?php
return ob_get_clean();
}
}
}
+13 -3
View File
@@ -56,10 +56,20 @@ class che_수몰 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->setDestCity($this->arg['destCityID'], null);
$this->minConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand(),
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation']);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::NotNeutralDestCity(),
@@ -101,7 +111,7 @@ class che_수몰 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -25,7 +25,6 @@ use \sammo\Constraint\ConstraintHelper;
class che_의병모집 extends Command\NationCommand{
static protected $actionName = '의병모집';
static public $reqArg = false;
protected function argTest():bool{
$this->arg = null;
@@ -41,7 +40,7 @@ class che_의병모집 extends Command\NationCommand{
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
@@ -75,7 +74,7 @@ class che_의병모집 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+73 -55
View File
@@ -1,20 +1,25 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
GameUnitConst,
Command,
Message, MessageTarget
Message,
MessageTarget
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -24,34 +29,37 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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;
}
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID
'destNationID' => $destNationID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -59,9 +67,18 @@ class che_이호경식 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->minConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand(),
];
}
protected function initWithArg()
{
$this->setDestNation($this->arg['destNationID'], null);
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::ExistsDestNation(),
@@ -71,42 +88,47 @@ class che_이호경식 extends Command\NationCommand{
),
ConstraintHelper::AvailableStrategicCommand(),
];
}
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*16)*10);
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
return $nextTerm;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
return "{$destNationName}】에 {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -144,7 +166,7 @@ class che_이호경식 extends Command\NationCommand{
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
foreach($nationGeneralList as $nationGeneralID){
foreach ($nationGeneralList as $nationGeneralID) {
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
$nationGeneralLogger->flush();
@@ -155,7 +177,7 @@ class che_이호경식 extends Command\NationCommand{
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
foreach($destNationGeneralList as $destNationGeneralID){
foreach ($destNationGeneralList as $destNationGeneralID) {
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
$destNationGeneralLogger->flush();
@@ -166,13 +188,13 @@ class che_이호경식 extends Command\NationCommand{
$destNationLogger->flush();
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
$db->update('nation', [
'strategic_cmd_limit' => $this->getPostReqTurn()
], 'nation=%i', $nationID);
$db->update('diplomacy', [
'term'=>$db->sqleval('IF(`state`=0, %i, `term`+ %i)', 3, 3),
'state'=>1,
'term' => $db->sqleval('IF(`state`=0, %i, `term`+ %i)', 3, 3),
'state' => 1,
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
$general->applyDB($db);
@@ -193,39 +215,35 @@ class che_이호경식 extends Command\NationCommand{
$nationID = $generalObj->getNationID();
$nationList = [];
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
foreach(getAllNationStaticInfo() as $destNation){
if($destNation['nation'] == $nationID){
foreach (getAllNationStaticInfo() as $destNation) {
if ($destNation['nation'] == $nationID) {
continue;
}
$testTurn->setArg(['destNationID'=>$destNation['nation']]);
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]);
if($testCommand->isRunnable()){
$testTurn->setArg(['destNationID' => $destNation['nation']]);
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
if ($testCommand->hasFullConditionMet()) {
$destNation['availableCommand'] = true;
}
else{
} else {
$destNation['availableCommand'] = false;
}
$nationList[] = $destNation;
}
ob_start();
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
<?= \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();
}
}
}
+62 -42
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -14,9 +18,9 @@ use \sammo\{
Message,
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
getAllNationStaticInfo,
getNationStaticInfo,
@@ -26,48 +30,51 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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('destNationID', $this->arg)){
if (!key_exists('destNationID', $this->arg)) {
return false;
}
$destNationID = $this->arg['destNationID'];
if(!is_int($destNationID)){
if (!is_int($destNationID)) {
return false;
}
if($destNationID < 1){
if ($destNationID < 1) {
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
$this->arg = [
'destNationID'=>$destNationID,
'destGeneralID'=>$destGeneralID,
'destNationID' => $destNationID,
'destGeneralID' => $destGeneralID,
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -76,19 +83,23 @@ class che_종전수락 extends Command\NationCommand{
$this->setCity();
$this->setNation();
$nationID = $this->nation['nation'];
$this->permissionConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
$this->setDestGeneral($destGeneral);
$this->setDestNation($this->arg['destNationID']);
$nationID = $this->nation['nation'];
$this->reservableConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::ExistsDestGeneral(),
ConstraintHelper::ReqDestNationValue('nation', '소속', '==', $this->destGeneralObj->getNationID(), '제의 장수가 국가 소속이 아닙니다'),
@@ -97,29 +108,33 @@ class che_종전수락 extends Command\NationCommand{
'상대국과 선포, 전쟁중이지 않습니다.'
),
];
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
return "{$destNationName}국과 종전 합의";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -140,13 +155,18 @@ class che_종전수락 extends Command\NationCommand{
$logger = $general->getLogger();
$destLogger = $this->destGeneralObj->getLogger();
$db->update('diplomacy',[
'state'=>2,
'term'=>0
],
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
$nationID, $destNationID,
$nationID, $destNationID);
$db->update(
'diplomacy',
[
'state' => 2,
'term' => 0
],
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
$nationID,
$destNationID,
$nationID,
$destNationID
);
$josaYiGeneral = JosaUtil::pick($generalName, '이');
$josaYiNation = JosaUtil::pick($nationName, '이');
@@ -168,4 +188,4 @@ class che_종전수락 extends Command\NationCommand{
return true;
}
}
}
+13 -3
View File
@@ -60,9 +60,20 @@ class che_종전제의 extends Command\NationCommand{
$this->setCity();
$this->setNation();
$this->minConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$this->setDestNation($this->arg['destNationID'], null);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeChief(),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
@@ -73,7 +84,6 @@ class che_종전제의 extends Command\NationCommand{
'선포, 전쟁중인 상대국에게만 가능합니다.'
),
];
}
public function getCost():array{
@@ -96,7 +106,7 @@ class che_종전제의 extends Command\NationCommand{
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+5 -6
View File
@@ -28,7 +28,6 @@ use sammo\Event\Action;
class che_증축 extends Command\NationCommand{
static protected $actionName = '증축';
static public $reqArg = false;
protected function argTest():bool{
$this->arg = [];
@@ -42,10 +41,10 @@ class che_증축 extends Command\NationCommand{
$env = $this->env;
if($general->getNationID()===0){
$this->reservableConstraints=[
$this->permissionConstraints=[
ConstraintHelper::NotBeNeutral(),
];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
];
return;
@@ -53,11 +52,11 @@ class che_증축 extends Command\NationCommand{
$this->setCity();
$this->setNation(['gold', 'rice', 'capset', 'capital']);
$this->setDestCity($this->nation['capital'], null);
$this->setDestCity($this->nation['capital']);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
@@ -135,7 +134,7 @@ class che_증축 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+76 -53
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -14,110 +18,127 @@ use \sammo\{
CityConst
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
GetImageURL,
getNationStaticInfo
getNationStaticInfo
};
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;
private $cachedDist = null;
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;
$this->setCity();
$this->setNation(['capset', 'gold', 'rice', 'capital']);
$this->setDestCity($this->arg['destCityID'], null);
$this->minConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
[$reqGold, $reqRice] = $this->getCost();
if($this->getDistance() === null){
$this->runnableConstraints[
ConstraintHelper::AlwaysFail('천도 대상으로 도달할 방법이 없습니다.')
];
if ($this->getDistance() === null) {
$this->fullConditionConstraints[ConstraintHelper::AlwaysFail('천도 대상으로 도달할 방법이 없습니다.')];
return;
}
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::OccupiedDestCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::SuppliedDestCity(),
ConstraintHelper::ReqNationValue('capital', '수도', '!=', $this->destCity['city'], '이미 수도입니다.'),
ConstraintHelper::ReqNationGold(GameConst::$basegold+$reqGold),
ConstraintHelper::ReqNationRice(GameConst::$baserice+$reqRice),
ConstraintHelper::ReqNationGold(GameConst::$basegold + $reqGold),
ConstraintHelper::ReqNationRice(GameConst::$baserice + $reqRice),
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
$amount = number_format($this->env['develcost'] * 5);
return "{$name}/1+거리×2턴(금쌀 {$amount}×2^거리)";
}
public function getCost():array{
public function getCost(): array
{
$amount = $this->env['develcost'] * 5;
$amount *= 2**$this->getDistance()??50;
$amount *= 2 ** $this->getDistance() ?? 50;
return [$amount, $amount];
}
private function getDistance():?int{
if($this->cachedDist !== null){
private function getDistance(): ?int
{
if ($this->cachedDist !== null) {
return $this->cachedDist;
}
$srcCityID = $this->nation['capital'];
$destCityID = $this->arg['destCityID'];
$nationID = $this->nation['nation'];
$distance = \sammo\calcCityDistance($srcCityID, $destCityID, [$nationID])??50;
$distance = \sammo\calcCityDistance($srcCityID, $destCityID, [$nationID]) ?? 50;
$this->cachedDist = $distance;
return $distance;
}
public function getPreReqTurn():int{
return $this->getDistance()*2;
public function getPreReqTurn(): int
{
return $this->getDistance() * 2;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function addTermStack():bool{
public function addTermStack(): bool
{
$lastTurn = $this->getLastTurn();
$commandName = $this->getName();
@@ -126,7 +147,7 @@ class che_천도 extends Command\NationCommand{
$nationID = $general->getNationID();
$nationStor->setValue("last천도Trial_{$nationID}", [$general->getVar('officer_level'), $general->getTurnTime()]);
if($lastTurn->getCommand() != $commandName || $lastTurn->getArg() !== $this->arg){
if ($lastTurn->getCommand() != $commandName || $lastTurn->getArg() !== $this->arg) {
$this->setResultTurn(new LastTurn(
$commandName,
$this->arg,
@@ -136,7 +157,7 @@ class che_천도 extends Command\NationCommand{
return false;
}
if($lastTurn->getSeq() < $this->nation['capset']){
if ($lastTurn->getSeq() < $this->nation['capset']) {
//NOTE: 최근에 천도, 증축이 일어났으면 리셋됨
$this->setResultTurn(new LastTurn(
$commandName,
@@ -147,7 +168,7 @@ class che_천도 extends Command\NationCommand{
return false;
}
if($lastTurn->getTerm() < $this->getPreReqTurn()){
if ($lastTurn->getTerm() < $this->getPreReqTurn()) {
$this->setResultTurn(new LastTurn(
$commandName,
$this->arg,
@@ -160,15 +181,17 @@ class che_천도 extends Command\NationCommand{
return true;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
$josaRo = JosaUtil::pick($destCityName, '로');
return "{$destCityName}{$josaRo} {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -192,7 +215,7 @@ class che_천도 extends Command\NationCommand{
$josaRo = JosaUtil::pick($destCityName, '로');
$logger = $general->getLogger();
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
@@ -204,7 +227,7 @@ class che_천도 extends Command\NationCommand{
'capital' => $destCityID,
'capset' => $db->sqleval('capset + 1'),
], 'nation=%i', $nationID);
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaRo} 천도했습니다. <1>$date</>");
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>{$josaRo} <M>천도</>명령");
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaRo} <M>천도</> 명령");
@@ -228,15 +251,15 @@ class che_천도 extends Command\NationCommand{
{
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>
<?= \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();
}
}
}
+14 -3
View File
@@ -58,9 +58,20 @@ class che_초토화 extends Command\NationCommand{
$this->setCity();
$this->setNation(['surlimit', 'gold', 'rice', 'capital']);
$this->setDestCity($this->arg['destCityID'], null);
$this->runnableConstraints=[
$this->minConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ReqNationValue('surlimit', '제한 턴', '==', 0, '외교제한 턴이 남아있습니다.'),
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::OccupiedDestCity(),
ConstraintHelper::BeChief(),
@@ -102,7 +113,7 @@ class che_초토화 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+95 -74
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -11,114 +15,131 @@ use \sammo\{
Command
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx
};
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
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;
}
//NOTE: 사망 직전에 '포상' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('isGold', $this->arg)){
if (!key_exists('isGold', $this->arg)) {
return false;
}
if(!key_exists('amount', $this->arg)){
if (!key_exists('amount', $this->arg)) {
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_numeric($amount)){
if (!is_numeric($amount)) {
return false;
}
$amount = Util::round($amount, -2);
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
if($amount <= 0){
if ($amount <= 0) {
return false;
}
if(!is_bool($isGold)){
if (!is_bool($isGold)) {
return false;
}
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount,
'destGeneralID'=>$destGeneralID
'isGold' => $isGold,
'amount' => $amount,
'destGeneralID' => $destGeneralID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation(['gold', 'rice']);
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1);
$this->setDestGeneral($destGeneral);
$this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(),
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ExistsDestGeneral(),
ConstraintHelper::FriendlyDestGeneral()
];
if($this->arg['isGold']){
$this->runnableConstraints[] = ConstraintHelper::ReqNationGold(1+GameConst::$basegold);
}
else{
$this->runnableConstraints[] = ConstraintHelper::ReqNationRice(1+GameConst::$baserice);
if ($this->arg['isGold']) {
$this->fullConditionConstraints[] = ConstraintHelper::ReqNationGold(1 + GameConst::$basegold);
} else {
$this->fullConditionConstraints[] = ConstraintHelper::ReqNationRice(1 + GameConst::$baserice);
}
}
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
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$amountText = number_format($amount, 0);
$resName = $isGold?'금':'쌀';
$resName = $isGold ? '금' : '쌀';
$destGeneral = $this->destGeneralObj;
$commandName = $this->getName();
return "{$destGeneral->getName()}{$resName} $amountText {$commandName}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -132,22 +153,22 @@ class che_포상 extends Command\NationCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$resKey = $isGold?'gold':'rice';
$resName = $isGold?'금':'쌀';
$resKey = $isGold ? 'gold' : 'rice';
$resName = $isGold ? '금' : '쌀';
$destGeneral = $this->destGeneralObj;
$amount = Util::valueFit(
$amount,
0,
$nation[$resKey] - ($isGold?GameConst::$basegold:GameConst::$baserice)
$amount,
0,
$nation[$resKey] - ($isGold ? GameConst::$basegold : GameConst::$baserice)
);
$amountText = number_format($amount, 0);
$logger = $general->getLogger();
$destGeneral->increaseVar($resKey, $amount);
$db->update('nation', [
$resKey=>$db->sqleval('%b - %i', $resKey, $amount)
$resKey => $db->sqleval('%b - %i', $resKey, $amount)
], 'nation=%i', $nationID);
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} <C>{$amountText}</>을 포상으로 받았습니다.", ActionLogger::PLAIN);
@@ -160,53 +181,53 @@ class che_포상 extends Command\NationCommand{
return true;
}
public function getForm(): string
{
//TODO: 암행부처럼 보여야...
$db = DB::db();
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID());
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation = %i AND no != %i ORDER BY npc,binary(name)', $this->generalObj->getNationID(), $this->generalObj->getID());
$destGeneralList = [];
foreach($destRawGenerals as $destGeneral){
foreach ($destRawGenerals as $destGeneral) {
$nameColor = \sammo\getNameColor($destGeneral['npc']);
if($nameColor){
if ($nameColor) {
$nameColor = " style='color:{$nameColor}'";
}
$name = $destGeneral['name'];
if($destGeneral['officer_level'] >= 5){
if ($destGeneral['officer_level'] >= 5) {
$name = "*{$name}*";
}
$destGeneralList[] = [
'no'=>$destGeneral['no'],
'color'=>$nameColor,
'name'=>$name,
'gold'=>$destGeneral['gold'],
'rice'=>$destGeneral['rice']
'no' => $destGeneral['no'],
'color' => $nameColor,
'name' => $name,
'gold' => $destGeneral['gold'],
'rice' => $destGeneral['rice']
];
}
ob_start();
?>
국고로 장수에게 자금이나 군량을 지급합니다.<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']?>(금:<?=$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>
<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>
<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'] ?>(금:<?= $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>
<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>
<br>
<?php
return ob_get_clean();
}
}
}
+12 -4
View File
@@ -60,9 +60,18 @@ class che_피장파장 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->minConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand(),
];
}
protected function initWithArg()
{
$this->setDestNation($this->arg['destNationID'], null);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::ExistsDestNation(),
@@ -72,7 +81,6 @@ class che_피장파장 extends Command\NationCommand{
),
ConstraintHelper::AvailableStrategicCommand(),
];
}
public function getCommandDetailTitle():string{
@@ -107,7 +115,7 @@ class che_피장파장 extends Command\NationCommand{
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -200,7 +208,7 @@ class che_피장파장 extends Command\NationCommand{
$testTurn->setArg(['destNationID'=>$destNation['nation']]);
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]);
if($testCommand->isRunnable()){
if($testCommand->hasFullConditionMet()){
$destNation['availableCommand'] = true;
}
else{
@@ -26,7 +26,6 @@ use sammo\Event\Action;
class che_필사즉생 extends Command\NationCommand{
static protected $actionName = '필사즉생';
static public $reqArg = false;
protected function argTest():bool{
$this->arg = [];
@@ -42,7 +41,7 @@ class che_필사즉생 extends Command\NationCommand{
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
@@ -77,7 +76,7 @@ class che_필사즉생 extends Command\NationCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+66 -42
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\Nation;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -14,52 +18,65 @@ use \sammo\{
CityConst
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
GetImageURL,
getNationStaticInfo
getNationStaticInfo
};
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;
$this->setCity();
$this->setNation(['strategic_cmd_limit']);
$this->setDestCity($this->arg['destCityID'], null);
$this->setDestNation($this->destCity['nation']);
$this->runnableConstraints=[
$this->minConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::AvailableStrategicCommand(),
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation']);
$this->fullConditionConstraints = [
ConstraintHelper::OccupiedCity(),
ConstraintHelper::BeChief(),
ConstraintHelper::NotNeutralDestCity(),
@@ -72,38 +89,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 1;
}
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->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -123,7 +146,7 @@ class che_허보 extends Command\NationCommand{
$destNationID = $destCity['nation'];
$destNationName = getNationStaticInfo($destNationID)['name'];
$nationID = $general->getNationID();
$nationName = $this->nation['name'];
@@ -138,7 +161,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();
@@ -148,12 +171,12 @@ class che_허보 extends Command\NationCommand{
$destNationCityList = $db->queryFirstColumn('SELECT city FROM city WHERE nation = %i AND supply = 1', $destNationID);
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i', $destNationID, $destCityID);
foreach(General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral){
foreach (General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
$targetLogger = $targetGeneral->getLogger();
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
$moveCityID = Util::choiceRandom($destNationCityList);
if($moveCityID == $destCityID){
if ($moveCityID == $destCityID) {
//현재도시면 다시 랜덤 추첨
$moveCityID = Util::choiceRandom($destNationCityList);
}
@@ -164,7 +187,8 @@ class che_허보 extends Command\NationCommand{
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
$destNationLogger->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
);
$destNationLogger->flush();
@@ -173,7 +197,7 @@ class che_허보 extends Command\NationCommand{
'def' => $db->sqleval('def * 0.2'),
'wall' => $db->sqleval('wall * 0.2'),
], 'city=%i', $destCityID);
$josaYiNation = JosaUtil::pick($nationName, '이');
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>에 <M>허보</>를 발동");
@@ -202,15 +226,15 @@ class che_허보 extends Command\NationCommand{
{
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>
<?= \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();
}
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ class 휴식 extends Command\NationCommand{
protected function init(){
//아무것도 하지 않음
$this->runnableConstraints=[];
$this->fullConditionConstraints=[];
}