From 5dabdb263616148acd4f5f00090b9886ac3a9999 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 5 Mar 2023 01:43:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20PageFront=20=EC=83=81=EB=8B=A8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4(wip)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/General/GetFrontInfo.php | 6 +- hwe/ts/PageFront.vue | 156 +++++++++++++++++-------- hwe/ts/components/AutorunInfo.vue | 2 +- hwe/ts/defs/API/Global.ts | 9 +- hwe/ts/utilGame/formatTournament.ts | 35 ++++++ 5 files changed, 155 insertions(+), 53 deletions(-) create mode 100644 hwe/ts/utilGame/formatTournament.ts diff --git a/hwe/sammo/API/General/GetFrontInfo.php b/hwe/sammo/API/General/GetFrontInfo.php index 207c881d..b0cba471 100644 --- a/hwe/sammo/API/General/GetFrontInfo.php +++ b/hwe/sammo/API/General/GetFrontInfo.php @@ -92,7 +92,8 @@ class GetFrontInfo extends \sammo\BaseAPI $isTournamentApplicationOpen = $gameStor->tournament == 1; $isBettingActive = $gameStor->tournament == 6; $tournamentType = $gameStor->tnmt_type; - $tournamentState = getTournamentTermText($gameStor->turnterm); + $tournamentState = $gameStor->tournament; + $tournamentTime = $gameStor->tnmt_time; $isLocked = boolval($db->queryFirstField('SELECT plock FROM plock WHERE `type`="GAME" LIMIT 1')); $globalGenCount = $db->queryAllLists('SELECT npc, count(no) FROM general GROUP BY npc'); @@ -122,6 +123,7 @@ class GetFrontInfo extends \sammo\BaseAPI 'isLocked' => $isLocked, 'tournamentType' => $tournamentType, 'tournamentState' => $tournamentState, + 'tournamentTime' => $tournamentTime, 'genCount' => $globalGenCount, 'generalCntLimit' => $generalCntLimit, 'serverCnt' => $serverCnt, @@ -176,6 +178,7 @@ class GetFrontInfo extends \sammo\BaseAPI return [ 'id' => $nationID, + 'full' => true, 'name' => $rawNation['name'], 'population' => $nationPopulation, 'crew' => $nationCrew, @@ -214,6 +217,7 @@ class GetFrontInfo extends \sammo\BaseAPI $staticInfo = getNationStaticInfo(0); return [ 'id' => 0, + 'full' => false, 'name' => $staticInfo['name'], 'population' => [ 'cityCnt' => 0, diff --git a/hwe/ts/PageFront.vue b/hwe/ts/PageFront.vue index 804847fa..259ee453 100644 --- a/hwe/ts/PageFront.vue +++ b/hwe/ts/PageFront.vue @@ -23,47 +23,87 @@ variant="sammo-base2" /> -
시나리오
-
-
{{ globalInfo.scenarioText }}
-
- NPC 수, 상성: {{ globalInfo.extendedGeneral ? "확장" : "표준" }} +

+ {{ gameConstStore?.gameConst.title }} {{ serverName }}{{ frontInfo?.global.serverCnt }}기 + {{ frontInfo?.global.scenarioText }} +

+
+
+ {{ globalInfo.scenarioText }} +
+
+ NPC 수, 상성: + {{ globalInfo.extendedGeneral ? "확장" : "표준" }} {{ globalInfo.isFiction ? "가상" : "사실" }}
-
NPC선택: {{ ["불가능", "가능", "선택 생성"][globalInfo.npcMode] }}
-
토너먼트: 경기당 {{ calcTournamentTerm(globalInfo.turnterm) }}분
-
+
+ NPC선택: {{ ["불가능", "가능", "선택 생성"][globalInfo.npcMode] }} +
+
+ 토너먼트: 경기당 {{ calcTournamentTerm(globalInfo.turnterm) }}분 +
+
기타 설정:
-
+
현재: {{ globalInfo.year }}年 {{ globalInfo.month }}月 ({{ globalInfo.turnterm }}분 턴 서버)
-
전체 접속자 수: {{ globalInfo.onlineUserCnt.toLocaleString() }}명
-
턴당 갱신횟수: {{ globalInfo.apiLimit.toLocaleString() }}회
-
- 등록 장수: 유저 - {{ globalInfo.genCount.toLocaleString() }} / {{ globalInfo.generalCntLimit.toLocaleString() }} - + NPC TODO:NPC Cnt 명 +
+ 전체 접속자 수: {{ globalInfo.onlineUserCnt.toLocaleString() }}명
-
TODO: tournament Text
-
+
+ 턴당 갱신횟수: {{ globalInfo.apiLimit.toLocaleString() }}회 +
+
+ 등록 장수: 유저 + {{ createdUserCnt.toLocaleString() }} / {{ globalInfo.generalCntLimit.toLocaleString() }} + + NPC {{ createdNPCCnt.toLocaleString() }} 명 +
+
+ + + ↑{{ formatTournamentType(frontInfo.global.tournamentType) }} + {{ tournamentStep.state }} {{ tournamentStep.nextText }} + {{ formatTime(tournamentTime).substring(11, 16) }}↑ + + + ↑{{ formatTournamentType(frontInfo.global.tournamentType) }} + {{ tournamentStep.state }} {{ tournamentStep.nextText }} + {{ formatTime(tournamentTime).substring(11, 16) }}↑ + + + 현재 토너먼트 경기 없음 +
+
동작 시각: {{ formatTime(lastExecuted).substring(5) }}
-
- {{ globalInfo.auctionCount.toLocaleString() }}건 거래 진행중 + -
진행중인 거래 없음
-
- 설문 진행 중: {{ globalInfo.lastVote.title }} + -
진행중인 설문 없음
-
접속중인 국가: {{ globalInfo.onlineNations }}
-
접속자
-
국가 방침 +
접속중인 국가: {{ globalInfo.onlineNations }}
+
【 접속자 】 {{ nationInfo?.onlineGen }}
+
+
【 국가방침 】
-
+
@@ -218,7 +258,7 @@ import CityBasicCard from "./components/CityBasicCard.vue"; import NationBasicCard from "./components/NationBasicCard.vue"; import GeneralBasicCard from "./components/GeneralBasicCard.vue"; import MessagePanel from "./components/MessagePanel.vue"; -import type { NationInfoFull } from "./defs/API/Nation"; +import type { NationInfoFull } from "./defs/API/Nation"; import type { MapResult, NationStaticItem } from "./defs"; import { formatTime } from "./util/formatTime"; import { calcTournamentTerm } from "./utilGame"; @@ -228,6 +268,7 @@ import AutorunInfo from "./components/AutorunInfo.vue"; import { scrollHardTo } from "./util/scrollHardTo"; import MainControlBar from "./components/MainControlBar.vue"; import GlobalMenu from "./components/GlobalMenu.vue"; +import { formatTournamentStep, formatTournamentType, type TournamentStepType } from "./utilGame/formatTournament"; const { serverName, serverNick, serverID } = staticValues; @@ -431,7 +472,18 @@ const frontInfo = ref(); const globalInfo = ref({} as GetFrontInfoResponse["global"]); const generalInfo = ref(); const nationStaticInfo = ref(); -const nationInfo = ref(); +const nationInfo = ref(); +const generalCnt = ref(new Map()); +const createdUserCnt = ref(0); +const createdNPCCnt = ref(0); + +const tournamentStep = ref({ + availableJoin: false, + state: "초기화 중", + nextText: "", +}); +const tournamentTime = ref(new Date()); + let generalInfoLock = false; watch(refreshCounter, async () => { @@ -453,6 +505,7 @@ watch(refreshCounter, async () => { } const rawNation = response.nation; + nationInfo.value = rawNation; nationStaticInfo.value = { nation: rawNation.id, name: rawNation.name, @@ -473,21 +526,24 @@ watch(refreshCounter, async () => { } }); -watch(refreshCounter, async () => { - try { - const response = await SammoAPI.Nation.GetNationInfo({full: true}); - console.log('nation', response); - if(!response.isFull){ - throw 'NationInfo 반환값 에러'; +watch(globalInfo, (global) => { + const value = new Map(); + let userCnt = 0; + let npcCnt = 0; + for (const [npcType, cnt] of global.genCount) { + value.set(npcType, cnt); + if (npcType < 2) { + userCnt += cnt; + } else { + npcCnt += cnt; } - nationInfo.value = response; - } catch (e) { - console.error(e); - toasts.danger({ - title: "국가 정보 갱신 실패", - body: `${e}`, - }); } + generalCnt.value = value; + createdUserCnt.value = userCnt; + createdNPCCnt.value = npcCnt; + + tournamentStep.value = formatTournamentStep(global.tournamentState); + tournamentTime.value = parseTime(global.tournamentTime); }); const map = ref(); @@ -544,6 +600,10 @@ watch(refreshCounter, async () => { justify-content: space-between; } +.gameInfo { + text-align: center; +} + .generalInfo { width: 500px; } @@ -552,12 +612,18 @@ watch(refreshCounter, async () => { display: grid; } -.nationNoticeBody{ +.nationNoticeBody { :deep(p) { min-height: 1em; } } +.subVoteState, .subAuctionState, .subTournamentState { + a { + text-decoration: gray underline; + } +} + @include media-500px { #outBlock { position: absolute; @@ -578,10 +644,6 @@ watch(refreshCounter, async () => { #container { width: 500px; - > main > div { - min-height: 100px; - /* 테스트 */ - } } #ingameBoard { diff --git a/hwe/ts/components/AutorunInfo.vue b/hwe/ts/components/AutorunInfo.vue index ea38c91c..6e3803cb 100644 --- a/hwe/ts/components/AutorunInfo.vue +++ b/hwe/ts/components/AutorunInfo.vue @@ -1,5 +1,5 @@