feat: StaticEventHandler 처리기 추가

- 커맨드 종료 시점에 호출
  - pre, post 각각이 필요한지는 논의 필요
  - 일단 용도에 따라 pre, post 둘중에 하나만 처리
- eventType으로는 full qualified class name 사용
  - 꼭 그럴필요는 없지만, 커맨드에 한해서는 이렇게
This commit is contained in:
2024-09-18 14:54:11 +00:00
parent 04a7a34fcc
commit 477b77b59f
79 changed files with 227 additions and 77 deletions
+23
View File
@@ -457,6 +457,29 @@ function buildWarUnitTriggerClass(?string $type, WarUnit $unit, ?array $args = n
return $class->newInstanceArgs(array_merge([$unit], $args));
}
function getStaticEventClass(string $type){
static $basePath = __NAMESPACE__.'\\StaticEvent\\';
$classPath = ($basePath.$type);
if(class_exists($classPath)){
return $classPath;
}
throw new \InvalidArgumentException("{$type}은 StaticEvent가 아님");
}
function buildStaticEventClass(?string $type):BaseStaticEvent{
static $cache = [];
if(key_exists($type, $cache)){
return $cache[$type];
}
$class = getStaticEventClass($type);
$obj = new $class();
$cache[$type] = $obj;
return $obj;
}
function getGeneralPoolClass(string $type){
static $basePath = __NAMESPACE__.'\\GeneralPool\\';
$classPath = ($basePath.$type);
+1 -1
View File
@@ -7,5 +7,5 @@ abstract class BaseStaticEvent {
}
abstract function run(General $general, array $env, array $params): bool | string;
abstract function run(GeneralLite|General $general, null|GeneralLite|General $destGeneral, array $env, array $params): bool | string;
}
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
CityConst,
ActionLogger,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -96,6 +97,7 @@ class che_NPC능동 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
}
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
+2 -3
View File
@@ -12,8 +12,7 @@ use function sammo\tryUniqueItemLottery;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\StaticEventHandler;
class che_강행 extends Command\GeneralCommand
{
@@ -158,8 +157,8 @@ class che_강행 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
return true;
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
@@ -174,6 +175,7 @@ class che_거병 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -19,6 +19,7 @@ use function \sammo\getAllNationStaticInfo;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
use sammo\StaticEventHandler;
use function sammo\buildNationTypeClass;
use function sammo\genGenericUniqueRNGFromGeneral;
@@ -205,6 +206,7 @@ class che_건국 extends Command\GeneralCommand
$general->increaseInheritancePoint(InheritanceKey::unifier, 250);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general, static::$actionName), $general, '건국');
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -112,6 +113,7 @@ class che_견문 extends Command\GeneralCommand{
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -9,7 +9,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -178,6 +179,7 @@ class che_군량매매 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -95,6 +96,7 @@ class che_귀환 extends Command\GeneralCommand{
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -6,7 +6,8 @@ use \sammo\{
General,
ActionLogger,
LastTurn,
Command, GameConst
Command, GameConst,
StaticEventHandler
};
use function sammo\{
@@ -134,6 +135,7 @@ class che_기술연구 extends che_상업투자{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
@@ -126,6 +127,7 @@ class che_단련 extends Command\GeneralCommand{
$general->increaseVar($incStat, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -9,7 +9,8 @@ use \sammo\{
General,
LastTurn,
Command,
ScoutMessage
ScoutMessage,
StaticEventHandler
};
use function \sammo\getAllNationStaticInfo;
@@ -169,6 +170,7 @@ class che_등용 extends Command\GeneralCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -6,6 +6,7 @@ use \sammo\{
General,
GameConst,
Command,
StaticEventHandler,
};
use \sammo\Constraint\ConstraintHelper;
@@ -207,6 +208,7 @@ class che_등용수락 extends Command\GeneralCommand{
}
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destGeneral->applyDB($db);
@@ -22,8 +22,7 @@ use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use sammo\MustNotBeReachedException;
use sammo\StaticEventHandler;
class che_랜덤임관 extends Command\GeneralCommand
{
@@ -281,6 +280,7 @@ class che_랜덤임관 extends Command\GeneralCommand
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general, static::$actionName), $general, '랜덤 임관');
$general->applyDB($db);
@@ -8,7 +8,8 @@ use \sammo\{
GameConst,
LastTurn,
GameUnitConst,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -97,6 +98,7 @@ class che_모반시도 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$lordGeneral->applyDB($db);
@@ -18,6 +18,7 @@ use function \sammo\getAllNationStaticInfo;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\StaticEventHandler;
use function sammo\buildNationTypeClass;
use function sammo\genGenericUniqueRNGFromGeneral;
@@ -216,6 +217,7 @@ class che_무작위건국 extends Command\GeneralCommand
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general, static::$actionName), $general, '건국');
$general->applyDB($db);
@@ -8,7 +8,8 @@ use \sammo\{
GameConst,
LastTurn,
GameUnitConst,
Command
Command,
StaticEventHandler
};
use function \sammo\getDomesticExpLevelBonus;
@@ -148,6 +149,7 @@ class che_물자조달 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -124,6 +125,7 @@ class che_방랑 extends Command\GeneralCommand{
refreshNationStaticInfo();
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -11,7 +11,8 @@ use \sammo\{
GameConst,
GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -121,6 +122,7 @@ class che_사기진작 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -9,7 +9,8 @@ use \sammo\{
LastTurn,
GameUnitConst,
Command,
RandUtil
RandUtil,
StaticEventHandler
};
use function \sammo\getDomesticExpLevelBonus;
@@ -218,6 +219,7 @@ class che_상업투자 extends Command\GeneralCommand{
$general->increaseVar(static::$statKey.'_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -21,6 +21,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\GeneralQueryMode;
use sammo\Enums\InheritanceKey;
use sammo\StaticEventHandler;
class che_선양 extends Command\GeneralCommand
{
@@ -138,6 +139,7 @@ class che_선양 extends Command\GeneralCommand
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destGeneral->applyDB($db);
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -80,6 +81,7 @@ class che_소집해제 extends Command\GeneralCommand{
$general->addDedication($ded);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -13,8 +13,7 @@ use function sammo\getDexLevelList;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\ConstraintHelper;
use sammo\StaticEventHandler;
class che_숙련전환 extends Command\GeneralCommand
{
@@ -179,6 +178,7 @@ class che_숙련전환 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 2);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -69,6 +70,7 @@ class che_요양 extends Command\GeneralCommand{
$general->addDedication($ded);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
+3 -1
View File
@@ -4,7 +4,8 @@ namespace sammo\Command\General;
use \sammo\{
DB,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\ConstraintHelper;
@@ -75,6 +76,7 @@ class che_은퇴 extends Command\GeneralCommand{
$logger->pushGeneralActionLog("은퇴하였습니다. <1>$date</>");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2 -2
View File
@@ -12,8 +12,7 @@ use function sammo\tryUniqueItemLottery;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\StaticEventHandler;
class che_이동 extends Command\GeneralCommand
{
@@ -164,6 +163,7 @@ class che_이동 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -18,6 +18,7 @@ use function \sammo\pickGeneralFromPool;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\StaticEventHandler;
class che_인재탐색 extends Command\GeneralCommand
{
@@ -218,6 +219,7 @@ class che_인재탐색 extends Command\GeneralCommand
$general->increaseVar($incStat, 3);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
return true;
+3 -1
View File
@@ -9,7 +9,8 @@ use \sammo\{
GameConst,
LastTurn,
Command,
KVStorage
KVStorage,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -175,6 +176,7 @@ class che_임관 extends Command\GeneralCommand
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -14,7 +14,8 @@ use \sammo\{
GameUnitConst,
LastTurn,
Command,
KVStorage
KVStorage,
StaticEventHandler
};
use function \sammo\buildItemClass;
@@ -196,6 +197,7 @@ class che_장비매매 extends Command\GeneralCommand
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -9,7 +9,8 @@ use \sammo\{
LastTurn,
Command,
Json,
KVStorage
KVStorage,
StaticEventHandler
};
use function sammo\getAllNationStaticInfo;
@@ -170,6 +171,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -8,7 +8,8 @@ use \sammo\{
GameConst, GameUnitConst,
LastTurn,
Command,
MustNotBeReachedException
MustNotBeReachedException,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -121,6 +122,7 @@ class che_전투태세 extends Command\GeneralCommand{
$general->increaseVar('leadership_exp', 3);
$this->setResultTurn($turnResult);
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -103,6 +104,7 @@ class che_전투특기초기화 extends Command\GeneralCommand{
$logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\ConstraintHelper;
@@ -98,6 +99,7 @@ class che_접경귀환 extends Command\GeneralCommand{
//TODO: InstantAction일때에만 설정하지 않는게 나은데..
//$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -9,7 +9,8 @@ use \sammo\{
LastTurn,
GameUnitConst,
Command,
RandUtil
RandUtil,
StaticEventHandler
};
use function \sammo\getDomesticExpLevelBonus;
@@ -188,6 +189,7 @@ class che_정착장려 extends Command\GeneralCommand{
$general->increaseVar(static::$statKey.'_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
@@ -9,7 +9,8 @@ use \sammo\{
LastTurn,
GameUnitConst,
Command,
RandUtil
RandUtil,
StaticEventHandler
};
use function \sammo\getDomesticExpLevelBonus;
@@ -188,6 +189,7 @@ class che_주민선정 extends Command\GeneralCommand{
$general->increaseVar(static::$statKey.'_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -16,6 +16,7 @@ use \sammo\Command;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\GeneralQueryMode;
use sammo\StaticEventHandler;
use function sammo\tryUniqueItemLottery;
@@ -170,6 +171,7 @@ class che_증여 extends Command\GeneralCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -103,6 +104,7 @@ class che_집합 extends Command\GeneralCommand{
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -16,6 +16,7 @@ use function sammo\getTechLevel;
use \sammo\Constraint\ConstraintHelper;
use sammo\MustNotBeReachedException;
use sammo\StaticEventHandler;
class che_징병 extends Command\GeneralCommand
{
@@ -226,6 +227,7 @@ class che_징병 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->setAuxVar('armType', $reqCrewType->armType);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -16,6 +16,7 @@ use function \sammo\searchDistance;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use sammo\StaticEventHandler;
class che_첩보 extends Command\GeneralCommand
{
@@ -212,6 +213,7 @@ class che_첩보 extends Command\GeneralCommand
$general->addDedication($ded);
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->checkStatChange();
$general->applyDB($db);
+2
View File
@@ -22,6 +22,7 @@ use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use sammo\LiteHashDRBG;
use sammo\RandUtil;
use sammo\StaticEventHandler;
use sammo\UniqueConst;
class che_출병 extends Command\GeneralCommand
@@ -253,6 +254,7 @@ class che_출병 extends Command\GeneralCommand
processWar($warRngSeed, $general, $this->nation, $this->destCity);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -122,6 +123,7 @@ class che_하야 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
+2
View File
@@ -10,6 +10,7 @@ use \sammo\{
Command,
Json,
KVStorage,
StaticEventHandler,
TurnExecutionHelper
};
@@ -109,6 +110,7 @@ class che_해산 extends Command\GeneralCommand{
foreach($nationGenerals as $oldGeneral){
$oldGeneral->applyDB($db);
}
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
// 이벤트 핸들러 동작
+2
View File
@@ -14,6 +14,7 @@ use \sammo\Command;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\StaticEventHandler;
use function sammo\tryUniqueItemLottery;
@@ -146,6 +147,7 @@ class che_헌납 extends Command\GeneralCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -18,6 +18,7 @@ use sammo\CityConst;
use sammo\Enums\GeneralQueryMode;
use sammo\Enums\RankColumn;
use sammo\RandUtil;
use sammo\StaticEventHandler;
class che_화계 extends Command\GeneralCommand
{
@@ -332,6 +333,7 @@ class che_화계 extends Command\GeneralCommand
$general->increaseVar($statType . '_exp', 1);
$general->increaseRankVar(RankColumn::firenum, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->checkStatChange();
$general->applyDB($db);
+3 -1
View File
@@ -11,7 +11,8 @@ use \sammo\{
GameConst,
GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -122,6 +123,7 @@ class che_훈련 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -18,6 +18,7 @@ use function \sammo\getAllNationStaticInfo;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\StaticEventHandler;
use function sammo\buildNationTypeClass;
use function sammo\genGenericUniqueRNGFromGeneral;
@@ -201,6 +202,7 @@ class cr_건국 extends Command\GeneralCommand
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general, static::$actionName), $general, '건국');
$general->applyDB($db);
+3 -1
View File
@@ -7,7 +7,8 @@ use \sammo\{
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
Command,
StaticEventHandler
};
use function \sammo\tryUniqueItemLottery;
@@ -105,6 +106,7 @@ class cr_맹훈련 extends Command\GeneralCommand{
$general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general, static::$actionName), $general);
$general->applyDB($db);
+2
View File
@@ -6,6 +6,7 @@ use \sammo\Util;
use \sammo\JosaUtil;
use \sammo\LastTurn;
use \sammo\DB;
use sammo\StaticEventHandler;
class 휴식 extends Command\GeneralCommand{
static protected $actionName = '휴식';
@@ -39,6 +40,7 @@ class 휴식 extends Command\GeneralCommand{
$logger->pushGeneralActionLog("아무것도 실행하지 않았습니다. <1>$date</>");
$this->setResultTurn(new LastTurn());
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB(DB::db());
return true;
}
+3 -1
View File
@@ -12,7 +12,8 @@ use \sammo\{
MessageTarget,
Message,
CityConst,
CityHelper
CityHelper,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -201,6 +202,7 @@ class che_감축 extends Command\NationCommand{
$logger->pushGlobalHistoryLog("<M><b>【감축】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaUl} <M>감축</>하였습니다.");
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
$general->applyDB($db);
@@ -12,6 +12,7 @@ use function \sammo\GetNationColors;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\StaticEventHandler;
class che_국기변경 extends Command\NationCommand
{
@@ -136,6 +137,7 @@ class che_국기변경 extends Command\NationCommand
$logger->pushGlobalHistoryLog("<S><b>【국기변경】</b></><D><b>{$nationName}</b></>{$josaYiNation} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다.");
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
$general->applyDB($db);
return true;
@@ -21,6 +21,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
use sammo\StaticEventHandler;
class che_국호변경 extends Command\NationCommand
{
@@ -154,6 +155,7 @@ class che_국호변경 extends Command\NationCommand
$logger->pushGlobalHistoryLog("<S><b>【국호변경】</b></><D><b>{$nationName}</b></>{$josaYiNation} 국호를 <D><b>{$newNationName}</b></>{$josaRo} 변경합니다.");
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
$general->applyDB($db);
return true;
+2
View File
@@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\StaticEventHandler;
class che_급습 extends Command\NationCommand
{
@@ -191,6 +192,7 @@ class che_급습 extends Command\NationCommand
$db->update('diplomacy', [
'term' => $db->sqleval('`term` - %i', 3),
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
+2
View File
@@ -21,6 +21,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\GeneralQueryMode;
use sammo\Enums\MessageType;
use sammo\StaticEventHandler;
class che_몰수 extends Command\NationCommand
{
@@ -212,6 +213,7 @@ class che_몰수 extends Command\NationCommand
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게서 {$resName} <C>$amountText</>{$josaUl} 몰수했습니다. <1>$date</>");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destGeneral->applyDB($db);
@@ -20,6 +20,7 @@ use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
use sammo\Json;
use sammo\StaticEventHandler;
class che_무작위수도이전 extends Command\NationCommand
{
@@ -159,6 +160,7 @@ class che_무작위수도이전 extends Command\NationCommand
$logger->pushGlobalHistoryLog("<S><b>【무작위 수도 이전】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaRo} <M>수도 이전</>하였습니다.");
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
}
@@ -15,6 +15,7 @@ use \sammo\{
Command,
Json,
KVStorage,
StaticEventHandler,
StringUtil
};
@@ -255,6 +256,7 @@ class che_물자원조 extends Command\NationCommand
$general->addExperience(5);
$general->addDedication(5);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
+2
View File
@@ -14,6 +14,7 @@ use \sammo\{
GameUnitConst,
CityConst,
Command,
StaticEventHandler,
TimeUtil
};
@@ -167,6 +168,7 @@ class che_발령 extends Command\NationCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
$destGeneral->applyDB($db);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
return true;
}
@@ -15,7 +15,8 @@ use \sammo\{
Command,
MessageTarget,
Message,
CityConst
CityConst,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -164,6 +165,7 @@ class che_백성동원 extends Command\NationCommand
], 'nation=%i', $nationID);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -24,6 +24,7 @@ use sammo\Enums\GeneralQueryMode;
use sammo\Json;
use sammo\KVStorage;
use sammo\RandUtil;
use sammo\StaticEventHandler;
class che_불가침수락 extends Command\NationCommand
{
@@ -224,6 +225,7 @@ class che_불가침수락 extends Command\NationCommand
$destLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaWa} <C>$year</>년 <C>{$month}</>월까지 불가침에 성공했습니다.", ActionLogger::PLAIN);
$destLogger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaWa} {$year}{$month}월까지 불가침 성공");
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destLogger->flush();
@@ -23,6 +23,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\MessageType;
use sammo\StaticEventHandler;
class che_불가침제의 extends Command\NationCommand
{
@@ -220,6 +221,7 @@ class che_불가침제의 extends Command\NationCommand
$msg->send();
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destLogger->flush();
@@ -22,6 +22,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\GeneralQueryMode;
use sammo\RandUtil;
use sammo\StaticEventHandler;
class che_불가침파기수락 extends Command\NationCommand
{
@@ -173,6 +174,7 @@ class che_불가침파기수락 extends Command\NationCommand
$destLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaWa}의 불가침 파기에 성공했습니다.", ActionLogger::PLAIN);
$destLogger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaWa}의 불가침 파기 성공");
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destLogger->flush();
@@ -12,6 +12,7 @@ use \sammo\{
MessageTarget,
DiplomaticMessage,
Message,
StaticEventHandler,
};
use function \sammo\getAllNationStaticInfo;
@@ -166,6 +167,7 @@ class che_불가침파기제의 extends Command\NationCommand{
$msg->send();
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destLogger->flush();
@@ -22,6 +22,7 @@ use function \sammo\GetImageURL;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\MessageType;
use sammo\StaticEventHandler;
class che_선전포고 extends Command\NationCommand
{
@@ -188,6 +189,7 @@ class che_선전포고 extends Command\NationCommand
$msg->send();
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destLogger->flush();
+3 -1
View File
@@ -15,7 +15,8 @@ use \sammo\{
Command,
MessageTarget,
Message,
CityConst
CityConst,
StaticEventHandler
};
use function \sammo\getNationStaticInfo;
@@ -191,6 +192,7 @@ class che_수몰 extends Command\NationCommand
], 'nation=%i', $nationID);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -15,7 +15,7 @@ use \sammo\KVStorage;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\StaticEventHandler;
class che_의병모집 extends Command\NationCommand
{
@@ -170,6 +170,7 @@ class che_의병모집 extends Command\NationCommand
], 'nation=%i', $nationID);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\StaticEventHandler;
class che_이호경식 extends Command\NationCommand
{
@@ -193,6 +194,7 @@ class che_이호경식 extends Command\NationCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -16,6 +16,7 @@ use \sammo\{
MessageTarget,
DiplomaticMessage,
Message,
StaticEventHandler,
};
use function \sammo\getNationStaticInfo;
@@ -188,6 +189,7 @@ class che_종전수락 extends Command\NationCommand
$destLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaWa} 종전");
$general->applyDB($db);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$destLogger->flush();
return true;
@@ -12,6 +12,7 @@ use \sammo\{
MessageTarget,
DiplomaticMessage,
Message,
StaticEventHandler,
};
use function \sammo\getAllNationStaticInfo;
@@ -164,6 +165,7 @@ class che_종전제의 extends Command\NationCommand{
$msg->send();
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destLogger->flush();
+3 -1
View File
@@ -11,7 +11,8 @@ use \sammo\{
Command,
MessageTarget,
Message,
CityConst
CityConst,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -193,6 +194,7 @@ class che_증축 extends Command\NationCommand{
$logger->pushGlobalHistoryLog("<C><b>【증축】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaUl} <M>증축</>하였습니다.");
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
+2
View File
@@ -19,6 +19,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
use sammo\StaticEventHandler;
class che_천도 extends Command\NationCommand
{
@@ -228,6 +229,7 @@ class che_천도 extends Command\NationCommand
$logger->pushGlobalHistoryLog("<S><b>【천도】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaRo} <M>천도</>하였습니다.");
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
}
+3 -1
View File
@@ -12,7 +12,8 @@ use \sammo\{
MessageTarget,
Message,
CityConst,
CityInitialDetail
CityInitialDetail,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -196,6 +197,7 @@ class che_초토화 extends Command\NationCommand{
$logger->pushGlobalHistoryLog("<S><b>【초토화】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</>하였습니다.");
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
}
+2
View File
@@ -16,6 +16,7 @@ use \sammo\Command;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\GeneralQueryMode;
use sammo\StaticEventHandler;
class che_포상 extends Command\NationCommand
{
@@ -174,6 +175,7 @@ class che_포상 extends Command\NationCommand
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게 {$resName} <C>$amountText</>{$josaUl} 수여했습니다. <1>$date</>");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
$destGeneral->applyDB($db);
@@ -15,7 +15,8 @@ use \sammo\{
Command,
KVStorage,
Message,
MessageTarget
MessageTarget,
StaticEventHandler
};
use function \sammo\buildNationCommandClass;
@@ -240,6 +241,7 @@ class che_피장파장 extends Command\NationCommand
$destDelay = max($destNationStor->getValue($cmd->getNextExecuteKey()) ?? 0, $yearMonth);
$destNationStor->setValue($cmd->getNextExecuteKey(), $destDelay + static::$delayCnt);
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -10,7 +10,8 @@ use \sammo\{
GameUnitConst,
Command,
MessageTarget,
Message
Message,
StaticEventHandler
};
use \sammo\Constraint\Constraint;
@@ -121,6 +122,7 @@ class che_필사즉생 extends Command\NationCommand{
], 'nation=%i', $nationID);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
+2
View File
@@ -21,6 +21,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Event\Action;
use sammo\StaticEventHandler;
class che_허보 extends Command\NationCommand
{
@@ -194,6 +195,7 @@ class che_허보 extends Command\NationCommand
], 'nation=%i', $nationID);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
@@ -19,6 +19,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
use sammo\StaticEventHandler;
class cr_인구이동 extends Command\NationCommand
{
@@ -179,6 +180,7 @@ class cr_인구이동 extends Command\NationCommand
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaRo} 인구 <C>{$amount}</>명을 옮겼습니다. <1>$date</>");
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
$general->applyDB($db);
return true;
}
+2
View File
@@ -5,6 +5,7 @@ use \sammo\Command;
use \sammo\Util;
use \sammo\JosaUtil;
use sammo\LastTurn;
use sammo\StaticEventHandler;
class 휴식 extends Command\NationCommand{
static protected $actionName = '휴식';
@@ -33,6 +34,7 @@ class 휴식 extends Command\NationCommand{
public function run(\Sammo\RandUtil $rng):bool{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg);
return true;
}
}
@@ -12,17 +12,13 @@ use sammo\JosaUtil;
class event_부대발령즉시집합 extends \sammo\BaseStaticEvent
{
function run(General $general, array $env, array $params): bool | string
function run(GeneralLite|General $general, null|GeneralLite|General $destGeneral, array $env, array $params): bool | string
{
$destGeneralID = $params['destGeneralID'] ?? null;
if ($destGeneralID === null) {
return "destGeneralID is null";
}
if (!is_int($destGeneralID)) {
return "destGeneralID is not int";
if($destGeneral === null){
return "destGeneral is null";
}
$destCityID = $params['city'] ?? null;
$destCityID = $params['destCityID'] ?? null;
if ($destCityID === null) {
return "destCityID is null";
}
@@ -30,21 +26,11 @@ class event_부대발령즉시집합 extends \sammo\BaseStaticEvent
return "destCityID is not int";
}
$destGeneral = GeneralLite::createObjFromDB($destGeneralID, ['nation', 'city', 'troop'], GeneralLiteQueryMode::Core);
if ($destGeneral === null) {
return "destGeneral is null";
}
if($destGeneral->getID() !== $destGeneral->getVar('troop')){
//부대장 발령이 아니므로 무시
return true;
}
if($destGeneral->getCityID() === $destCityID){
//이미 제자리이므로 무시
return true;
}
if($destGeneral->getNationID() !== $general->getNationID()){
return "destGeneral is not same nation";
}
@@ -56,8 +42,7 @@ class event_부대발령즉시집합 extends \sammo\BaseStaticEvent
$troopID = $destGeneral->getID();
$troopName = $db->queryFirstField('SELECT name FROM troop WHERE troop_leader = %i', $troopID);
$generalList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city!=%i AND troop=%i AND no!=%i', $general->getNationID(), $destCityID, $troopID, $general->getID());
$generalList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city!=%i AND troop=%i AND no!=%i', $destGeneral->getNationID(), $destCityID, $troopID, $destGeneral->getID());
if($generalList){
$db->update('general', [
'city'=>$destCityID
@@ -69,9 +54,6 @@ class event_부대발령즉시집합 extends \sammo\BaseStaticEvent
$targetLogger->flush();
}
$general->setVar('city', $destGeneral->getCityID());
$general->applyDB(DB::db());
return true;
}
}
@@ -9,7 +9,7 @@ use sammo\GeneralLite;
class event_부대탑승즉시이동 extends \sammo\BaseStaticEvent
{
function run(General $general, array $env, array $params): bool | string
function run(GeneralLite|General $general, null|GeneralLite|General $destGeneral, array $env, array $params): bool | string
{
$troopID = $params['troopID'] ?? null;
+14 -7
View File
@@ -1,18 +1,25 @@
<?php
namespace sammo;
class StaticEventHandler {
class StaticEventHandler
{
// This is a static class, so we don't want to instantiate it
public function __construct() {
public function __construct()
{
throw new \Exception('This is a static class');
}
public static function handleEvent(General $general, string $eventType, array ...$params): void {
$handlersList = GameConst::$staticEventHandlers[ $eventType ] ?? null;
if( $handlersList === null ) {
public static function handleEvent(General|GeneralLite $general, null|General|GeneralLite $destGeneral, string $eventType, array $env, array ...$params): void
{
$handlersList = GameConst::$staticEventHandlers[$eventType] ?? null;
if ($handlersList === null) {
return;
}
foreach ($handlersList as $handlerName) {
$handler = buildStaticEventClass($handlerName);
$handler->run($general, $destGeneral, $env, ...$params);
}
}
}
}