전략 사용 방식 변경
This commit is contained in:
@@ -232,7 +232,7 @@ function checkCommandArg(?array $arg):?string{
|
|||||||
}
|
}
|
||||||
$defaultCheck = [
|
$defaultCheck = [
|
||||||
/*'string'=>[
|
/*'string'=>[
|
||||||
'nationName', 'optionText', 'itemType', 'nationType'
|
'nationName', 'optionText', 'itemType', 'nationType', 'commandType',
|
||||||
],*/
|
],*/
|
||||||
'integer'=>[
|
'integer'=>[
|
||||||
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
||||||
|
|||||||
@@ -516,6 +516,7 @@ function checkWander()
|
|||||||
$logger = $wanderer->getLogger();
|
$logger = $wanderer->getLogger();
|
||||||
$logger->pushGeneralActionLog('초반 제한후 방랑군은 자동 해산됩니다.', ActionLogger::PLAIN);
|
$logger->pushGeneralActionLog('초반 제한후 방랑군은 자동 해산됩니다.', ActionLogger::PLAIN);
|
||||||
$wanderCmd->run();
|
$wanderCmd->run();
|
||||||
|
$wanderCmd->setNextAvailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ jQuery(function($) {
|
|||||||
//checkCommandArg 참고
|
//checkCommandArg 참고
|
||||||
var availableArgumentList = {
|
var availableArgumentList = {
|
||||||
'string': [
|
'string': [
|
||||||
'nationName', 'optionText', 'itemType', 'nationType', 'itemCode',
|
'nationName', 'optionText', 'itemType', 'nationType', 'itemCode', 'commandType',
|
||||||
],
|
],
|
||||||
'int': [
|
'int': [
|
||||||
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use \sammo\Constraint\ConstraintHelper;
|
|||||||
abstract class BaseCommand{
|
abstract class BaseCommand{
|
||||||
static protected $actionName = 'CommandName';
|
static protected $actionName = 'CommandName';
|
||||||
static public $reqArg = false;
|
static public $reqArg = false;
|
||||||
|
static protected $isLazyCalcReqTurn = false;
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
return $this->getName();
|
return $this->getName();
|
||||||
@@ -54,7 +55,6 @@ abstract class BaseCommand{
|
|||||||
|
|
||||||
static protected $isInitStatic = true;
|
static protected $isInitStatic = true;
|
||||||
protected static function initStatic(){
|
protected static function initStatic(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(General $generalObj, array $env, $arg = null){
|
public function __construct(General $generalObj, array $env, $arg = null){
|
||||||
@@ -271,6 +271,29 @@ abstract class BaseCommand{
|
|||||||
return $this->logger;
|
return $this->logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract protected function getNextExecuteKey():string;
|
||||||
|
abstract public function getNextAvailable():?int;
|
||||||
|
abstract public function setNextAvailable(?int $yearMonth=null);
|
||||||
|
|
||||||
|
protected function testPostReqTurn():?array{
|
||||||
|
if(!$this->getPostReqTurn()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextAvailable = $this->getNextAvailable();
|
||||||
|
if($nextAvailable === null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
$remainTurn = $nextAvailable - $yearMonth - $this->getPreReqTurn();
|
||||||
|
if($remainTurn <= 0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['testPostReqTurn', "{$remainTurn}턴 더 기다려야 합니다"];
|
||||||
|
}
|
||||||
|
|
||||||
public function testPermissionToReserve():?string{
|
public function testPermissionToReserve():?string{
|
||||||
if($this->cachedPermissionToReserve){
|
if($this->cachedPermissionToReserve){
|
||||||
return $this->reasonNoPermissionToReserve;
|
return $this->reasonNoPermissionToReserve;
|
||||||
@@ -331,6 +354,11 @@ abstract class BaseCommand{
|
|||||||
];
|
];
|
||||||
|
|
||||||
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = Constraint::testAll($this->minConditionConstraints??[], $constraintInput, $this->env);
|
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = Constraint::testAll($this->minConditionConstraints??[], $constraintInput, $this->env);
|
||||||
|
|
||||||
|
if($this->reasonNotMinConditionMet === null && !self::$isLazyCalcReqTurn){
|
||||||
|
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = $this->testPostReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
$this->cachedMinConditionMet = true;
|
$this->cachedMinConditionMet = true;
|
||||||
return $this->reasonNotMinConditionMet;
|
return $this->reasonNotMinConditionMet;
|
||||||
|
|
||||||
@@ -364,6 +392,11 @@ abstract class BaseCommand{
|
|||||||
];
|
];
|
||||||
|
|
||||||
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = Constraint::testAll($this->fullConditionConstraints??[], $constraintInput, $this->env);
|
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = Constraint::testAll($this->fullConditionConstraints??[], $constraintInput, $this->env);
|
||||||
|
|
||||||
|
if($this->reasonNotFullConditionMet === null){
|
||||||
|
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = $this->testPostReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
$this->cachedFullConditionMet = true;
|
$this->cachedFullConditionMet = true;
|
||||||
return $this->reasonNotFullConditionMet;
|
return $this->reasonNotFullConditionMet;
|
||||||
|
|
||||||
|
|||||||
@@ -32,24 +32,6 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
|
||||||
$env = $this->env;
|
|
||||||
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
|
||||||
$auxYearMonth = $general->getAuxVar('used_'.$this->getName())??-999;
|
|
||||||
|
|
||||||
if($yearMonth < $auxYearMonth + 60 - $this->getPreReqTurn()){
|
|
||||||
$this->minConditionConstraints=[
|
|
||||||
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
|
||||||
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
|
|
||||||
];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
|
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
|
||||||
];
|
];
|
||||||
@@ -57,7 +39,6 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
|||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
|
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
@@ -82,7 +63,7 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTermString():string{
|
public function getTermString():string{
|
||||||
@@ -113,7 +94,6 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
$general->setVar(static::$specialType, 'None');
|
$general->setVar(static::$specialType, 'None');
|
||||||
$general->setVar(static::$speicalAge, $general->getVar('age') + 1);
|
$general->setVar(static::$speicalAge, $general->getVar('age') + 1);
|
||||||
$general->setAuxVar('used_'.$this->getName(), $yearMonth);
|
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command;
|
namespace sammo\Command;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
abstract class GeneralCommand extends BaseCommand{
|
abstract class GeneralCommand extends BaseCommand{
|
||||||
|
|
||||||
|
protected function getNextExecuteKey():string{
|
||||||
|
$turnKey = static::$actionName;
|
||||||
|
$generalID = $this->getGeneral()->getID();
|
||||||
|
$executeKey = "next_execute_{$generalID}_{$turnKey}";
|
||||||
|
return $executeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextAvailable():?int{
|
||||||
|
if($this->isArgValid && !$this->getPostReqTurn()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$lastExecuteStor = \sammo\KVStorage::getStorage($db, 'next_execute');
|
||||||
|
return $lastExecuteStor->getValue($this->getNextExecuteKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
|
if(!$this->getPostReqTurn()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($yearMonth === null){
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']) + $this->getPostReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$lastExecuteStor = \sammo\KVStorage::getStorage($db, 'next_execute');
|
||||||
|
$lastExecuteStor->setValue($this->getNextExecuteKey(), $yearMonth);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -72,7 +72,7 @@ class che_급습 extends Command\NationCommand
|
|||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class che_급습 extends Command\NationCommand
|
|||||||
12,
|
12,
|
||||||
'선포 12개월 이상인 상대국에만 가능합니다.'
|
'선포 12개월 이상인 상대국에만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,9 +124,18 @@ class che_물자원조 extends Command\NationCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
|
//NOTE: 자체 postReqTurn 사용
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNextAvailable():?int{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public function getBrief():string{
|
public function getBrief():string{
|
||||||
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
||||||
$goldAmountText = number_format($goldAmount);
|
$goldAmountText = number_format($goldAmount);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class che_백성동원 extends Command\NationCommand{
|
|||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand()
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,11 +72,8 @@ class che_백성동원 extends Command\NationCommand{
|
|||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
|
||||||
0, 1
|
|
||||||
], '전쟁중이 아닙니다.'),
|
|
||||||
ConstraintHelper::OccupiedDestCity(),
|
ConstraintHelper::OccupiedDestCity(),
|
||||||
ConstraintHelper::AvailableStrategicCommand()
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +158,7 @@ class che_백성동원 extends Command\NationCommand{
|
|||||||
$logger->pushNationalHistoryLog("<L><b>【전략】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.");
|
$logger->pushNationalHistoryLog("<L><b>【전략】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => 12
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class che_수몰 extends Command\NationCommand{
|
|||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ class che_수몰 extends Command\NationCommand{
|
|||||||
ConstraintHelper::NotNeutralDestCity(),
|
ConstraintHelper::NotNeutralDestCity(),
|
||||||
ConstraintHelper::NotOccupiedDestCity(),
|
ConstraintHelper::NotOccupiedDestCity(),
|
||||||
ConstraintHelper::BattleGroundCity(),
|
ConstraintHelper::BattleGroundCity(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ class che_수몰 extends Command\NationCommand{
|
|||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => 12
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class che_의병모집 extends Command\NationCommand
|
|||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
ConstraintHelper::NotOpeningPart($relYear),
|
ConstraintHelper::NotOpeningPart($relYear),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ class che_의병모집 extends Command\NationCommand
|
|||||||
$gameStor->npccount = $lastCreatGenIdx;
|
$gameStor->npccount = $lastCreatGenIdx;
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'gennum' => $db->sqleval('gennum + %i', $createGenCnt),
|
'gennum' => $db->sqleval('gennum + %i', $createGenCnt),
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => 12
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class che_이호경식 extends Command\NationCommand
|
|||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ class che_이호경식 extends Command\NationCommand
|
|||||||
[0, 1],
|
[0, 1],
|
||||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ class che_이호경식 extends Command\NationCommand
|
|||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => 12
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'term' => $db->sqleval('IF(`state`=0, %i, `term`+ %i)', 3, 3),
|
'term' => $db->sqleval('IF(`state`=0, %i, `term`+ %i)', 3, 3),
|
||||||
|
|||||||
@@ -95,9 +95,18 @@ class che_초토화 extends Command\NationCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
|
//NOTE: 자체 postReqTurn 사용
|
||||||
return 24;
|
return 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNextAvailable():?int{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use \sammo\{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
|
buildNationCommandClass,
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
@@ -58,12 +59,11 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation();
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,6 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
[0, 1],
|
[0, 1],
|
||||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
$reqTurn = $this->getPreReqTurn()+1;
|
$reqTurn = $this->getPreReqTurn()+1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
@@ -96,15 +95,11 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 2;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
return 0;
|
||||||
$nextTerm = Util::round(sqrt($genCount*2)*10);
|
|
||||||
|
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
|
||||||
return $nextTerm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief():string{
|
public function getBrief():string{
|
||||||
@@ -176,12 +171,7 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
|
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
$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('nation', [
|
|
||||||
'strategic_cmd_limit' => $db->sqleval('strategic_cmd_limit + %i', static::$delayCnt)
|
|
||||||
], 'nation = %i', $destNationID);
|
|
||||||
|
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
@@ -218,10 +208,28 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
$nationList[] = $destNation;
|
$nationList[] = $destNation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$availableCommandTypeList = [];
|
||||||
|
$currYearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
foreach(GameConst::$availableChiefCommand['전략'] as $commandType){
|
||||||
|
$cmd = buildNationCommandClass($commandType, $generalObj, $this->env, new LastTurn());
|
||||||
|
if($cmd->getName() == $this->getName()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$cmdName = $cmd->getName();
|
||||||
|
$available = true;
|
||||||
|
$nextAvailable = $cmd->getNextAvailable();
|
||||||
|
|
||||||
|
if($nextAvailable !== null && $currYearMonth < $cmd->getNextAvailable() - $cmd->getPreReqTurn()){
|
||||||
|
$available = false;
|
||||||
|
}
|
||||||
|
$availableCommandTypeList[$commandType] = [$cmdName, $available];
|
||||||
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<?=\sammo\getMapHtml()?><br>
|
<?=\sammo\getMapHtml()?><br>
|
||||||
선택된 국가에 피장파장을 발동합니다.<br>
|
선택된 국가에 피장파장을 발동합니다.<br>
|
||||||
|
지정한 전략을 상대국이 <?=static::$delayCnt?>턴 동안 사용할 수 없게됩니다.<br>
|
||||||
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
||||||
상대 국가를 목록에서 선택하세요.<br>
|
상대 국가를 목록에서 선택하세요.<br>
|
||||||
배경색은 현재 피장파장 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
배경색은 현재 피장파장 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||||
@@ -232,6 +240,16 @@ class che_피장파장 extends Command\NationCommand{
|
|||||||
style='color:<?=$nation['color']?>;<?=$nation['availableCommand']?'':'background-color:red;'?>'
|
style='color:<?=$nation['color']?>;<?=$nation['availableCommand']?'':'background-color:red;'?>'
|
||||||
>【<?=$nation['name']?> 】</option>
|
>【<?=$nation['name']?> 】</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
<select class='formInput' name="commandType" id="commandType" size='1' style='color:white;background-color:black;'>
|
||||||
|
<?php foreach($availableCommandTypeList as $commandType=>[$cmdName, $cmdAvailable]):
|
||||||
|
/** @var \sammo\Command\NationCommand $cmdObj */
|
||||||
|
?>
|
||||||
|
<option
|
||||||
|
value='<?=$commandType?>'
|
||||||
|
style='color:white;<?=$cmdAvailable?'':'background-color:red;'?>'
|
||||||
|
>【<?=$cmdName?> 】</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class che_필사즉생 extends Command\NationCommand{
|
|||||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||||
0
|
0
|
||||||
], '전쟁중이 아닙니다.'),
|
], '전쟁중이 아닙니다.'),
|
||||||
ConstraintHelper::AvailableStrategicCommand()
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class che_허보 extends Command\NationCommand
|
|||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class che_허보 extends Command\NationCommand
|
|||||||
[0, 1],
|
[0, 1],
|
||||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand($this->getPreReqTurn()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command;
|
namespace sammo\Command;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use sammo\KVStorage;
|
||||||
use \sammo\LastTurn;
|
use \sammo\LastTurn;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
abstract class NationCommand extends BaseCommand{
|
abstract class NationCommand extends BaseCommand{
|
||||||
protected $lastTurn;
|
protected $lastTurn;
|
||||||
@@ -25,6 +27,32 @@ abstract class NationCommand extends BaseCommand{
|
|||||||
return $this->resultTurn;
|
return $this->resultTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getNextExecuteKey():string{
|
||||||
|
$turnKey = static::$actionName;
|
||||||
|
$executeKey = "next_execute_{$turnKey}";
|
||||||
|
return $executeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextAvailable():?int{
|
||||||
|
if($this->isArgValid && !$this->getPostReqTurn()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$nationStor = \sammo\KVStorage::getStorage($db, $this->getNationID(), 'nation_env');
|
||||||
|
return $nationStor->getValue($this->getNextExecuteKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
|
if(!$this->getPostReqTurn()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($yearMonth === null){
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']) + $this->getPostReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$nationStor = \sammo\KVStorage::getStorage($db, $this->getNationID(), 'nation_env');
|
||||||
|
$nationStor->setValue($this->getNextExecuteKey(), $yearMonth);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace sammo\Constraint;
|
namespace sammo\Constraint;
|
||||||
|
|
||||||
class AvailableStrategicCommand extends Constraint{
|
class AvailableStrategicCommand extends Constraint{
|
||||||
const REQ_VALUES = Constraint::REQ_NATION;
|
const REQ_VALUES = Constraint::REQ_NATION | Constraint::REQ_INT_ARG;
|
||||||
|
|
||||||
public function checkInputValues(bool $throwExeception=true):bool{
|
public function checkInputValues(bool $throwExeception=true):bool{
|
||||||
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
|
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
|
||||||
@@ -22,7 +22,7 @@ class AvailableStrategicCommand extends Constraint{
|
|||||||
$this->checkInputValues();
|
$this->checkInputValues();
|
||||||
$this->tested = true;
|
$this->tested = true;
|
||||||
|
|
||||||
if($this->nation['strategic_cmd_limit'] == 0){
|
if($this->nation['strategic_cmd_limit'] <= $this->arg){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ class ConstraintHelper{
|
|||||||
return [__FUNCTION__, $crewTypeID];
|
return [__FUNCTION__, $crewTypeID];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AvailableStrategicCommand():array{
|
static function AvailableStrategicCommand(int $allowTurnCnt=0):array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__, $allowTurnCnt];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function BattleGroundCity():array{
|
static function BattleGroundCity():array{
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class DiplomaticMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$commandObj->run();
|
$commandObj->run();
|
||||||
|
$commandObj->setNextAvailable();
|
||||||
|
|
||||||
return [self::ACCEPTED, ''];
|
return [self::ACCEPTED, ''];
|
||||||
}
|
}
|
||||||
@@ -110,6 +111,7 @@ class DiplomaticMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$commandObj->run();
|
$commandObj->run();
|
||||||
|
$commandObj->setNextAvailable();
|
||||||
|
|
||||||
return [self::ACCEPTED, ''];
|
return [self::ACCEPTED, ''];
|
||||||
}
|
}
|
||||||
@@ -131,6 +133,7 @@ class DiplomaticMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$commandObj->run();
|
$commandObj->run();
|
||||||
|
$commandObj->setNextAvailable();
|
||||||
|
|
||||||
return [self::ACCEPTED, ''];
|
return [self::ACCEPTED, ''];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,11 +321,11 @@ class GameConstBase
|
|||||||
'che_감축',
|
'che_감축',
|
||||||
],
|
],
|
||||||
'전략'=>[
|
'전략'=>[
|
||||||
|
'che_피장파장',
|
||||||
'che_필사즉생',
|
'che_필사즉생',
|
||||||
'che_백성동원',
|
'che_백성동원',
|
||||||
'che_수몰',
|
'che_수몰',
|
||||||
'che_허보',
|
'che_허보',
|
||||||
'che_피장파장',
|
|
||||||
'che_의병모집',
|
'che_의병모집',
|
||||||
'che_이호경식',
|
'che_이호경식',
|
||||||
'che_급습',
|
'che_급습',
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ class ResetHelper{
|
|||||||
$gameStor->resetValues();
|
$gameStor->resetValues();
|
||||||
$gameStor->next_season_idx = $seasonIdx;
|
$gameStor->next_season_idx = $seasonIdx;
|
||||||
|
|
||||||
|
$lastExecuteStor = KVStorage::getStorage($db, 'next_execute');
|
||||||
|
$lastExecuteStor->resetValues();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'serverID'=>$serverID,
|
'serverID'=>$serverID,
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class ScoutMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$commandObj->run();
|
$commandObj->run();
|
||||||
|
$commandObj->setNextAvailable();
|
||||||
|
|
||||||
//메시지 비 활성화
|
//메시지 비 활성화
|
||||||
$this->msgOption['used'] = true;
|
$this->msgOption['used'] = true;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class TurnExecutionHelper
|
|||||||
|
|
||||||
$result = $commandObj->run();
|
$result = $commandObj->run();
|
||||||
if($result){
|
if($result){
|
||||||
|
$commandObj->setNextAvailable();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ class TurnExecutionHelper
|
|||||||
|
|
||||||
$result = $commandObj->run();
|
$result = $commandObj->run();
|
||||||
if($result){
|
if($result){
|
||||||
|
$commandObj->setNextAvailable();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$alt = $commandObj->getAlternativeCommand();
|
$alt = $commandObj->getAlternativeCommand();
|
||||||
|
|||||||
Reference in New Issue
Block a user