필사즉생 구현
This commit is contained in:
@@ -4,7 +4,8 @@ namespace sammo\Command;
|
||||
use \sammo\{
|
||||
Util, JosaUtil, DB,
|
||||
General, GameConst,
|
||||
ActionLogger
|
||||
ActionLogger,
|
||||
LastTurn
|
||||
};
|
||||
|
||||
use function \sammo\getNationStaticInfo;
|
||||
@@ -124,7 +125,7 @@ abstract class BaseCommand{
|
||||
return;
|
||||
}
|
||||
|
||||
$defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital'];
|
||||
$defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital', 'gennum'];
|
||||
$args = array_unique(array_merge($defaultArgs, $args));
|
||||
if($args == $defaultArgs){
|
||||
$this->nation = $this->generalObj->getStaticNation();
|
||||
@@ -293,6 +294,41 @@ abstract class BaseCommand{
|
||||
|
||||
}
|
||||
|
||||
public function getTermString():string{
|
||||
$commandName = $this->getName();
|
||||
$term = $this->getResultTurn()->getTerm();
|
||||
$termMax = $this->getPreReqTurn() + 1;
|
||||
return "{$commandName} 수행중... ({$term}/{$termMax})";
|
||||
}
|
||||
|
||||
public function addTermStack():bool{
|
||||
if($this->getPreReqTurn() == 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
$lastTurn = $this->getLastTurn();
|
||||
$commandName = $this->getName();
|
||||
if($lastTurn->getCommand() != $commandName){
|
||||
$this->setResultTurn(new LastTurn(
|
||||
$commandName,
|
||||
$this->arg,
|
||||
1
|
||||
));
|
||||
return false;
|
||||
}
|
||||
|
||||
if($lastTurn->getTerm() < $this->getPreReqTurn()){
|
||||
$this->setResultTurn(new LastTurn(
|
||||
$commandName,
|
||||
$this->arg,
|
||||
$lastTurn->getTerm() + 1
|
||||
));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isReservable():bool{
|
||||
if($this->reservable !== null){
|
||||
return $this->reservable;
|
||||
@@ -344,4 +380,16 @@ abstract class BaseCommand{
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getLastTurn():LastTurn{
|
||||
return $this->generalObj->getLastTurn();
|
||||
}
|
||||
|
||||
public function setResultTurn(LastTurn $lastTurn){
|
||||
$this->generalObj->setResultTurn($lastTurn);
|
||||
}
|
||||
|
||||
public function getResultTurn():LastTurn{
|
||||
return $this->generalObj->getResultTurn();
|
||||
}
|
||||
}
|
||||
@@ -44,15 +44,9 @@ class che_방랑 extends Command\GeneralCommand{
|
||||
ConstraintHelper::BeLord(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::DisallowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||
0 => '방랑할 수 없는 외교상태입니다.',
|
||||
1 => '방랑할 수 없는 외교상태입니다.',
|
||||
3 => '방랑할 수 없는 외교상태입니다.',
|
||||
4 => '방랑할 수 없는 외교상태입니다.',
|
||||
5 => '방랑할 수 없는 외교상태입니다.',
|
||||
6 => '방랑할 수 없는 외교상태입니다.'
|
||||
]),
|
||||
//TODO:diplomacy status 상수화
|
||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||
2, 7
|
||||
], '방랑할 수 없는 외교상태입니다.'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ class che_몰수 extends Command\NationCommand{
|
||||
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}을 몰수 당했습니다.", ActionLogger::PLAIN);
|
||||
$logger->pushGeneralActionLog("{$destGeneral->getName()}에게서 {$resName} <C>$amountText</>을 몰수했습니다. <1>$date</>");
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->applyDB($db);
|
||||
$destGeneral->applyDB($db);
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class che_발령 extends Command\NationCommand{
|
||||
$destGeneral->getLogger()->pushGeneralActionLog("<Y>{$generalName}</>에 의해 <G><b>{$destCityName}</b></>{$josaRo} 발령됐습니다. <1>$date</>");
|
||||
$logger->pushGeneralActionLog("<Y>{$destGeneralName}</>{$josaUl} <G><b>{$destCityName}</b></>{$josaRo} 발령했습니다. <1>$date</>");
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->applyDB($db);
|
||||
$destGeneral->applyDB($db);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_불가침제의 extends Command\NationCommand{
|
||||
static protected $actionName = '불가침제의';
|
||||
static protected $actionName = '불가침 제의';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
@@ -206,7 +206,7 @@ class che_불가침제의 extends Command\NationCommand{
|
||||
);
|
||||
$msg->send();
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->applyDB($db);
|
||||
$destLogger->flush();
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ class che_선전포고 extends Command\NationCommand{
|
||||
);
|
||||
$msg->send();
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->applyDB($db);
|
||||
$destLogger->flush();
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class che_포상 extends Command\NationCommand{
|
||||
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} <C>{$amountText}</>을 포상으로 받았습니다.", ActionLogger::PLAIN);
|
||||
$logger->pushGeneralActionLog("{$destGeneral->getName()}에게 {$resName} <C>$amountText</>을 수여했습니다. <1>$date</>");
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->applyDB($db);
|
||||
$destGeneral->applyDB($db);
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
MessageTarget,
|
||||
Message
|
||||
};
|
||||
|
||||
use function \sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
GetImageURL
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Event\Action;
|
||||
|
||||
class che_필사즉생 extends Command\NationCommand{
|
||||
static protected $actionName = '필사즉생';
|
||||
static public $reqArg = false;
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
/*ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||
0
|
||||
], '전쟁중이 아닙니다.'),*/
|
||||
ConstraintHelper::ReqNationValue('strategic_cmd_limit', '전략기한', '==', 0, '전략기한이 남았습니다.')
|
||||
];
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$general = $this->generalObj;
|
||||
$generalID = $general->getID();
|
||||
$generalName = $general->getName();
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$nationID = $general->getNationID();
|
||||
$nationName = $this->nation['name'];
|
||||
|
||||
$logger = $general->getLogger();
|
||||
$logger->pushGeneralActionLog("필사즉생 발동! <1>$date</>");
|
||||
|
||||
$exp = 5 * ($this->getPreReqTurn() + 1);
|
||||
$ded = 5 * ($this->getPreReqTurn() + 1);
|
||||
|
||||
$exp = $general->onCalcStat($general, 'experience', $exp);
|
||||
$ded = $general->onCalcStat($general, 'dedication', $ded);
|
||||
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
|
||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
||||
|
||||
foreach($db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID) as $targetGeneralID){
|
||||
$targetGeneral = General::createGeneralObjFromDB($targetGeneralID, ['train', 'atmos'], 1);
|
||||
$targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||
if($targetGeneral->getVar('train') < 100){
|
||||
$targetGeneral->setVar('train', 100);
|
||||
}
|
||||
if($targetGeneral->getVar('atmos') < 100){
|
||||
$targetGeneral->setVar('atmos', 100);
|
||||
}
|
||||
|
||||
|
||||
$targetGeneral->applyDB($db);
|
||||
}
|
||||
|
||||
if($general->getVar('train') < 100){
|
||||
$general->setVar('train', 100);
|
||||
}
|
||||
if($general->getVar('atmos') < 100){
|
||||
$general->setVar('atmos', 100);
|
||||
}
|
||||
$logger->pushGeneralHistoryLog('<M>필사즉생</>을 발동');
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동");
|
||||
|
||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||
$nextTerm = Util::round(sqrt($genCount*8)*10);
|
||||
|
||||
$nextTerm = $general->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||
$db->update('nation', ['strategic_cmd_limit' => $nextTerm], 'nation=%i', $nationID);
|
||||
|
||||
$general->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user