From 0b7703141796dea18e4b37f7d810b7f93f0a0250 Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Tue, 2 Aug 2022 18:22:34 +0200 Subject: [PATCH] Basic challenge info --- src/server/packets/GetChallengeCsReq.ts | 17 +++++- .../packets/GetChallengeRaidInfoCsReq.ts | 16 ++++- .../excel/ChallengeActivityRaidConfigExcel.ts | 13 ++++ src/util/excel/RaidConfigExcel.ts | 60 +++++++++++++++++++ 4 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 src/util/excel/ChallengeActivityRaidConfigExcel.ts create mode 100644 src/util/excel/RaidConfigExcel.ts diff --git a/src/server/packets/GetChallengeCsReq.ts b/src/server/packets/GetChallengeCsReq.ts index 901b438..9acba58 100644 --- a/src/server/packets/GetChallengeCsReq.ts +++ b/src/server/packets/GetChallengeCsReq.ts @@ -1,10 +1,23 @@ import { GetChallengeScRsp } from "../../data/proto/StarRail"; +import ChallengeActivityRaidConfigExcel from "../../util/excel/ChallengeActivityRaidConfigExcel"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetChallengeScRsp", { + const activities = ChallengeActivityRaidConfigExcel.all(); + + const dataObj: GetChallengeScRsp = { retcode: 0, challengeList: [] - } as GetChallengeScRsp); + } + + activities.forEach(activity => { + dataObj.challengeList.push({ + challengeId: activity.ChallengeID, + stars: 0, + takenReward: 0 + }); + }); + + session.send("GetChallengeScRsp", dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetChallengeRaidInfoCsReq.ts b/src/server/packets/GetChallengeRaidInfoCsReq.ts index 7f8c02b..9cf1be9 100644 --- a/src/server/packets/GetChallengeRaidInfoCsReq.ts +++ b/src/server/packets/GetChallengeRaidInfoCsReq.ts @@ -1,11 +1,23 @@ import { GetChallengeRaidInfoScRsp } from "../../data/proto/StarRail"; +import RaidConfigExcel from "../../util/excel/RaidConfigExcel"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetChallengeRaidInfoScRsp", { + const activities = RaidConfigExcel.all(); + + const dataObj: GetChallengeRaidInfoScRsp = { retcode: 0, challengeRaidList: [], takenRewardIdList: [] - } as GetChallengeRaidInfoScRsp); + } + + activities.forEach(activity => { + dataObj.challengeRaidList.push({ + maxScore: 0, + raidId: activity.RaidID + }); + }) + + session.send("GetChallengeRaidInfoScRsp", dataObj); } \ No newline at end of file diff --git a/src/util/excel/ChallengeActivityRaidConfigExcel.ts b/src/util/excel/ChallengeActivityRaidConfigExcel.ts new file mode 100644 index 0000000..bf4337c --- /dev/null +++ b/src/util/excel/ChallengeActivityRaidConfigExcel.ts @@ -0,0 +1,13 @@ +import ChallengeActivityRaidConfigExcelTable from "../../data/excel/ChallengeActivityRaidConfigExcelTable.json"; + +export default class ChallengeActivityRaidConfigExcel { + private constructor() { } + + public static fromId(id: number) { + return Object.values(ChallengeActivityRaidConfigExcelTable).find(x => x.ChallengeID === id); + } + + public static all() { + return Object.values(ChallengeActivityRaidConfigExcelTable); + } +} \ No newline at end of file diff --git a/src/util/excel/RaidConfigExcel.ts b/src/util/excel/RaidConfigExcel.ts new file mode 100644 index 0000000..91d8d30 --- /dev/null +++ b/src/util/excel/RaidConfigExcel.ts @@ -0,0 +1,60 @@ +import _RaidConfigExcelTable from "../../data/excel/RaidConfigExcelTable.json"; +const RaidConfigExcelTable = _RaidConfigExcelTable as { [key: string]: RaidConfigExcelTableEntry }; + +interface TextMap { + hash: number; +} + +interface Param { + RawValue: number; +} + +interface RaidConfigExcelTableEntry { + RaidID: number; + WorldLevel: number; + Type: string; + MappingInfoID: number; + MonsterList: number[]; + MonsterHideList: number[]; + DisplayEventID: number; + RaidName: TextMap; + RaidDesc: TextMap; + MapEntranceID: number; + GroupID: number; + ConfigIDList: number[]; + NpcMonsterIDList: number[]; + PlaneEventIDList: number[]; + BuffDesc: TextMap; + ParamList: Param[]; + LimitIDList: number[]; + RecoverType: string[]; + FinishType: string; + FinishParamList: number[]; + FinishAutoQuit: boolean; + DropList: number[]; + StaminaCost: number; + FailedType: string; + FailedResult: string; + LogoutType: string; + TeamType: string; + TrialAvatarList: number[]; + MainMissionID: number; + IsEntryByProp: boolean; +} + +export default class RaidExcelConfig { + private constructor() { } + + public static fromId(id: number, wl: number = 0) { + const key = `${id}:${wl}`; + return RaidConfigExcelTable[key]; + } + + public static all() { + return Object.values(RaidConfigExcelTable); + } + + public static find(id: number) { + return Object.values(RaidConfigExcelTable).find(x => x.RaidID === id); + } +} \ No newline at end of file