feat(WIP): process 등용 등
- ColorSelect 색을 가득 채움, - ColorSelect 결과값을 둥글게 - procGeneralList의 column 가변형 정의 - 등용 brief 조사 처리 버그 수정
This commit is contained in:
@@ -185,23 +185,14 @@ class che_군량매매 extends Command\GeneralCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
public function exportJSVars(): array
|
||||||
{
|
{
|
||||||
ob_start();
|
return [
|
||||||
?>
|
'procRes' => [
|
||||||
자신의 군량을 사거나 팝니다.<br>
|
'minAmount' => 100,
|
||||||
<select id='buyRice' name="buyRice" size=1 style=color:white;background-color:black>
|
'maxAmount' => GameConst::$maxResourceActionAmount,
|
||||||
<option value='false'>팜</option>
|
'amountGuide' => GameConst::$resourceActionAmountGuide,
|
||||||
<option value='true'>삼</option>
|
]
|
||||||
</select>
|
];
|
||||||
<select name=amount id='amount' size=1 style=text-align:right;color:white;background-color:black>
|
|
||||||
<?php foreach(GameConst::$resourceActionAmountGuide as $amount): ?>
|
|
||||||
<option value='<?=$amount?>'><?=$amount?></option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
|
||||||
<?php
|
|
||||||
return ob_get_clean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB,
|
||||||
General, DummyGeneral,
|
Util,
|
||||||
|
JosaUtil,
|
||||||
|
General,
|
||||||
|
DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
@@ -21,30 +25,32 @@ use \sammo\Constraint\Constraint;
|
|||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_등용 extends Command\GeneralCommand{
|
class che_등용 extends Command\GeneralCommand
|
||||||
|
{
|
||||||
static protected $actionName = '등용';
|
static protected $actionName = '등용';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest(): bool
|
||||||
if($this->arg === null){
|
{
|
||||||
|
if ($this->arg === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//NOTE: 사망 직전에 '등용' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 사망 직전에 '등용' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
||||||
if(!key_exists('destGeneralID', $this->arg)){
|
if (!key_exists('destGeneralID', $this->arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destGeneralID = $this->arg['destGeneralID'];
|
$destGeneralID = $this->arg['destGeneralID'];
|
||||||
if(!is_int($destGeneralID)){
|
if (!is_int($destGeneralID)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($destGeneralID <= 0){
|
if ($destGeneralID <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($destGeneralID == $this->generalObj->getID()){
|
if ($destGeneralID == $this->generalObj->getID()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destGeneralID'=>$destGeneralID
|
'destGeneralID' => $destGeneralID
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -59,11 +65,11 @@ class che_등용 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||||
|
|
||||||
$this->permissionConstraints=[
|
$this->permissionConstraints = [
|
||||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
@@ -79,7 +85,7 @@ class che_등용 extends Command\GeneralCommand{
|
|||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
@@ -90,33 +96,37 @@ class che_등용 extends Command\GeneralCommand{
|
|||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->destGeneralObj->getVar('officer_level') == 12){
|
if ($this->destGeneralObj->getVar('officer_level') == 12) {
|
||||||
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
|
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canDisplay():bool{
|
public function canDisplay(): bool
|
||||||
|
{
|
||||||
return $this->env['join_mode'] !== 'onlyRandom';
|
return $this->env['join_mode'] !== 'onlyRandom';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost(): array
|
||||||
|
{
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
if(!$this->isArgValid){
|
if (!$this->isArgValid) {
|
||||||
return [$env['develcost'], 0];
|
return [$env['develcost'], 0];
|
||||||
}
|
}
|
||||||
$destGeneral = $this->destGeneralObj;
|
$destGeneral = $this->destGeneralObj;
|
||||||
$reqGold = Util::round(
|
$reqGold = Util::round(
|
||||||
$env['develcost'] +
|
$env['develcost'] +
|
||||||
($destGeneral->getVar('experience') + $destGeneral->getVar('dedication')) / 1000
|
($destGeneral->getVar('experience') + $destGeneral->getVar('dedication')) / 1000
|
||||||
) * 10;
|
) * 10;
|
||||||
return [$reqGold, 0];
|
return [$reqGold, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn(): int
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn(): int
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,12 +134,13 @@ class che_등용 extends Command\GeneralCommand{
|
|||||||
{
|
{
|
||||||
$destGeneralName = $this->destGeneralObj->getName();
|
$destGeneralName = $this->destGeneralObj->getName();
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$josaUl = JosaUtil::pick($name, '을');
|
$josaUl = JosaUtil::pick($destGeneralName, '을');
|
||||||
return "【{$destGeneralName}】{$josaUl} {$name}";
|
return "【{$destGeneralName}】{$josaUl} {$name}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run(): bool
|
||||||
if(!$this->hasFullConditionMet()){
|
{
|
||||||
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,11 +156,10 @@ class che_등용 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
|
|
||||||
$msg = ScoutMessage::buildScoutMessage($general->getID(), $destGeneralID, $reason, new \DateTime($general->getTurnTime()));
|
$msg = ScoutMessage::buildScoutMessage($general->getID(), $destGeneralID, $reason, new \DateTime($general->getTurnTime()));
|
||||||
if($msg){
|
if ($msg) {
|
||||||
$logger->pushGeneralActionLog("<Y>{$destGeneralName}</>에게 등용 권유 서신을 보냈습니다. <1>$date</>");
|
$logger->pushGeneralActionLog("<Y>{$destGeneralName}</>에게 등용 권유 서신을 보냈습니다. <1>$date</>");
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$logger->pushGeneralActionLog("<Y>{$destGeneralName}</>에게 등용 권유 서신을 보내지 못했습니다. {$reason} <1>$date</>");
|
$logger->pushGeneralActionLog("<Y>{$destGeneralName}</>에게 등용 권유 서신을 보내지 못했습니다. {$reason} <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,43 +182,27 @@ class che_등용 extends Command\GeneralCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
public function exportJSVars(): array
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$destRawGenerals = $db->queryAllLists('SELECT no,name,nation,officer_level,npc,leadership,strength,intel FROM general WHERE npc < 2 AND officer_level != 12 AND no != %i ORDER BY npc,binary(name)', $this->generalObj->getID());
|
||||||
|
$nationList = [];
|
||||||
|
|
||||||
$destGenerals = [];
|
foreach ([getNationStaticInfo(0), ...getAllNationStaticInfo()] as $destNation) {
|
||||||
$destRawGenerals = $db->query('SELECT no,name,npc,nation FROM general WHERE npc < 2 AND no != %i AND officer_level != 12 ORDER BY npc,binary(name)',$this->generalObj->getID());
|
$nationList[] = [
|
||||||
foreach($destRawGenerals as $destGeneral){
|
'id' => $destNation['nation'],
|
||||||
$destNationID = $destGeneral['nation'];
|
'name' => $destNation['name'],
|
||||||
if(!key_exists($destNationID, $destGenerals)){
|
'color' => $destNation['color'],
|
||||||
$destGenerals[$destNationID] = [];
|
'power' => $destNation['power'],
|
||||||
}
|
];
|
||||||
$destGenerals[$destNationID][] = $destGeneral;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nationList = array_merge([0=>getNationStaticInfo(0)], getAllNationStaticInfo());
|
return [
|
||||||
|
'procRes' => [
|
||||||
ob_start();
|
'nationList' => $nationList,
|
||||||
?>
|
'generals' => $destRawGenerals,
|
||||||
재야나 타국의 장수를 등용합니다.<br>
|
'generalsKey' => ['no', 'name', 'nationID', 'officerLevel', 'npc', 'leadership', 'strength', 'intel']
|
||||||
서신은 개인 메세지로 전달됩니다.<br>
|
]
|
||||||
등용할 장수를 목록에서 선택하세요.<br>
|
];
|
||||||
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
|
|
||||||
<?php foreach($nationList as $destNation): ?>
|
|
||||||
<optgroup style='background-color:<?=$destNation['color']?>;color:<?=newColor($destNation['color'])?>;' label="【<?=$destNation['name']?>】" >
|
|
||||||
<?php foreach($destGenerals[$destNation['nation']]??[] as $destGeneral):
|
|
||||||
$nameColor = \sammo\getNameColor($destGeneral['npc']);
|
|
||||||
if($nameColor){
|
|
||||||
$nameColor = " style='color:{$nameColor}'";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option style="background-color:black;color:white" value='<?=$destGeneral['no']?>' <?=$nameColor?>><?=$destGeneral['name']?></option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</optgroup>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
|
||||||
<?php
|
|
||||||
return ob_get_clean();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<div
|
<div
|
||||||
class="sam-nation-own-bgcolor"
|
class="sam-nation-own-bgcolor"
|
||||||
:style="{
|
:style="{
|
||||||
padding: '0.375rem 0.75rem',
|
padding: '0.545rem 0.75rem',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{ props.option.title }}
|
{{ props.option.title }}
|
||||||
@@ -37,12 +37,13 @@
|
|||||||
<div
|
<div
|
||||||
:class="`sam-color-${props.option.title.slice(1)}`"
|
:class="`sam-color-${props.option.title.slice(1)}`"
|
||||||
:style="{
|
:style="{
|
||||||
margin: '-0.375rem -0.75rem',
|
margin: '-0.25rem -0.75rem',
|
||||||
}"
|
}"
|
||||||
><div
|
><div
|
||||||
class="sam-nation-own-bgcolor"
|
class="sam-nation-own-bgcolor"
|
||||||
:style="{
|
:style="{
|
||||||
padding: '0.375rem 0.75rem',
|
padding: '0.30rem 0.75rem',
|
||||||
|
borderRadius: '0.25rem',
|
||||||
}"
|
}"
|
||||||
>{{ props.option.title }}</div
|
>{{ props.option.title }}</div
|
||||||
></div
|
></div
|
||||||
@@ -102,9 +103,3 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.multiselect__option {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<template>
|
||||||
|
<TopBackBar :title="commandName" type="chief" />
|
||||||
|
<div class="bg0">
|
||||||
|
<div>
|
||||||
|
자신의 군량을 사거나 팝니다.<br />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2 col-md-1">
|
||||||
|
군량을 :
|
||||||
|
<b-button-group>
|
||||||
|
<b-button :pressed="buyRice" @click="buyRice=true">삼</b-button>
|
||||||
|
<b-button :pressed="!buyRice" @click="buyRice=false">팜</b-button>
|
||||||
|
</b-button-group>
|
||||||
|
</div>
|
||||||
|
<div class="col-10 col-md-4">
|
||||||
|
금액 :
|
||||||
|
<AmountSelect
|
||||||
|
:amountGuide="amountGuide"
|
||||||
|
v-model="amount"
|
||||||
|
: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" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import AmountSelect from "@/processing/AmountSelect.vue";
|
||||||
|
import { defineComponent, ref } from "vue";
|
||||||
|
import { unwrap } from "@/util/unwrap";
|
||||||
|
import { Args } from "@/processing/args";
|
||||||
|
import TopBackBar from "@/components/TopBackBar.vue";
|
||||||
|
import BottomBar from "@/components/BottomBar.vue";
|
||||||
|
declare const commandName: string;
|
||||||
|
|
||||||
|
declare const procRes: {
|
||||||
|
minAmount: number;
|
||||||
|
maxAmount: number;
|
||||||
|
amountGuide: number[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
components: {
|
||||||
|
AmountSelect,
|
||||||
|
TopBackBar,
|
||||||
|
BottomBar,
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const amount = ref(1000);
|
||||||
|
const buyRice = ref(true);
|
||||||
|
|
||||||
|
async function submit(e: Event) {
|
||||||
|
const event = new CustomEvent<Args>("customSubmit", {
|
||||||
|
detail: {
|
||||||
|
amount: amount.value,
|
||||||
|
buyRice: buyRice.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
unwrap(e.target).dispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
buyRice,
|
||||||
|
amount,
|
||||||
|
minAmount: ref(procRes.minAmount),
|
||||||
|
maxAmount: ref(procRes.maxAmount),
|
||||||
|
amountGuide: procRes.amountGuide,
|
||||||
|
commandName,
|
||||||
|
submit,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<template>
|
||||||
|
<TopBackBar :title="commandName" type="chief" />
|
||||||
|
<div class="bg0">
|
||||||
|
<div>
|
||||||
|
재야나 타국의 장수를 등용합니다.<br />
|
||||||
|
서신은 개인 메세지로 전달됩니다.<br />
|
||||||
|
등용할 장수를 목록에서 선택하세요.<br />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
장수 :
|
||||||
|
<GeneralSelect
|
||||||
|
:generals="generalList"
|
||||||
|
:groupByNation="nationList"
|
||||||
|
:textHelper="textHelpGeneral"
|
||||||
|
v-model="selectedGeneralID"
|
||||||
|
/>
|
||||||
|
</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" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import GeneralSelect from "@/processing/GeneralSelect.vue";
|
||||||
|
import { defineComponent, ref } from "vue";
|
||||||
|
import { unwrap } from "@/util/unwrap";
|
||||||
|
import { Args } from "@/processing/args";
|
||||||
|
import TopBackBar from "@/components/TopBackBar.vue";
|
||||||
|
import BottomBar from "@/components/BottomBar.vue";
|
||||||
|
import {
|
||||||
|
convertGeneralList,
|
||||||
|
procGeneralItem,
|
||||||
|
procGeneralKey,
|
||||||
|
procGeneralRawItemList,
|
||||||
|
procNationItem,
|
||||||
|
procNationList,
|
||||||
|
} from "../processingRes";
|
||||||
|
import { getNpcColor } from "@/common_legacy";
|
||||||
|
declare const mapTheme: string;
|
||||||
|
declare const commandName: string;
|
||||||
|
|
||||||
|
declare const procRes: {
|
||||||
|
generals: procGeneralRawItemList;
|
||||||
|
generalsKey: procGeneralKey[];
|
||||||
|
nationList: procNationList,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
components: {
|
||||||
|
GeneralSelect,
|
||||||
|
TopBackBar,
|
||||||
|
BottomBar,
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const generalList = convertGeneralList(
|
||||||
|
procRes.generalsKey,
|
||||||
|
procRes.generals
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectedGeneralID = ref(generalList[0].no);
|
||||||
|
|
||||||
|
function textHelpGeneral(gen: procGeneralItem): string {
|
||||||
|
const nameColor = getNpcColor(gen.npc);
|
||||||
|
const name = nameColor
|
||||||
|
? `<span style="color:${nameColor}">${gen.name}</span>`
|
||||||
|
: gen.name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submit(e: Event) {
|
||||||
|
const event = new CustomEvent<Args>("customSubmit", {
|
||||||
|
detail: {
|
||||||
|
destGeneralID: selectedGeneralID.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
unwrap(e.target).dispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
const nationList = new Map<number, procNationItem>();
|
||||||
|
for(const nationItem of procRes.nationList){
|
||||||
|
nationList.set(nationItem.id, nationItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
mapTheme: ref(mapTheme),
|
||||||
|
selectedGeneralID,
|
||||||
|
generalList,
|
||||||
|
nationList,
|
||||||
|
commandName,
|
||||||
|
textHelpGeneral,
|
||||||
|
submit,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
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 CityProcess} from "./che_이동.vue";
|
||||||
|
|
||||||
export const commandMap: Record<string, typeof CityProcess> = {
|
export const commandMap: Record<string, typeof CityProcess> = {
|
||||||
che_강행: CityProcess,
|
che_강행: CityProcess,
|
||||||
|
che_군량매매,
|
||||||
che_건국,
|
che_건국,
|
||||||
|
che_등용,
|
||||||
che_이동: CityProcess,
|
che_이동: CityProcess,
|
||||||
che_출병: CityProcess,
|
che_출병: CityProcess,
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
:allow-empty="false"
|
:allow-empty="false"
|
||||||
:options="forFind"
|
:options="forFind"
|
||||||
:group-select="false"
|
:group-select="false"
|
||||||
|
:group-values="groupByNation ? 'values' : undefined"
|
||||||
|
group-label="nationID"
|
||||||
label="searchText"
|
label="searchText"
|
||||||
track-by="value"
|
track-by="value"
|
||||||
:show-labels="false"
|
:show-labels="false"
|
||||||
@@ -18,7 +20,21 @@
|
|||||||
:searchable="searchMode"
|
:searchable="searchMode"
|
||||||
>
|
>
|
||||||
<template v-slot:option="props">
|
<template v-slot:option="props">
|
||||||
<div v-html="props.option.title"></div>
|
<div v-if="props.option.title" v-html="props.option.title"></div>
|
||||||
|
<div
|
||||||
|
v-if="props.option.$groupLabel !== undefined"
|
||||||
|
class="margin-filler"
|
||||||
|
:style="{
|
||||||
|
backgroundColor: groupByNation.get(props.option.$groupLabel).color,
|
||||||
|
color: isBrightColor(
|
||||||
|
groupByNation.get(props.option.$groupLabel).color
|
||||||
|
)
|
||||||
|
? 'black'
|
||||||
|
: 'white',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ groupByNation.get(props.option.$groupLabel).name }}
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:singleLabel="props">
|
<template v-slot:singleLabel="props">
|
||||||
{{ props.option.simpleName }}
|
{{ props.option.simpleName }}
|
||||||
@@ -29,10 +45,13 @@
|
|||||||
import { getNpcColor } from "@/common_legacy";
|
import { getNpcColor } from "@/common_legacy";
|
||||||
import { automata초성All } from "@/util/automata초성";
|
import { automata초성All } from "@/util/automata초성";
|
||||||
import { filter초성withAlphabet } from "@/util/filter초성withAlphabet";
|
import { filter초성withAlphabet } from "@/util/filter초성withAlphabet";
|
||||||
|
import { isBrightColor } from "@/util/isBrightColor";
|
||||||
|
import { unwrap } from "@/util/unwrap";
|
||||||
import { defineComponent, PropType } from "vue";
|
import { defineComponent, PropType } from "vue";
|
||||||
import {
|
import {
|
||||||
procGeneralItem,
|
procGeneralItem,
|
||||||
procGeneralList,
|
procGeneralList,
|
||||||
|
procNationItem,
|
||||||
} from "./processingRes";
|
} from "./processingRes";
|
||||||
|
|
||||||
type SelectedGeneral = {
|
type SelectedGeneral = {
|
||||||
@@ -58,6 +77,11 @@ export default defineComponent({
|
|||||||
required: false,
|
required: false,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
},
|
},
|
||||||
|
groupByNation: {
|
||||||
|
type: Map as PropType<Map<number, procNationItem>>,
|
||||||
|
required: false,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
emits: ["update:modelValue"],
|
emits: ["update:modelValue"],
|
||||||
watch: {
|
watch: {
|
||||||
@@ -70,15 +94,41 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const forFind = [];
|
const forFind: (
|
||||||
|
| SelectedGeneral
|
||||||
|
| {
|
||||||
|
values: SelectedGeneral[];
|
||||||
|
nationID: number;
|
||||||
|
}
|
||||||
|
)[] = [];
|
||||||
|
const forFindGroup = new Map<number, SelectedGeneral[]>();
|
||||||
const targets = new Map<number, SelectedGeneral>();
|
const targets = new Map<number, SelectedGeneral>();
|
||||||
|
|
||||||
let selectedGeneral;
|
let selectedGeneral;
|
||||||
|
|
||||||
for (const gen of this.generals) {
|
for (const gen of this.generals) {
|
||||||
|
let groupArray = forFind;
|
||||||
|
if (this.groupByNation) {
|
||||||
|
const nationID = gen.nationID ?? 0;
|
||||||
|
if (!forFindGroup.has(nationID)) {
|
||||||
|
const nationItem = unwrap(this.groupByNation.get(nationID));
|
||||||
|
let tmpArr: SelectedGeneral[] = [];
|
||||||
|
forFindGroup.set(nationID, tmpArr);
|
||||||
|
groupArray = tmpArr;
|
||||||
|
|
||||||
|
forFind.push({
|
||||||
|
nationID: nationItem.id,
|
||||||
|
values: tmpArr,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
groupArray = unwrap(forFindGroup.get(nationID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nameColor = getNpcColor(gen.npc);
|
const nameColor = getNpcColor(gen.npc);
|
||||||
const name = nameColor?`<span style="color:${nameColor}">${gen.name}</span>`:gen.name;
|
const name = nameColor
|
||||||
|
? `<span style="color:${nameColor}">${gen.name}</span>`
|
||||||
|
: gen.name;
|
||||||
|
|
||||||
const [filteredTextH, filteredTextA] = filter초성withAlphabet(gen.name);
|
const [filteredTextH, filteredTextA] = filter초성withAlphabet(gen.name);
|
||||||
const [filteredTextHL1, filteredTextHL2] = automata초성All(filteredTextH);
|
const [filteredTextHL1, filteredTextHL2] = automata초성All(filteredTextH);
|
||||||
@@ -86,9 +136,7 @@ export default defineComponent({
|
|||||||
value: gen.no,
|
value: gen.no,
|
||||||
title: this.textHelper
|
title: this.textHelper
|
||||||
? this.textHelper(gen)
|
? this.textHelper(gen)
|
||||||
: `${name} (${gen.leadership}/${gen.leadership}/${
|
: `${name} (${gen.leadership}/${gen.leadership}/${gen.intel})`,
|
||||||
gen.intel
|
|
||||||
})`,
|
|
||||||
simpleName: gen.name,
|
simpleName: gen.name,
|
||||||
searchText: `${gen.name} ${filteredTextH} ${filteredTextA} ${filteredTextHL1} ${filteredTextHL2}`,
|
searchText: `${gen.name} ${filteredTextH} ${filteredTextA} ${filteredTextHL1} ${filteredTextHL2}`,
|
||||||
obj: gen,
|
obj: gen,
|
||||||
@@ -96,14 +144,16 @@ export default defineComponent({
|
|||||||
if (gen.no == this.modelValue) {
|
if (gen.no == this.modelValue) {
|
||||||
selectedGeneral = obj;
|
selectedGeneral = obj;
|
||||||
}
|
}
|
||||||
forFind.push(obj);
|
groupArray.push(obj);
|
||||||
targets.set(gen.no, obj);
|
targets.set(gen.no, obj);
|
||||||
}
|
}
|
||||||
|
console.log(forFind);
|
||||||
return {
|
return {
|
||||||
selectedGeneral,
|
selectedGeneral,
|
||||||
searchMode: true,
|
searchMode: true,
|
||||||
forFind,
|
forFind,
|
||||||
targets,
|
targets,
|
||||||
|
isBrightColor,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -128,5 +178,12 @@ export default defineComponent({
|
|||||||
input {
|
input {
|
||||||
color: $vue-multiselect-color;
|
color: $vue-multiselect-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.multiselect__option--group {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.margin-filler {
|
||||||
|
padding: calc($vue-multiselect-padding-y + 0.17em) $vue-multiselect-padding-x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -52,7 +52,7 @@ import BottomBar from "@/components/BottomBar.vue";
|
|||||||
import {
|
import {
|
||||||
convertGeneralList,
|
convertGeneralList,
|
||||||
procGeneralItem,
|
procGeneralItem,
|
||||||
procGeneralKeyList,
|
procGeneralKey,
|
||||||
procGeneralRawItemList,
|
procGeneralRawItemList,
|
||||||
procTroopList,
|
procTroopList,
|
||||||
} from "../processingRes";
|
} from "../processingRes";
|
||||||
@@ -66,7 +66,7 @@ declare const procRes: {
|
|||||||
cities: [number, string][];
|
cities: [number, string][];
|
||||||
troops: procTroopList;
|
troops: procTroopList;
|
||||||
generals: procGeneralRawItemList;
|
generals: procGeneralRawItemList;
|
||||||
generalsKey: procGeneralKeyList;
|
generalsKey: procGeneralKey[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -110,7 +110,7 @@ export default defineComponent({
|
|||||||
const troops = (!gen.troopID)?'':`,${procRes.troops[gen.troopID].name}`;
|
const troops = (!gen.troopID)?'':`,${procRes.troops[gen.troopID].name}`;
|
||||||
const nameColor = getNpcColor(gen.npc);
|
const nameColor = getNpcColor(gen.npc);
|
||||||
const name = nameColor?`<span style="color:${nameColor}">${gen.name}</span>`:gen.name;
|
const name = nameColor?`<span style="color:${nameColor}">${gen.name}</span>`:gen.name;
|
||||||
return `${name} [${citiesMap.get(gen.cityID)?.name}${troops}] (${gen.leadership}/${gen.leadership}/${gen.intel}) <병${gen.crew.toLocaleString()}/훈${gen.train}/사${gen.atmos}>`;
|
return `${name} [${citiesMap.get(unwrap(gen.cityID))?.name}${troops}] (${gen.leadership}/${gen.leadership}/${gen.intel}) <병${unwrap(gen.crew).toLocaleString()}/훈${gen.train}/사${gen.atmos}>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submit(e: Event) {
|
async function submit(e: Event) {
|
||||||
|
|||||||
@@ -3,42 +3,26 @@ import { combineArray } from "@/util/combineArray";
|
|||||||
export type procGeneralItem = {
|
export type procGeneralItem = {
|
||||||
no: number,
|
no: number,
|
||||||
name: string,
|
name: string,
|
||||||
|
nationID?: number,
|
||||||
officerLevel: number,
|
officerLevel: number,
|
||||||
npc: number,
|
npc: number,
|
||||||
gold: number,
|
gold?: number,
|
||||||
rice: number,
|
rice?: number,
|
||||||
leadership: number,
|
leadership: number,
|
||||||
strength: number,
|
strength: number,
|
||||||
intel: number,
|
intel: number,
|
||||||
cityID: number,
|
cityID?: number,
|
||||||
crew: number,
|
crew?: number,
|
||||||
train: number,
|
train?: number,
|
||||||
atmos: number,
|
atmos?: number,
|
||||||
troopID: number,
|
troopID?: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type procGeneralList = procGeneralItem[];
|
export type procGeneralList = procGeneralItem[];
|
||||||
|
|
||||||
export type procGeneralKeyList = [
|
export type procGeneralKey = 'no'| 'name'| 'nationID' | 'officerLevel'| 'npc'| 'gold'| 'rice'| 'leadership'| 'strength'| 'intel'| 'cityID'| 'crew'| 'train'| 'atmos'| 'troopID';
|
||||||
'no', 'name', 'officerLevel', 'npc', 'gold', 'rice', 'leadership', 'strength', 'intel', 'cityID', 'crew', 'train', 'atmos', 'troopID'
|
|
||||||
];
|
|
||||||
|
|
||||||
export type procGeneralRawItem = [
|
export type procGeneralRawItem = procGeneralItem[procGeneralKey][];
|
||||||
procGeneralItem[procGeneralKeyList[0]],
|
|
||||||
procGeneralItem[procGeneralKeyList[1]],
|
|
||||||
procGeneralItem[procGeneralKeyList[2]],
|
|
||||||
procGeneralItem[procGeneralKeyList[3]],
|
|
||||||
procGeneralItem[procGeneralKeyList[4]],
|
|
||||||
procGeneralItem[procGeneralKeyList[5]],
|
|
||||||
procGeneralItem[procGeneralKeyList[6]],
|
|
||||||
procGeneralItem[procGeneralKeyList[7]],
|
|
||||||
procGeneralItem[procGeneralKeyList[8]],
|
|
||||||
procGeneralItem[procGeneralKeyList[9]],
|
|
||||||
procGeneralItem[procGeneralKeyList[10]],
|
|
||||||
procGeneralItem[procGeneralKeyList[11]],
|
|
||||||
procGeneralItem[procGeneralKeyList[12]],
|
|
||||||
procGeneralItem[procGeneralKeyList[13]],
|
|
||||||
];
|
|
||||||
|
|
||||||
export type procTroopItem = {
|
export type procTroopItem = {
|
||||||
troop_leader: number,
|
troop_leader: number,
|
||||||
@@ -49,7 +33,7 @@ export type procTroopList = Record<number, procTroopItem>;
|
|||||||
|
|
||||||
export type procGeneralRawItemList = procGeneralRawItem[];
|
export type procGeneralRawItemList = procGeneralRawItem[];
|
||||||
|
|
||||||
export function convertGeneralList(keys: procGeneralKeyList, rawList: procGeneralRawItemList): procGeneralList{
|
export function convertGeneralList(keys: procGeneralKey[], rawList: procGeneralRawItemList): procGeneralList{
|
||||||
return combineArray(rawList, keys) as procGeneralList;
|
return combineArray(rawList, keys) as procGeneralList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user