fix: 장수 카드에서 '남은 시간'이 제대로 표기 안됨

This commit is contained in:
2022-07-30 20:16:08 +09:00
parent 79734a6dcf
commit 16a2f20af0
3 changed files with 30 additions and 7 deletions
+12 -1
View File
@@ -38,7 +38,12 @@
<div v-if="targetGeneral && nationInfo && targetGeneralLogs" class="row gx-0 bg0">
<div class="col-12 col-md-6">
<div class="bg1 header-cell" style="color: skyblue">장수 정보</div>
<GeneralBasicCard :general="targetGeneral" :nation="nationInfo" />
<GeneralBasicCard
:general="targetGeneral"
:nation="nationInfo"
:turnTerm="turnTerm"
:lastExecuted="lastExecuted"
/>
<GeneralSupplementCard :general="targetGeneral" />
</div>
<div class="col-12 col-md-6">
@@ -89,6 +94,7 @@ import type { NationStaticItem } from "./defs";
import type { GeneralLogType } from "./defs/API/General";
import { isString } from "lodash";
import { formatLog } from "./utilGame/formatLog";
import { parseTime } from "./util/parseTime";
const toasts = unwrap(useToast());
@@ -104,6 +110,8 @@ const textMap = {
turntime: ["최근 턴", (gen: GeneralListItemP1) => gen.turntime, false, (gen: GeneralListItemP1) => ""],
name: ["이름", (gen: GeneralListItemP1) => `${gen.npc} ${gen.name}`, true, (gen: GeneralListItemP1) => ""],
} as const;
const turnTerm = ref<number>(1);
const lastExecuted = ref<Date>(new Date());
const orderedGeneralList = ref<GeneralListItemP1[]>([]);
const orderedInvGeneralKeyIndex = ref(new Map<number, number>());
@@ -240,6 +248,9 @@ async function reload(): Promise<void> {
throw "권한이 부족합니다.";
}
turnTerm.value = env.turnterm;
lastExecuted.value = parseTime(env.turntime);
console.log(list);
const rawGeneralList = merge2DArrToObjectArr(column, list);
+7
View File
@@ -127,6 +127,8 @@
:general="popupGeneralTarget"
:troopInfo="convBasicCardTroopInfo(popupGeneralTarget)"
:nation="nationInfo"
:turnTerm="turnTerm"
:lastExecuted="lastExecuted"
/>
<GeneralSupplementCard :general="popupGeneralTarget" :showCommandList="true" />
</template>
@@ -154,6 +156,7 @@ import type { NationStaticItem } from "./defs";
import GeneralLiteCard from "./components/GeneralLiteCard.vue";
import GeneralSupplementCard from "./components/GeneralSupplementCard.vue";
import { pick } from "./util/JosaUtil";
import { parseTime } from "./util/parseTime";
const toasts = unwrap(useToast());
const asyncReady = ref(false);
@@ -225,6 +228,8 @@ type TroopInfo = {
const me = ref<GeneralListItem>({} as GeneralListItem);
const myPermission = ref<0 | 1 | 2 | 3 | 4>(0);
const turnTerm = ref<number>(1);
const lastExecuted = ref<Date>(new Date());
const troopList = ref(new Map<number, TroopInfo>());
const generalList = ref(new Map<number, GeneralListItem>());
@@ -249,6 +254,8 @@ async function refresh() {
const nationP = SammoAPI.Nation.GetNationInfo({});
nationInfo.value = (await nationP).nation;
const { column, list, permission, troops, env, myGeneralID } = await generalListP;
turnTerm.value = env.turnterm;
lastExecuted.value = parseTime(env.turntime);
//빠른 턴 순서로 정렬되어있다.
+11 -6
View File
@@ -148,7 +148,7 @@
<script lang="ts" setup>
import type { GeneralListItemP1 } from "@/defs/API/Nation";
import { computed, inject, onMounted, ref, toRefs, type Ref } from "vue";
import { computed, inject, onMounted, ref, toRefs, watch, type Ref } from "vue";
import { getIconPath } from "@/util/getIconPath";
import { isBrightColor } from "@/util/isBrightColor";
import { formatInjury } from "@/utilGame/formatInjury";
@@ -164,6 +164,7 @@ import { clamp } from "lodash";
import { formatCityName } from "@/utilGame/formatCityName";
import { isValidObjKey } from "@/utilGame/isValidObjKey";
import { calcInjury } from "@/utilGame/calcInjury";
import { addMinutes } from "date-fns/esm";
const imagePath = window.pathConfig.gameImage;
const gameConstStore = unwrap(inject<Ref<GameConstStore>>("gameConstStore"));
@@ -174,6 +175,8 @@ const props = defineProps<{
name: string;
};
nation: NationStaticItem;
turnTerm: number;
lastExecuted: Date;
}>();
const { general, troopInfo, nation } = toRefs(props);
@@ -258,11 +261,13 @@ const ageColor = computed(() => {
});
const nextExecuteMinute = ref(999);
onMounted(() => {
const now = new Date();
const turnTime = parseTime(general.value.turntime);
nextExecuteMinute.value = Math.floor(clamp(turnTime.getSeconds() - now.getSeconds() / 60, 0));
});
watch(general, () => {
let turnTime = parseTime(general.value.turntime);
if(turnTime.getTime() < props.lastExecuted.getTime()){
turnTime = addMinutes(turnTime, props.turnTerm);
}
nextExecuteMinute.value = Math.floor(clamp((turnTime.getTime() - props.lastExecuted.getTime()) / 60000, 0, 999));
}, { immediate: true });
</script>
<style lang="scss" scoped>