buildGeneralCommandClass류 구현
This commit is contained in:
@@ -5,8 +5,7 @@ function getGeneralTurnBrief(General $generalObj, array $turnList) {
|
||||
$result = [];
|
||||
|
||||
foreach($turnList as $turnIdx => [$action, $arg]){
|
||||
$commandClass = getGeneralCommandClass($action);
|
||||
$commandObj = new $commandClass($generalObj, [], $arg);
|
||||
$commandObj = buildGeneralCommandClass($action, $generalObj, [], $arg);
|
||||
$turnText = $commandObj->getBrief();
|
||||
$result[$turnIdx] = $turnText;
|
||||
}
|
||||
@@ -270,8 +269,7 @@ function getNationTurnBrief(General $generalObj, array $turnList) {
|
||||
|
||||
$tmpTurn = new LastTurn();
|
||||
foreach($turnList as $turnIdx => [$action, $arg]){
|
||||
$commandClass = getNationCommandClass($action);
|
||||
$commandObj = new $commandClass($generalObj, [], $tmpTurn, $arg);
|
||||
$commandObj = buildNationCommandClass($action, $generalObj, [], $tmpTurn, $arg);
|
||||
$turnText = $commandObj->getBrief();
|
||||
$result[$turnIdx] = $turnText;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ function getGeneralTurnBrief(General $generalObj, array $turnList) {
|
||||
$result = [];
|
||||
|
||||
foreach($turnList as $turnIdx => [$action, $arg]){
|
||||
$commandClass = getGeneralCommandClass($action);
|
||||
$commandObj = new $commandClass($generalObj, [], $arg);
|
||||
$commandObj = buildGeneralCommandClass($action, $generalObj, [], $arg);
|
||||
$turnText = $commandObj->getBrief();
|
||||
$result[$turnIdx] = $turnText;
|
||||
}
|
||||
@@ -18,8 +17,7 @@ function getNationTurnBrief(General $generalObj, array $turnList) {
|
||||
|
||||
$tmpTurn = new LastTurn();
|
||||
foreach($turnList as $turnIdx => [$action, $arg]){
|
||||
$commandClass = getNationCommandClass($action);
|
||||
$commandObj = new $commandClass($generalObj, [], $tmpTurn, $arg);
|
||||
$commandObj = buildNationCommandClass($action, $generalObj, [], $tmpTurn, $arg);
|
||||
$turnText = $commandObj->getBrief();
|
||||
$result[$turnIdx] = $turnText;
|
||||
}
|
||||
|
||||
@@ -313,6 +313,11 @@ function getGeneralCommandClass(?string $type){
|
||||
throw new \InvalidArgumentException("{$type}은 올바른 장수 커맨드가 아님");
|
||||
}
|
||||
|
||||
function buildGeneralCommandClass(?string $type, General $generalObj, array $env, $arg = null):Command\GeneralCommand{
|
||||
$class = getGeneralCommandClass($type);
|
||||
return new $class($generalObj, $env, $arg);
|
||||
}
|
||||
|
||||
function getNationCommandClass(?string $type){
|
||||
if($type === null){
|
||||
$type = '휴식';
|
||||
@@ -328,6 +333,11 @@ function getNationCommandClass(?string $type){
|
||||
throw new \InvalidArgumentException("{$type}은 올바른 국가 커맨드가 아님");
|
||||
}
|
||||
|
||||
function buildNationCommandClass(?string $type, General $generalObj, array $env, LastTurn $lastTurn, $arg = null):Command\NationCommand{
|
||||
$class = getNationCommandClass($type);
|
||||
return new $class($generalObj, $env, $lastTurn, $arg);
|
||||
}
|
||||
|
||||
function getLevel($level, $nlevel=8) {
|
||||
if($level >= 0 && $level <= 4) { $nlevel = 0; }
|
||||
$code = $nlevel * 100 + $level;
|
||||
|
||||
@@ -75,9 +75,7 @@ class TurnExecutionHelper
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$commandClass = getNationCommandClass($commandClassName);
|
||||
/** @var \sammo\Command\NationCommand $commandObj */
|
||||
$commandObj = new $commandClass($general, $gameStor->getAll(true), $commandLast, $commandArg);
|
||||
$commandObj = buildNationCommandClass($commandClassName, $general, $gameStor->getAll(true), $commandLast, $commandArg);
|
||||
|
||||
$failReason = $commandObj->testReservable();
|
||||
if($failReason){
|
||||
|
||||
Reference in New Issue
Block a user