diff --git a/hwe/sammo/Command/General/che_임관.php b/hwe/sammo/Command/General/che_임관.php index d31ac729..156999fc 100644 --- a/hwe/sammo/Command/General/che_임관.php +++ b/hwe/sammo/Command/General/che_임관.php @@ -1,11 +1,15 @@ arg === null){ + protected function argTest(): bool + { + if ($this->arg === null) { return false; } - $destNationID = $this->arg['destNationID']??null; + $destNationID = $this->arg['destNationID'] ?? null; - if($destNationID === null){ + if ($destNationID === null) { return false; } - if(!is_int($destNationID)){ + if (!is_int($destNationID)) { return false; } - if($destNationID < 1){ + if ($destNationID < 1) { return false; } @@ -50,7 +56,8 @@ class che_임관 extends Command\GeneralCommand{ return true; } - protected function init(){ + protected function init() + { $general = $this->generalObj; $env = $this->env; @@ -60,23 +67,24 @@ class che_임관 extends Command\GeneralCommand{ $relYear = $env['year'] - $env['startyear']; - $this->permissionConstraints=[ + $this->permissionConstraints = [ ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다') ]; - $this->minConditionConstraints=[ + $this->minConditionConstraints = [ ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'), ConstraintHelper::BeNeutral(), ConstraintHelper::AllowJoinAction() ]; - } - public function getCommandDetailTitle():string{ + public function getCommandDetailTitle(): string + { return '지정한 국가로 임관'; } - public function canDisplay():bool{ + public function canDisplay(): bool + { return $this->env['join_mode'] !== 'onlyRandom'; } @@ -87,7 +95,7 @@ class che_임관 extends Command\GeneralCommand{ $env = $this->env; $relYear = $env['year'] - $env['startyear']; - $this->fullConditionConstraints=[ + $this->fullConditionConstraints = [ ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'), ConstraintHelper::BeNeutral(), ConstraintHelper::ExistsDestNation(), @@ -96,27 +104,32 @@ class che_임관 extends Command\GeneralCommand{ ]; } - public function getCost():array{ + public function getCost(): array + { return [0, 0]; } - public function getPreReqTurn():int{ + public function getPreReqTurn(): int + { return 0; } - public function getPostReqTurn():int{ + public function getPostReqTurn(): int + { return 0; } - public function getBrief():string{ + public function getBrief(): string + { $commandName = $this->getName(); $destNationName = getNationStaticInfo($this->arg['destNationID'])['name']; $josaRo = JosaUtil::pick($destNationName, '로'); return "【{$destNationName}】{$josaRo} {$commandName}"; } - public function run():bool{ - if(!$this->hasFullConditionMet()){ + public function run(): bool + { + if (!$this->hasFullConditionMet()) { throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); } @@ -139,10 +152,9 @@ class che_임관 extends Command\GeneralCommand{ $logger->pushGeneralHistoryLog("{$destNationName}에 임관"); $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$destNationName}임관했습니다."); - if($gennum < GameConst::$initialNationGenLimit) { + if ($gennum < GameConst::$initialNationGenLimit) { $exp = 700; - } - else { + } else { $exp = 100; } @@ -151,22 +163,21 @@ class che_임관 extends Command\GeneralCommand{ $general->setVar('officer_city', 0); $general->setVar('belong', 1); - if($this->destGeneralObj !== null){ + if ($this->destGeneralObj !== null) { $general->setVar('city', $this->destGeneralObj->getCityID()); - } - else{ + } else { $targetCityID = $db->queryFirstField('SELECT city FROM general WHERE nation = %i AND officer_level=12', $destNationID); $general->setVar('city', $targetCityID); } $db->update('nation', [ - 'gennum'=>$db->sqleval('gennum + 1') + 'gennum' => $db->sqleval('gennum + 1') ], 'nation=%i', $destNationID); \sammo\refreshNationStaticInfo(); $relYear = $env['year'] - $env['startyear']; - if($general->getNPCType() == 1 || $relYear >= 3){ - $joinedNations = $general->getAuxVar('joinedNations')??[]; + if ($general->getNPCType() == 1 || $relYear >= 3) { + $joinedNations = $general->getAuxVar('joinedNations') ?? []; $joinedNations[] = $destNationID; $general->setAuxVar('joinedNations', $joinedNations); } @@ -181,64 +192,43 @@ class che_임관 extends Command\GeneralCommand{ return true; } - public function getForm(): string + public function exportJSVars(): array { + $generalObj = $this->generalObj; + $nationID = $generalObj->getNationID(); + $testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn()); $db = DB::db(); - $generalObj = $this->generalObj; - - $env = $this->env; - - $joinedNations = $generalObj->getAuxVar('joinedNations')??[]; - - $nationList = $db->query('SELECT nation,`name`,color,scout,gennum FROM nation'); - shuffle($nationList); - $nationList = Util::convertArrayToDict($nationList, 'nation'); - //NOTE: join 안할것임 + $rawNationList = Util::convertArrayToDict($db->query('SELECT nation,`name`,color,gennum,`power` FROM nation'), 'nation'); $scoutMsgs = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'scout_msg'); - foreach($scoutMsgs as $nationID=>$scoutMsg){ - $nationList[$nationID]['scoutmsg'] = $scoutMsg; + foreach ($scoutMsgs as $nationID => $scoutMsg) { + $rawNationList[$nationID]['scoutmsg'] = $scoutMsg; } + foreach ($rawNationList as $destNation) { + $testCommand = new static($generalObj, $this->env, ['destNationID' => $destNation['nation']]); - $hiddenItems = []; - - foreach($nationList as &$nation){ - if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){ - $nation['availableJoin'] = false; + $nationTarget = [ + 'id' => $destNation['nation'], + 'name' => $destNation['name'], + 'color' => $destNation['color'], + 'power' => $destNation['power'], + 'scoutMsg' => $destNation['scoutmsg'] ?? ' ', + ]; + if (!$testCommand->hasFullConditionMet()) { + $nationTarget['notAvailable'] = true; } - else if($nation['scout'] == 1) { - $nation['availableJoin'] = false; - } - else{ - $nation['availableJoin'] = true; + if ($destNation['id'] == $nationID) { + $nationTarget['notAvailable'] = true; } - if(in_array($nation['nation'], $joinedNations)){ - $nation['availableJoin'] = false; - } - - if(Util::starts_with($nation['name'], 'ⓤ')){ - $hiddenItems[$nation['nation']] = $nation['nation']; - } + $nationList[] = $nationTarget; } - unset($nation); - ob_start(); -?> -국가에 임관합니다.
-이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.
-바로 군주의 위치로 이동합니다.
-임관할 국가를 목록에서 선택하세요.
- - - \sammo\getMapTheme(), + 'procRes' => [ + 'nations' => $nationList, + 'startYear' => $this->env['startyear'], + ], + ]; } -} \ No newline at end of file +} diff --git a/hwe/sammo/Command/Nation/che_급습.php b/hwe/sammo/Command/Nation/che_급습.php index f7daf847..14aaf13b 100644 --- a/hwe/sammo/Command/Nation/che_급습.php +++ b/hwe/sammo/Command/Nation/che_급습.php @@ -203,11 +203,6 @@ class che_급습 extends Command\NationCommand $nationList = []; $testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn()); foreach (getAllNationStaticInfo() as $destNation) { - /*if ($destNation['nation'] == $nationID) { - continue; - }*/ - - $testTurn->setArg(['destNationID' => $destNation['nation']]); $testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]); $nationTarget = [ @@ -219,7 +214,7 @@ class che_급습 extends Command\NationCommand if (!$testCommand->hasFullConditionMet()) { $nationTarget['notAvailable'] = true; } - if ($destNation['nation'] == $nationID) { + if ($destNation['id'] == $nationID) { $nationTarget['notAvailable'] = true; } diff --git a/hwe/sammo/Command/Nation/che_선전포고.php b/hwe/sammo/Command/Nation/che_선전포고.php index 2c127767..4da60c6f 100644 --- a/hwe/sammo/Command/Nation/che_선전포고.php +++ b/hwe/sammo/Command/Nation/che_선전포고.php @@ -200,10 +200,6 @@ class che_선전포고 extends Command\NationCommand $nationList = []; $testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn()); foreach (getAllNationStaticInfo() as $destNation) { - /*if ($destNation['nation'] == $nationID) { - continue; - }*/ - $testTurn->setArg(['destNationID' => $destNation['nation']]); $testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]); @@ -216,7 +212,7 @@ class che_선전포고 extends Command\NationCommand if (!$testCommand->hasFullConditionMet()) { $nationTarget['notAvailable'] = true; } - if ($destNation['nation'] == $nationID) { + if ($destNation['id'] == $nationID) { $nationTarget['notAvailable'] = true; } @@ -237,44 +233,4 @@ class che_선전포고 extends Command\NationCommand 'defaultSelectNationByMap' ]; } - - public function getForm(): string - { - $generalObj = $this->generalObj; - $nationID = $generalObj->getNationID(); - $startYear = $this->env['startyear']; - $availableYear = $startYear + 1; - $nationList = []; - foreach (getAllNationStaticInfo() as $destNation) { - if ($destNation['nation'] == $nationID) { - continue; - } - - $testCommand = new static($generalObj, $this->env, $this->getLastTurn(), ['destNationID' => $destNation['nation']]); - if ($testCommand->hasFullConditionMet()) { - $destNation['availableWar'] = true; - } else { - $destNation['availableWar'] = false; - } - - $nationList[] = $destNation; - } - - ob_start(); -?> -
- 타국에게 선전 포고합니다.
- 선전 포고할 국가를 목록에서 선택하세요.
- 고립되지 않은 아국 도시에서 인접한 국가에 선포 가능합니다.
- 초반제한 해제 2년전부터 선포가 가능합니다. (년 1월부터 가능)
- 현재 선포가 불가능한 국가는 배경색이 붉은색으로 표시됩니다.
- - - {{ props.option.title }} - ({{ props.option.info }})({{ props.option.info }}) {{ props.option.notAvailable ? "(불가)" : undefined }} diff --git a/hwe/ts/processing/General/che_임관.vue b/hwe/ts/processing/General/che_임관.vue new file mode 100644 index 00000000..1e2027ed --- /dev/null +++ b/hwe/ts/processing/General/che_임관.vue @@ -0,0 +1,137 @@ + + + + + \ No newline at end of file diff --git a/hwe/ts/processing/General/index.ts b/hwe/ts/processing/General/index.ts index 5e6f76df..7782cb51 100644 --- a/hwe/ts/processing/General/index.ts +++ b/hwe/ts/processing/General/index.ts @@ -1,8 +1,9 @@ -import { default as che_건국} from "./che_건국.vue"; -import { default as che_군량매매} from "./che_군량매매.vue"; -import { default as che_등용} from "./che_등용.vue"; -import { default as CityProcess} from "./che_이동.vue"; -import { default as che_징병} from "./che_징병.vue"; +import { default as che_건국 } from "./che_건국.vue"; +import { default as che_군량매매 } from "./che_군량매매.vue"; +import { default as che_등용 } from "./che_등용.vue"; +import { default as CityProcess } from "./che_이동.vue"; +import { default as che_임관 } from "./che_임관.vue"; +import { default as che_징병 } from "./che_징병.vue"; //TODO: 자주 쓰는 녀석들은 Slot으로 변경 @@ -12,6 +13,7 @@ export const commandMap: Record = { che_건국, che_등용, che_이동: CityProcess, + che_임관, che_출병: CityProcess, che_징병, che_모병: che_징병, diff --git a/hwe/ts/processing/NationSelect.vue b/hwe/ts/processing/NationSelect.vue index c1664bfd..2a34da9f 100644 --- a/hwe/ts/processing/NationSelect.vue +++ b/hwe/ts/processing/NationSelect.vue @@ -28,7 +28,14 @@ diff --git a/hwe/ts/processing/processingRes.ts b/hwe/ts/processing/processingRes.ts index 691ff846..9361807c 100644 --- a/hwe/ts/processing/processingRes.ts +++ b/hwe/ts/processing/processingRes.ts @@ -43,6 +43,7 @@ export type procNationItem = { name: string, color: string, power: number, + scoutMsg?: string, info?: string, notAvailable?: boolean, }; diff --git a/hwe/v_processing.php b/hwe/v_processing.php index 1fd72a27..2365a36e 100644 --- a/hwe/v_processing.php +++ b/hwe/v_processing.php @@ -86,11 +86,6 @@ if (!$commandObj->hasPermissionToReserve()) { ])?> exportJSVars(), false) ?> -