game: cr_건국,맹훈련,인구이동 추가
- 특수 맵 커맨드에 맞춤 - 건국: 소,중성 제한 없음 - 맹훈련: 훈련/사기진작의 2/3를 동시에 - 인구이동: 도시의 인구를 다른 곳으로 이동
This commit is contained in:
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\DB;
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
use \sammo\General;
|
||||
use \sammo\ActionLogger;
|
||||
use \sammo\GameConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\LastTurn;
|
||||
use \sammo\Command;
|
||||
use \sammo\Json;
|
||||
|
||||
use function \sammo\tryUniqueItemLottery;
|
||||
use function \sammo\getAllNationStaticInfo;
|
||||
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
|
||||
use function sammo\buildNationTypeClass;
|
||||
use function sammo\genGenericUniqueRNGFromGeneral;
|
||||
use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
|
||||
|
||||
class cr_건국 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '건국';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
$nationName = $this->arg['nationName'] ?? null;
|
||||
$nationType = $this->arg['nationType'] ?? null;
|
||||
$colorType = $this->arg['colorType'] ?? null;
|
||||
|
||||
if ($nationName === null || $nationType === null || $colorType === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_string($nationName) || !is_string($nationType) || !is_int($colorType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mb_strwidth($nationName) > 18 || $nationName == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!key_exists($colorType, GetNationColors())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$nationTypeClass = buildNationTypeClass($nationType);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->arg = [
|
||||
'nationName' => $nationName,
|
||||
'nationType' => $nationType,
|
||||
'colorType' => $colorType
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gennum', 'aux']);
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::BeOpeningPart($relYear + 1),
|
||||
ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.')
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$nationName = $this->arg['nationName'];
|
||||
$nationType = $this->arg['nationType'];
|
||||
$colorType = $this->arg['colorType'];
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeLord(),
|
||||
ConstraintHelper::WanderingNation(),
|
||||
ConstraintHelper::ReqNationValue('gennum', '수하 장수', '>=', 2),
|
||||
ConstraintHelper::BeOpeningPart($relYear + 1),
|
||||
ConstraintHelper::CheckNationNameDuplicate($nationName),
|
||||
ConstraintHelper::AllowJoinAction(),
|
||||
ConstraintHelper::NeutralCity(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getBrief(): string
|
||||
{
|
||||
$nationName = $this->arg['nationName'];
|
||||
$josaUl = JosaUtil::pick($nationName, '을');
|
||||
return "【{$nationName}】{$josaUl} 건국";
|
||||
}
|
||||
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
$generalName = $general->getName();
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$initYearMonth = Util::joinYearMonth($env['init_year'], $env['init_month']);
|
||||
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
||||
if($yearMonth <= $initYearMonth){
|
||||
$logger->pushGeneralActionLog("다음 턴부터 건국할 수 있습니다. <1>$date</>");
|
||||
$this->alternative = new che_인재탐색($general, $this->env, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
|
||||
$nationName = $this->arg['nationName'];
|
||||
$nationType = $this->arg['nationType'];
|
||||
$colorType = GetNationColors()[$this->arg['colorType']];
|
||||
|
||||
$cityName = $this->city['name'];
|
||||
|
||||
$josaUl = JosaUtil::pick($nationName, '을');
|
||||
|
||||
|
||||
|
||||
$nationTypeClass = buildNationTypeClass($nationType);
|
||||
$nationTypeName = $nationTypeClass->getName();
|
||||
|
||||
|
||||
$logger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaUl} 건국하였습니다. <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$cityName}</b></>에 국가를 건설하였습니다.");
|
||||
|
||||
$josaNationYi = JosaUtil::pick($nationName, '이');
|
||||
$logger->pushGlobalHistoryLog("<Y><b>【건국】</b></>{$nationTypeName} <D><b>{$nationName}</b></>{$josaNationYi} 새로이 등장하였습니다.");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 건국");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>{$josaUl} 건국");
|
||||
|
||||
$exp = 1000;
|
||||
$ded = 1000;
|
||||
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
|
||||
$aux = Json::decode($this->nation['aux']) ?? [];
|
||||
$aux['can_국기변경'] = 1;
|
||||
|
||||
$db->update('city', [
|
||||
'nation' => $general->getNationID(),
|
||||
'conflict' => '{}'
|
||||
], 'city=%i', $general->getCityID());
|
||||
|
||||
$db->update('nation', [
|
||||
'name' => $nationName,
|
||||
'color' => $colorType,
|
||||
'level' => 1,
|
||||
'type' => $nationType,
|
||||
'capital' => $general->getCityID(),
|
||||
'aux' => Json::encode($aux)
|
||||
], 'nation=%i', $general->getNationID());
|
||||
|
||||
refreshNationStaticInfo();
|
||||
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general), $general, '건국');
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function exportJSVars(): array
|
||||
{
|
||||
$nationTypes = [];
|
||||
foreach (GameConst::$availableNationType as $nationType) {
|
||||
$nationClass = buildNationTypeClass($nationType);
|
||||
$nationTypes[$nationType] = [
|
||||
'type' => $nationType,
|
||||
'name' => $nationClass->getName(),
|
||||
'pros' => $nationClass::$pros,
|
||||
'cons' => $nationClass::$cons
|
||||
];
|
||||
}
|
||||
return [
|
||||
'procRes' => [
|
||||
'available건국' => count(getAllNationStaticInfo()) < $this->env['maxnation'],
|
||||
'nationTypes' => $nationTypes,
|
||||
'colors' => GetNationColors(),
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
|
||||
use function \sammo\tryUniqueItemLottery;
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
|
||||
class cr_맹훈련 extends Command\GeneralCommand{
|
||||
static protected $actionName = '맹훈련';
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
];
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
ConstraintHelper::ReqGeneralTrainMargin(GameConst::$maxTrainByCommand),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$title = "{$name}(통솔경험";
|
||||
if($reqGold > 0){
|
||||
$title .= ", 자금{$reqGold}";
|
||||
}
|
||||
if($reqRice > 0){
|
||||
$title .= ", 군량{$reqRice}";
|
||||
}
|
||||
$title .= ')';
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 500];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score = Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$trainDelta * 2 / 3);
|
||||
$scoreText = number_format($score, 0);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$logger->pushGeneralActionLog("훈련, 사기치가 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||
|
||||
$exp = 150;
|
||||
$ded = 100;
|
||||
|
||||
$general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand);
|
||||
$general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maxAtmosByCommand);
|
||||
|
||||
$general->addDex($general->getCrewTypeObj(), $score * 2, false);
|
||||
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use \sammo\DB;
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
use \sammo\General;
|
||||
use \sammo\DummyGeneral;
|
||||
use \sammo\ActionLogger;
|
||||
use \sammo\GameConst;
|
||||
use \sammo\LastTurn;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\Command;
|
||||
use \sammo\MessageTarget;
|
||||
use \sammo\Message;
|
||||
use \sammo\CityConst;
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\Event\Action;
|
||||
|
||||
class cr_인구이동 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '인구이동';
|
||||
static public $reqArg = true;
|
||||
|
||||
const AMOUNT_LIMIT = 100000; //그냥!
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!key_exists('destCityID', $this->arg)) {
|
||||
return false;
|
||||
}
|
||||
if (CityConst::byID($this->arg['destCityID']) === null) {
|
||||
return false;
|
||||
}
|
||||
$destCityID = $this->arg['destCityID'];
|
||||
|
||||
|
||||
if (!key_exists('amount', $this->arg)) {
|
||||
return false;
|
||||
}
|
||||
$amount = $this->arg['amount'];
|
||||
if (!is_numeric($amount)) {
|
||||
return false;
|
||||
}
|
||||
$amount = (int) $amount;
|
||||
if ($amount > static::AMOUNT_LIMIT){
|
||||
$amount = static::AMOUNT_LIMIT;
|
||||
}
|
||||
if ($amount < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->arg = [
|
||||
'destCityID' => $destCityID,
|
||||
'amount' => $amount,
|
||||
];
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gold', 'rice']);
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + 100),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotSameDestCity(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + 100),
|
||||
ConstraintHelper::OccupiedDestCity(),
|
||||
ConstraintHelper::NearCity(1),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::SuppliedDestCity(),
|
||||
ConstraintHelper::ReqNationGold(GameConst::$basegold + $reqGold),
|
||||
ConstraintHelper::ReqNationRice(GameConst::$baserice + $reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
|
||||
$amount = number_format($this->env['develcost']);
|
||||
|
||||
return "{$name}(금쌀 {$amount}×인구[만])";
|
||||
}
|
||||
|
||||
public function getCost(): array
|
||||
{
|
||||
$amount = Util::round($this->env['develcost'] * $this->arg['amount'] / 10000);
|
||||
|
||||
return [$amount, $amount];
|
||||
}
|
||||
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
$amount = number_format($this->arg['amount']);
|
||||
return "【{$destCityName}】{$josaRo} {$amount}명 {$commandName}";
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$srcCity = $this->city;
|
||||
$srcCityID = $srcCity['city'];
|
||||
|
||||
$destCity = $this->destCity;
|
||||
$destCityID = $destCity['city'];
|
||||
$destCityName = $destCity['name'];
|
||||
|
||||
$amount = $this->arg['amount'];
|
||||
$amount = Util::clamp($amount, null, $this->city['pop'] - GameConst::$minAvailableRecruitPop);
|
||||
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$general->addExperience(5);
|
||||
$general->addDedication(5);
|
||||
|
||||
$db->update('city', [
|
||||
'pop' => $db->sqleval('pop + %i', $amount),
|
||||
], 'city=%i', $destCityID);
|
||||
$db->update('city', [
|
||||
'pop' => $db->sqleval('pop - %i', $amount),
|
||||
], 'city=%i', $srcCityID);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$db->update('nation', [
|
||||
'gold' => $db->sqleval('gold - %i', $reqGold),
|
||||
'rice' => $db->sqleval('rice - %i', $reqRice),
|
||||
], 'nation=%i', $this->nation['nation']);
|
||||
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaRo} 인구 <C>{$amount}</>명을 옮겼습니다. <1>$date</>");
|
||||
|
||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function exportJSVars(): array
|
||||
{
|
||||
return [
|
||||
'procRes' => [
|
||||
'cities' => \sammo\JSOptionsForCities(),
|
||||
'distanceList' => \sammo\JSCitiesBasedOnDistance($this->generalObj->getCityID(), 1),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<TopBackBar :title="commandName" />
|
||||
<div v-if="!available건국" class="bg0">더 이상 건국은 불가능합니다.</div>
|
||||
<div v-else class="bg0">
|
||||
<div>현재 도시에서 나라를 세웁니다. 도시 규모의 제한이 없습니다.</div>
|
||||
<ul>
|
||||
<li v-for="nationType in nationTypes" :key="nationType.type" class="row">
|
||||
<div class="col-2 col-md-1">- {{ nationType.name }}</div>
|
||||
<div class="col-4 col-md-2">
|
||||
: <span style="color: cyan">{{ nationType.pros }}</span
|
||||
>,
|
||||
</div>
|
||||
<div class="col-4 col-md-2">
|
||||
<span style="color: magenta">{{ nationType.cons }}</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="row">
|
||||
<div class="col-4 col-md-2">국명 : <b-form-input v-model="destNationName" maxlength="18" /></div>
|
||||
<div class="col-3 col-md-2">색상 : <ColorSelect v-model="selectedColorID" :colors="colors" /></div>
|
||||
<div class="col-3 col-md-2">
|
||||
<label>성향 :</label>
|
||||
<b-form-select v-model="selectedNationType" :options="nationTypesOption" />
|
||||
</div>
|
||||
|
||||
<div class="col-2 col-md-2 d-grid">
|
||||
<b-button @click="submit">
|
||||
{{ commandName }}
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BottomBar :title="commandName" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
declare const staticValues: {
|
||||
commandName: string;
|
||||
};
|
||||
|
||||
declare const procRes: {
|
||||
available건국: boolean;
|
||||
colors: string[];
|
||||
nationTypes: procNationTypeList;
|
||||
};
|
||||
</script>
|
||||
<script setup lang="ts">
|
||||
import ColorSelect from "@/processing/SelectColor.vue";
|
||||
import { ref } from "vue";
|
||||
import { unwrap } from "@/util/unwrap";
|
||||
import type { Args } from "@/processing/args";
|
||||
import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import BottomBar from "@/components/BottomBar.vue";
|
||||
import type { procNationTypeList } from "../processingRes";
|
||||
|
||||
const commandName = staticValues.commandName;
|
||||
const { nationTypes, available건국, colors } = procRes;
|
||||
|
||||
const destNationName = ref("");
|
||||
const selectedColorID = ref(0);
|
||||
|
||||
const selectedNationType = ref(Object.values(procRes.nationTypes)[0].type);
|
||||
|
||||
async function submit(e: Event) {
|
||||
const event = new CustomEvent<Args>("customSubmit", {
|
||||
detail: {
|
||||
colorType: selectedColorID.value,
|
||||
nationName: destNationName.value,
|
||||
nationType: selectedNationType.value,
|
||||
},
|
||||
});
|
||||
unwrap(e.target).dispatchEvent(event);
|
||||
}
|
||||
|
||||
const nationTypesOption: { html: string; value: string }[] = [];
|
||||
for (const nationType of Object.values(procRes.nationTypes)) {
|
||||
nationTypesOption.push({
|
||||
html: nationType.name,
|
||||
value: nationType.type,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -9,6 +9,7 @@ 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 cr_건국 } from "./cr_건국.vue";
|
||||
|
||||
import { default as ProcessCity } from "../ProcessCity.vue";
|
||||
import { default as ProcessGeneralAmount } from "../ProcessGeneralAmount.vue";
|
||||
@@ -38,6 +39,7 @@ export const commandMap: Record<string, typeof ProcessCity> = {
|
||||
che_파괴: ProcessCity,
|
||||
che_화계: ProcessCity,
|
||||
che_헌납,
|
||||
cr_건국,
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<TopBackBar v-model:searchable="searchable" :title="commandName" type="chief" />
|
||||
<div v-if="asyncReady" class="bg0">
|
||||
<MapViewer
|
||||
v-if="map"
|
||||
v-model="selectedCityObj"
|
||||
:server-nick="serverNick"
|
||||
:serverID="serverID"
|
||||
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
|
||||
:mapData="map"
|
||||
:isDetailMap="false"
|
||||
:cityPosition="cityPosition"
|
||||
:formatCityInfo="formatCityInfoText"
|
||||
:image-path="imagePath"
|
||||
/>
|
||||
|
||||
<div>
|
||||
현재 도시의 인구를 인접 도시로 이동합니다.<br />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 col-md-4">
|
||||
도시 :
|
||||
<SelectCity v-model="selectedCityID" :cities="citiesMap" :searchable="searchable" />
|
||||
</div>
|
||||
<div class="col-6 col-md-4">
|
||||
금 :
|
||||
<SelectAmount
|
||||
v-model="amount"
|
||||
:amountGuide="amountGuide"
|
||||
:step="10"
|
||||
:maxAmount="maxAmount"
|
||||
:minAmount="minAmount"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-4 col-md-2 d-grid">
|
||||
<b-button variant="primary" @click="submit">
|
||||
{{ commandName }}
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BottomBar :title="commandName" type="chief" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
declare const staticValues: {
|
||||
serverNick: string;
|
||||
serverID: string;
|
||||
currentCity: number;
|
||||
commandName: string;
|
||||
};
|
||||
|
||||
declare const getCityPosition: () => CityPositionMap;
|
||||
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MapViewer, { type CityPositionMap, type MapCityParsed, type MapCityParsedRaw } from "@/components/MapViewer.vue";
|
||||
import SelectCity from "@/processing/SelectCity.vue";
|
||||
import SelectAmount from "@/processing/SelectAmount.vue";
|
||||
import { ref, watch, onMounted, provide } from "vue";
|
||||
import { unwrap } from "@/util/unwrap";
|
||||
import type { Args } from "@/processing/args";
|
||||
import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import BottomBar from "@/components/BottomBar.vue";
|
||||
import {
|
||||
getProcSearchable,
|
||||
} from "../processingRes";
|
||||
import type { MapResult } from '@/defs';
|
||||
import { SammoAPI } from '@/SammoAPI';
|
||||
import { getGameConstStore, type GameConstStore } from '@/GameConstStore';
|
||||
|
||||
const serverNick = staticValues.serverNick;
|
||||
const serverID = staticValues.serverID;
|
||||
|
||||
const cityPosition = getCityPosition();
|
||||
const formatCityInfoText = formatCityInfo;
|
||||
const imagePath = window.pathConfig.gameImage;
|
||||
|
||||
const asyncReady = ref<boolean>(false);
|
||||
const gameConstStore = ref<GameConstStore>();
|
||||
provide("gameConstStore", gameConstStore);
|
||||
const storeP = getGameConstStore().then((store) => {
|
||||
gameConstStore.value = store;
|
||||
});
|
||||
|
||||
void Promise.all([storeP]).then(() => {
|
||||
asyncReady.value = true;
|
||||
});
|
||||
|
||||
const amountGuide = [
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
30000,
|
||||
50000,
|
||||
100000,
|
||||
];
|
||||
const maxAmount = 100000;
|
||||
const minAmount = 100;
|
||||
const selectedCityID = ref(staticValues.currentCity);
|
||||
|
||||
const map = ref<MapResult>();
|
||||
const citiesMap = ref(
|
||||
new Map<
|
||||
number,
|
||||
{
|
||||
name: string;
|
||||
info?: string;
|
||||
}
|
||||
>()
|
||||
);
|
||||
watch(gameConstStore, (store)=>{
|
||||
if(!store){
|
||||
return;
|
||||
}
|
||||
const tmpCitiesMap = new Map<
|
||||
number,
|
||||
{
|
||||
name: string;
|
||||
info?: string;
|
||||
}
|
||||
>();
|
||||
|
||||
for(const city of Object.values(store.cityConst)){
|
||||
tmpCitiesMap.set(city.id, {
|
||||
name: city.name,
|
||||
});
|
||||
}
|
||||
citiesMap.value = tmpCitiesMap;
|
||||
})
|
||||
|
||||
async function submit(e: Event) {
|
||||
const event = new CustomEvent<Args>("customSubmit", {
|
||||
detail: {
|
||||
destCityID: selectedCityID.value,
|
||||
amount: amount.value,
|
||||
},
|
||||
});
|
||||
unwrap(e.target).dispatchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
const amount = ref(0);
|
||||
|
||||
const searchable = getProcSearchable();
|
||||
|
||||
const selectedCityObj = ref<MapCityParsed>();
|
||||
const commandName = ref(staticValues.commandName);
|
||||
|
||||
watch(selectedCityObj, (city?: MapCityParsed) => {
|
||||
if (city === undefined) {
|
||||
return;
|
||||
}
|
||||
selectedCityID.value = city.id;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
try{
|
||||
map.value = await SammoAPI.Global.GetMap({neutralView:0, showMe: 1});
|
||||
}
|
||||
catch(e){
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -4,6 +4,8 @@ import { default as che_물자원조 } from "./che_물자원조.vue";
|
||||
import { default as che_불가침제의 } from "./che_불가침제의.vue";
|
||||
import { default as che_피장파장 } from "./che_피장파장.vue";
|
||||
|
||||
import { default as cr_인구이동 } from "./cr_인구이동.vue";
|
||||
|
||||
import { default as ProcessNation } from "../ProcessNation.vue";
|
||||
import { default as ProcessGeneralAmount } from "../ProcessGeneralAmount.vue";
|
||||
import { default as ProcessGeneralCity } from "./che_발령.vue";
|
||||
@@ -28,6 +30,7 @@ export const commandMap: Record<string, typeof ProcessNation | typeof ProcessCit
|
||||
che_포상: ProcessGeneralAmount,
|
||||
che_피장파장,
|
||||
che_허보: ProcessCity,
|
||||
cr_인구이동,
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user