feat: 장수 패널에 개인 전략 표기

This commit is contained in:
2023-12-25 16:41:52 +00:00
parent 8e93c69582
commit ca46061d17
5 changed files with 69 additions and 16 deletions
+21 -1
View File
@@ -3,7 +3,9 @@
namespace sammo\API\Nation;
use ArrayObject;
use sammo\Command\UserActionCommand;
use sammo\DB;
use sammo\DTO\UserAction;
use sammo\Enums\APIRecoveryType;
use sammo\Enums\GeneralLiteQueryMode;
use sammo\Enums\GeneralQueryMode;
@@ -117,6 +119,8 @@ class GeneralList extends \sammo\BaseAPI
'reservedCommand' => 1,
'autorun_limit' => 1,
'impossibleUserAction' => 1,
];
public function validateArgs(): ?string
@@ -153,7 +157,8 @@ class GeneralList extends \sammo\BaseAPI
$me = $db->queryFirstRow(
'SELECT refresh_score, turntime, belong, nation, officer_level, permission, penalty FROM `general`
LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $session->getUserID()
LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i',
$session->getUserID()
);
$limitState = checkLimit($me['refresh_score']);
if ($limitState >= 2) {
@@ -269,6 +274,21 @@ class GeneralList extends \sammo\BaseAPI
'bill' => fn ($rawGeneral) => getBillByLevel($rawGeneral['dedlevel']),
'reservedCommand' => fn ($rawGeneral) => $reservedCommand[$rawGeneral['no']] ?? null,
'autorun_limit' => fn ($rawGeneral) => ($rawGeneral['aux'] ?? [])['autorun_limit'] ?? 0,
'impossibleUserAction' => function ($rawGeneral) use ($env) {
$rawUserAction = ($rawGeneral['aux'] ?? [])[UserActionCommand::USER_ACTION_KEY] ?? [];
$userAction = UserAction::fromArray($rawUserAction);
$impossibleUserAction = [];
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
if ($userAction->nextAvailableTurn) {
foreach ($userAction->nextAvailableTurn as $command => $nextAvailableTurn) {
if ($nextAvailableTurn > $yearMonth) {
$impossibleUserAction[] = [$command, $nextAvailableTurn - $yearMonth];
}
}
}
return $impossibleUserAction;
}
];
foreach ($rankColumns as $rankKey) {
+16 -11
View File
@@ -1,17 +1,22 @@
<template>
<BContainer id="container" ref="container" :toast="{ root: true }">
<TopBackBar :reloadable="true" title="개인 전략" @reload="refresh" />
<div v-if="asyncReady && gameConstStore && generalInfo && frontInfo && globalInfo && nationStaticInfo" id="pages" class="bg0">
<div v-if="asyncReady && gameConstStore && generalInfo && frontInfo && globalInfo && nationStaticInfo" id="pages"
class="bg0">
<div id="leftPanel">
<GeneralBasicCard :general="generalInfo" :nation="nationStaticInfo" :troopInfo="frontInfo.general.troopInfo"
:turnTerm="globalInfo.turnterm" :lastExecuted="lastExecuted" />
<div class="bg1" style="margin-top: 10px;">
대기 중인 전략
</div>
<div v-for="[command, turn] of frontInfo.general.impossibleUserAction" :key="command">
<span>{{ command }}</span>: {{ turn.toLocaleString() }}
</div>
</div>
<div id="actionForm">
<ReservedCommandForUserAction ref="reservedCommandPanel" />
</div>
</div>
</BContainer>
</template>
<script lang="ts">
@@ -91,14 +96,14 @@ async function refresh() {
const rawNation = frontResponse.nation;
nationStaticInfo.value = {
nation: rawNation.id,
name: rawNation.name,
color: rawNation.color,
type: rawNation.type.raw,
level: rawNation.level,
capital: rawNation.capital,
gennum: rawNation.gennum,
power: rawNation.power
nation: rawNation.id,
name: rawNation.name,
color: rawNation.color,
type: rawNation.type.raw,
level: rawNation.level,
capital: rawNation.capital,
gennum: rawNation.gennum,
power: rawNation.power
};
}
+30 -3
View File
@@ -150,6 +150,17 @@
{{ troopInfo.name }}({{ formatCityName(troopInfo.leader, gameConstStore) }})
</span>
</div>
<div class="bg1">전략</div>
<div
v-if="impossibleUserActionText"
v-b-tooltip.hover="impossibleUserActionText"
style="text-decoration: underline dashed red"
>
<span style="color: yellow">가능</span>
</div>
<div v-else class="strategicClg-body tb-body">
<span style="color: limegreen">가능</span>
</div>
<div class="bg1">벌점</div>
<div class="general-refresh-score-total">
{{ formatRefreshScore(general.refreshScoreTotal) }} {{ (general.refreshScoreTotal ?? 0).toLocaleString() }}({{ general.refreshScore ?? 0 }})
@@ -272,6 +283,25 @@ watch(
{ immediate: true }
);
const impossibleUserActionText = ref<string>("");
watch(
general,
(general) => {
const impossibleUserAction = general.impossibleUserAction;
if (impossibleUserAction.length == 0) {
impossibleUserActionText.value = "";
return;
}
const texts = [];
for (const [cmdName, turnCnt] of impossibleUserAction) {
texts.push(`${cmdName}: ${turnCnt.toLocaleString()}턴 뒤`);
}
impossibleUserActionText.value = texts.join("<br>\n");
},
{ immediate: true }
);
const nextExecuteMinute = ref(999);
watch(
general,
@@ -341,7 +371,4 @@ watch(
grid-column: 2 / 4;
}
.general-refresh-score-total {
grid-column: 5 / 8;
}
</style>
-1
View File
@@ -148,7 +148,6 @@ export type GetFrontInfoResponse = {
};
name: string;
};
impossibleUserAction: [string, number][];
};
nation: {
id: number;
+2
View File
@@ -81,6 +81,8 @@ export type GeneralListItemP1 = {
killcrew: number;
deathcrew: number;
firenum: number;
impossibleUserAction: [string, number][];
} & GeneralListItemP0;
export type GeneralListItemP2 = GeneralListItemP1;