wip: GetFrontInfo
This commit is contained in:
+69
-16
@@ -27,7 +27,15 @@
|
||||
<div class="reservedCommandZone">예턴</div>
|
||||
<div class="cityInfo">도시 정보</div>
|
||||
<div class="nationInfo">국가 정보</div>
|
||||
<div class="generalInfo">장수 정보</div>
|
||||
<div v-if="frontInfo && generalInfo && nationStaticInfo" class="generalInfo">
|
||||
<GeneralBasicCard
|
||||
:general="generalInfo"
|
||||
:nation="nationStaticInfo"
|
||||
:troopInfo="frontInfo.general.troopInfo"
|
||||
:turnTerm="frontInfo.global.turnterm"
|
||||
:lastExecuted="lastExecuted"
|
||||
/>
|
||||
</div>
|
||||
<div class="generalCommandToolbar">국가 툴바</div>
|
||||
<div class="actionMiniPlate">갱신/로비 버튼</div>
|
||||
<div class="PublicRecord">
|
||||
@@ -87,8 +95,11 @@ import { parseTime } from "./util/parseTime";
|
||||
import { unwrap } from "./util/unwrap";
|
||||
import Denque from "denque";
|
||||
import { formatLog } from "@/utilGame/formatLog";
|
||||
import type { ExecuteResponse } from "./defs/API/Global";
|
||||
import type { ExecuteResponse, GetFrontInfoResponse } from "./defs/API/Global";
|
||||
import { delay } from "./util/delay";
|
||||
import GeneralBasicCard from "./components/GeneralBasicCard.vue";
|
||||
import type { GeneralListItemP1 } from "./defs/API/Nation";
|
||||
import type { NationStaticItem } from "./defs";
|
||||
|
||||
const { serverName, serverNick, serverID } = staticValues;
|
||||
|
||||
@@ -115,21 +126,19 @@ async function tryRefresh() {
|
||||
}
|
||||
try {
|
||||
responseLock = true;
|
||||
const responseP = SammoAPI.Global.ExecuteEngine({ serverID }, true).then(
|
||||
(response) => {
|
||||
if (response.result) {
|
||||
lastExecuted.value = parseTime(response.lastExecuted);
|
||||
serverLocked.value = response.locked;
|
||||
}
|
||||
return response;
|
||||
const responseP = SammoAPI.Global.ExecuteEngine({ serverID }, true).then((response) => {
|
||||
if (response.result) {
|
||||
lastExecuted.value = parseTime(response.lastExecuted);
|
||||
serverLocked.value = response.locked;
|
||||
}
|
||||
);
|
||||
return response;
|
||||
});
|
||||
|
||||
//TODO: 갱신 알림 띄우기
|
||||
const response = await Promise.race([delay(3000), responseP]);
|
||||
responseLock = false;
|
||||
|
||||
if(response === undefined){
|
||||
if (response === undefined) {
|
||||
//timeout이지만 일단 갱신한다.
|
||||
refreshCounter.value += 1;
|
||||
return;
|
||||
@@ -179,7 +188,7 @@ const worldHistory = ref(new Denque<[number, string]>());
|
||||
let recordLock = false;
|
||||
|
||||
watch(refreshCounter, async () => {
|
||||
if(recordLock){
|
||||
if (recordLock) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -215,11 +224,10 @@ watch(refreshCounter, async () => {
|
||||
if (!generalRecords.value.isEmpty() && id <= unwrap(generalRecords.value.get(0))[0]) {
|
||||
continue;
|
||||
}
|
||||
if(generalRecords.value.length >= 15) {
|
||||
if (generalRecords.value.length >= 15) {
|
||||
generalRecords.value.pop();
|
||||
}
|
||||
generalRecords.value.unshift([id, record]);
|
||||
|
||||
}
|
||||
|
||||
while (response.global.length) {
|
||||
@@ -227,7 +235,7 @@ watch(refreshCounter, async () => {
|
||||
if (!globalRecords.value.isEmpty() && id <= unwrap(globalRecords.value.get(0))[0]) {
|
||||
continue;
|
||||
}
|
||||
if(globalRecords.value.length >= 15) {
|
||||
if (globalRecords.value.length >= 15) {
|
||||
globalRecords.value.pop();
|
||||
}
|
||||
globalRecords.value.unshift([id, record]);
|
||||
@@ -238,7 +246,7 @@ watch(refreshCounter, async () => {
|
||||
if (!worldHistory.value.isEmpty() && id <= unwrap(worldHistory.value.get(0))[0]) {
|
||||
continue;
|
||||
}
|
||||
if(worldHistory.value.length >= 15) {
|
||||
if (worldHistory.value.length >= 15) {
|
||||
worldHistory.value.pop();
|
||||
}
|
||||
worldHistory.value.unshift([id, record]);
|
||||
@@ -252,6 +260,51 @@ watch(refreshCounter, async () => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const frontInfo = ref<GetFrontInfoResponse>();
|
||||
|
||||
const generalInfo = ref<GeneralListItemP1>();
|
||||
const nationStaticInfo = ref<NationStaticItem>();
|
||||
|
||||
let generalInfoLock = false;
|
||||
|
||||
watch(refreshCounter, async () => {
|
||||
if (generalInfoLock) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
generalInfoLock = true;
|
||||
const response = await SammoAPI.General.GetFrontInfo();
|
||||
generalInfoLock = false;
|
||||
|
||||
frontInfo.value = response;
|
||||
generalInfo.value = response.general;
|
||||
|
||||
const newLastExecuted = parseTime(response.global.lastExecuted);
|
||||
if(newLastExecuted.getTime() > lastExecuted.value.getTime()){
|
||||
lastExecuted.value = newLastExecuted;
|
||||
}
|
||||
|
||||
const rawNation = response.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,
|
||||
};
|
||||
} catch (e) {
|
||||
recordLock = false;
|
||||
console.error(e);
|
||||
toasts.danger({
|
||||
title: "최근 정보 갱신 실패",
|
||||
body: `${e}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import "@scss/common/break_500px.scss";
|
||||
|
||||
@@ -26,6 +26,7 @@ import type {
|
||||
GetConstResponse,
|
||||
GetCurrentHistoryResponse,
|
||||
GetDiplomacyResponse,
|
||||
GetFrontInfoResponse,
|
||||
GetHistoryResponse,
|
||||
GetRecentRecordResponse,
|
||||
} from "./defs/API/Global";
|
||||
@@ -131,6 +132,7 @@ const apiRealPath = {
|
||||
DieOnPrestart: POST as APICallT<undefined>,
|
||||
BuildNationCandidate: POST as APICallT<undefined>,
|
||||
GetCommandTable: GET as APICallT<undefined, CommandTableResponse>,
|
||||
GetFrontInfo: GET as APICallT<undefined, GetFrontInfoResponse>,
|
||||
},
|
||||
Global: {
|
||||
GeneralList: GET as APICallT<undefined, GeneralListResponse>,
|
||||
|
||||
+201
-80
@@ -1,96 +1,217 @@
|
||||
import type { CityID, CrewTypeID, GameCityDefault, GameConstType, GameUnitType, GameIActionKey, GameIActionCategory, GameIActionInfo } from "@/defs/GameObj";
|
||||
import type { diplomacyState, MapResult, SimpleNationObj } from "@/defs";
|
||||
import type {
|
||||
CityID,
|
||||
CrewTypeID,
|
||||
GameCityDefault,
|
||||
GameConstType,
|
||||
GameUnitType,
|
||||
GameIActionKey,
|
||||
GameIActionCategory,
|
||||
GameIActionInfo,
|
||||
} from "@/defs/GameObj";
|
||||
import type { diplomacyState, MapResult, NationLevel, SimpleNationObj } from "@/defs";
|
||||
import type { GeneralListItemP0, GeneralListItemP1 } from "./Nation";
|
||||
import type { VoteInfo } from "./Vote";
|
||||
|
||||
export interface GetConstResponse {
|
||||
result: true;
|
||||
cacheKey: string;
|
||||
data: {
|
||||
gameConst: GameConstType;
|
||||
gameUnitConst: Record<CrewTypeID, GameUnitType>;
|
||||
cityConst: Record<CityID, GameCityDefault>;
|
||||
cityConstMap: {
|
||||
region: Record<number | string, string | number>;
|
||||
level: Record<number | string, string | number>; //defs.CityLevelText
|
||||
};
|
||||
iActionInfo: Record<
|
||||
GameIActionCategory,
|
||||
Record<
|
||||
GameIActionKey,
|
||||
GameIActionInfo
|
||||
>
|
||||
>;
|
||||
iActionKeyMap: {
|
||||
availableNationType: "nationType";
|
||||
neutralNationType: "nationType";
|
||||
defaultSpecialDomestic: "specialDomestic";
|
||||
availableSpecialDomestic: "specialDomestic";
|
||||
optionalSpecialDomestic: "specialDomestic";
|
||||
defaultSpecialWar: "specialWar";
|
||||
availableSpecialWar: "specialWar";
|
||||
optionalSpecialWar: "specialWar";
|
||||
neutralPersonality: "personality";
|
||||
availablePersonality: "personality";
|
||||
optionalPersonality: "personality";
|
||||
allItems: "item";
|
||||
};
|
||||
result: true;
|
||||
cacheKey: string;
|
||||
data: {
|
||||
gameConst: GameConstType;
|
||||
gameUnitConst: Record<CrewTypeID, GameUnitType>;
|
||||
cityConst: Record<CityID, GameCityDefault>;
|
||||
cityConstMap: {
|
||||
region: Record<number | string, string | number>;
|
||||
level: Record<number | string, string | number>; //defs.CityLevelText
|
||||
};
|
||||
iActionInfo: Record<GameIActionCategory, Record<GameIActionKey, GameIActionInfo>>;
|
||||
iActionKeyMap: {
|
||||
availableNationType: "nationType";
|
||||
neutralNationType: "nationType";
|
||||
defaultSpecialDomestic: "specialDomestic";
|
||||
availableSpecialDomestic: "specialDomestic";
|
||||
optionalSpecialDomestic: "specialDomestic";
|
||||
defaultSpecialWar: "specialWar";
|
||||
availableSpecialWar: "specialWar";
|
||||
optionalSpecialWar: "specialWar";
|
||||
neutralPersonality: "personality";
|
||||
availablePersonality: "personality";
|
||||
optionalPersonality: "personality";
|
||||
allItems: "item";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export type HistoryObj = {
|
||||
server_id: string,
|
||||
year: number;
|
||||
month: number;
|
||||
map: MapResult,
|
||||
global_history: string[],
|
||||
global_action: string[],
|
||||
nations: {
|
||||
capital: number,
|
||||
cities: string[],
|
||||
color: string,
|
||||
gennum: number,
|
||||
level: number,
|
||||
name: string,
|
||||
nation: number,
|
||||
power: number,
|
||||
type: GameIActionKey
|
||||
}[],
|
||||
}
|
||||
server_id: string;
|
||||
year: number;
|
||||
month: number;
|
||||
map: MapResult;
|
||||
global_history: string[];
|
||||
global_action: string[];
|
||||
nations: {
|
||||
capital: number;
|
||||
cities: string[];
|
||||
color: string;
|
||||
gennum: number;
|
||||
level: number;
|
||||
name: string;
|
||||
nation: number;
|
||||
power: number;
|
||||
type: GameIActionKey;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type GetHistoryResponse = {
|
||||
result: true;
|
||||
data: HistoryObj & {
|
||||
hash: string;
|
||||
//no: number,
|
||||
};
|
||||
}
|
||||
result: true;
|
||||
data: HistoryObj & {
|
||||
hash: string;
|
||||
//no: number,
|
||||
};
|
||||
};
|
||||
|
||||
export type GetCurrentHistoryResponse = {
|
||||
result: true;
|
||||
data: HistoryObj;
|
||||
}
|
||||
|
||||
result: true;
|
||||
data: HistoryObj;
|
||||
};
|
||||
|
||||
export type GetDiplomacyResponse = {
|
||||
result: true;
|
||||
nations: SimpleNationObj[];
|
||||
conflict: [number, Record<number, number>][];
|
||||
diplomacyList: Record<number, Record<number, diplomacyState>>;
|
||||
myNationID: number;
|
||||
}
|
||||
result: true;
|
||||
nations: SimpleNationObj[];
|
||||
conflict: [number, Record<number, number>][];
|
||||
diplomacyList: Record<number, Record<number, diplomacyState>>;
|
||||
myNationID: number;
|
||||
};
|
||||
|
||||
export type ExecuteResponse = {
|
||||
result: true;
|
||||
updated: boolean;
|
||||
locked: boolean;
|
||||
lastExecuted: string;
|
||||
}
|
||||
result: true;
|
||||
updated: boolean;
|
||||
locked: boolean;
|
||||
lastExecuted: string;
|
||||
};
|
||||
|
||||
export type GetRecentRecordResponse = {
|
||||
result: true;
|
||||
history: [number, string][];
|
||||
global: [number, string][];
|
||||
general: [number, string][];
|
||||
flushHistory: 1 | 0;
|
||||
flushGlobal: 1 | 0;
|
||||
flushGeneral: 1 | 0;
|
||||
}
|
||||
result: true;
|
||||
history: [number, string][];
|
||||
global: [number, string][];
|
||||
general: [number, string][];
|
||||
flushHistory: 1 | 0;
|
||||
flushGlobal: 1 | 0;
|
||||
flushGeneral: 1 | 0;
|
||||
};
|
||||
|
||||
export type AutorunUserMode = "develop" | "warp" | "recruit" | "recruit_high" | "train" | "battle" | "chief";
|
||||
|
||||
export type GetFrontInfoResponse = {
|
||||
result: true;
|
||||
global: {
|
||||
scenarioText: string;
|
||||
extendedGeneral: 1 | 0;
|
||||
isFiction: 1 | 0;
|
||||
npcMode: 2 | 1 | 0;
|
||||
joinMode: "onlyRandom" | "full";
|
||||
startyear: number;
|
||||
year: number;
|
||||
month: number;
|
||||
autorunUser: AutorunUserMode[];
|
||||
turnterm: number;
|
||||
lastExecuted: string;
|
||||
lastVoteID: number;
|
||||
develCost: number;
|
||||
noticeMsg: number;
|
||||
onlineNations: string; //TODO: string[]으로 변경
|
||||
onlineUserCnt: number;
|
||||
apiLimit: number;
|
||||
auctionCount: number;
|
||||
isTournamentActive: boolean;
|
||||
isTournamentApplicationOpen: boolean;
|
||||
isBettingActive: boolean;
|
||||
isLocked: boolean;
|
||||
tournamentType: null | 0 | 1 | 2 | 3;
|
||||
tournamentState: string;
|
||||
genCount: number;
|
||||
generalCntLimit: number;
|
||||
lastVote: VoteInfo | null;
|
||||
};
|
||||
general: GeneralListItemP1 & {
|
||||
troopInfo?: {
|
||||
leader: {
|
||||
city: number;
|
||||
reservedCommand: GeneralListItemP1["reservedCommand"];
|
||||
};
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
nation: {
|
||||
id: number;
|
||||
name: string;
|
||||
population: {
|
||||
cityCnt: number;
|
||||
now: number;
|
||||
max: number;
|
||||
};
|
||||
crew: {
|
||||
generalCnt: number;
|
||||
now: number;
|
||||
max: number;
|
||||
};
|
||||
type: {
|
||||
raw: GameIActionKey;
|
||||
name: string;
|
||||
pros: string;
|
||||
cons: string;
|
||||
};
|
||||
color: string;
|
||||
level: NationLevel;
|
||||
capital: number;
|
||||
gold: number;
|
||||
rice: number;
|
||||
tech: number;
|
||||
gennum: number;
|
||||
power: number;
|
||||
bill: number;
|
||||
taxRate: number;
|
||||
onlineGen: string;
|
||||
notice: string;
|
||||
topChiefs: Record<
|
||||
11 | 12,
|
||||
{
|
||||
officer_level: number;
|
||||
no: number;
|
||||
name: string;
|
||||
npc: GeneralListItemP0["npc"];
|
||||
}
|
||||
>;
|
||||
officerLevelTexts: Record<number, string>;
|
||||
diplomaticLimit: number;
|
||||
strategicCmdLimit: number;
|
||||
impossibleStrategicCommand: [string, number][];
|
||||
prohibitScout: 1 | 0;
|
||||
prohibitWar: 1 | 0;
|
||||
};
|
||||
city: {
|
||||
id: number;
|
||||
name: string;
|
||||
nationInfo: {
|
||||
id: number;
|
||||
name: string;
|
||||
color: string;
|
||||
};
|
||||
level: number;
|
||||
trust: number;
|
||||
pop: [number, number];
|
||||
agri: [number, number];
|
||||
comm: [number, number];
|
||||
secu: [number, number];
|
||||
def: [number, number];
|
||||
wall: [number, number];
|
||||
trade: null | number;
|
||||
officerList: Record<
|
||||
2 | 3 | 4,
|
||||
{
|
||||
officer_level: 2 | 3 | 4;
|
||||
name: string;
|
||||
npc: GeneralListItemP0["npc"];
|
||||
} | null
|
||||
>;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user