From f5d5808ca9f57d17d946f52a881af480069b801a Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Sun, 31 Jul 2022 18:29:57 +0200 Subject: [PATCH] fix more factoring issues --- src/db/Database.ts | 6 +++--- src/server/packets/GetAllLineupDataCsReq.ts | 4 +--- src/server/packets/GetAvatarDataCsReq.ts | 2 +- src/server/packets/GetBagCsReq.ts | 4 +--- src/server/packets/GetBasicInfoCsReq.ts | 4 +--- src/server/packets/GetChallengeCsReq.ts | 4 +--- src/server/packets/GetChallengeRaidInfoCsReq.ts | 4 +--- src/server/packets/GetCurBattleInfoCsReq.ts | 4 +--- src/server/packets/GetCurLineupDataCsReq.ts | 4 +--- src/server/packets/GetCurSceneInfoCsReq.ts | 4 +--- src/server/packets/GetDialogueEventDataCsReq.ts | 4 +--- src/server/packets/GetExpeditionDataCsReq.ts | 4 +--- src/server/packets/GetFirstTalkNpcCsReq.ts | 4 +--- src/server/packets/GetHeroBasicTypeInfoCsReq.ts | 4 +--- src/server/packets/GetHeroPathCsReq.ts | 4 +--- src/server/packets/GetLevelRewardTakenListCsReq.ts | 4 +--- src/server/packets/GetLoginActivityCsReq.ts | 4 +--- src/server/packets/GetMailCsReq.ts | 4 +--- src/server/packets/GetMazeTimeOfDayCsReq.ts | 4 +--- src/server/packets/GetMissionDataCsReq.ts | 4 +--- src/server/packets/GetMissionEventDataCsReq.ts | 4 +--- src/server/packets/GetNpcStatusCsReq.ts | 4 +--- src/server/packets/GetQuestDataCsReq.ts | 4 +--- src/server/packets/GetRogueInfoCsReq.ts | 4 +--- src/server/packets/GetSpringRecoverDataCsReq.ts | 4 +--- src/server/packets/PlayerKeepAliveNotify.ts | 3 --- 26 files changed, 27 insertions(+), 76 deletions(-) diff --git a/src/db/Database.ts b/src/db/Database.ts index 00cd847..34aeb04 100644 --- a/src/db/Database.ts +++ b/src/db/Database.ts @@ -22,7 +22,7 @@ export default class Database { return Database.instance; } - public async get(collection: string, query?: {}) { + public async get(collection: string, query?: object) { try { const db = await Database.client.db(); const _collection = db.collection(collection); @@ -52,7 +52,7 @@ export default class Database { } } - public async delete(collection: string, query: {}) { + public async delete(collection: string, query: object) { try { const db = await Database.client.db(); const _collection = db.collection(collection); @@ -66,7 +66,7 @@ export default class Database { } } - public async update(collection: string, query: {}, payload: {}) { + public async update(collection: string, query: object, payload: object) { try { const db = await Database.client.db(); const _collection = db.collection(collection); diff --git a/src/server/packets/GetAllLineupDataCsReq.ts b/src/server/packets/GetAllLineupDataCsReq.ts index 22fc5f5..734d2f1 100644 --- a/src/server/packets/GetAllLineupDataCsReq.ts +++ b/src/server/packets/GetAllLineupDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetAllLineupDataCsReq, GetAllLineupDataScRsp } from "../../data/proto/StarRail"; +import { GetAllLineupDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetAllLineupDataCsReq; - session.send("GetAllLineupDataScRsp", { retcode: 0, lineupList: [] diff --git a/src/server/packets/GetAvatarDataCsReq.ts b/src/server/packets/GetAvatarDataCsReq.ts index 22cbc98..adfdceb 100644 --- a/src/server/packets/GetAvatarDataCsReq.ts +++ b/src/server/packets/GetAvatarDataCsReq.ts @@ -1,4 +1,4 @@ -import { ActivateFarmElementCsReq, GetAvatarDataCsReq, GetAvatarDataScRsp } from "../../data/proto/StarRail"; +import { GetAvatarDataCsReq, GetAvatarDataScRsp } from "../../data/proto/StarRail"; import AvatarExcelTable from "../../data/excel/AvatarExcelTable.json"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; diff --git a/src/server/packets/GetBagCsReq.ts b/src/server/packets/GetBagCsReq.ts index 9c1ad85..08c1914 100644 --- a/src/server/packets/GetBagCsReq.ts +++ b/src/server/packets/GetBagCsReq.ts @@ -1,10 +1,8 @@ -import { GetBagCsReq, GetBagScRsp } from "../../data/proto/StarRail"; +import { GetBagScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetBagCsReq; - session.send("GetBagScRsp", { equipmentList: [], materialList: [], diff --git a/src/server/packets/GetBasicInfoCsReq.ts b/src/server/packets/GetBasicInfoCsReq.ts index a83f0bb..471f0f6 100644 --- a/src/server/packets/GetBasicInfoCsReq.ts +++ b/src/server/packets/GetBasicInfoCsReq.ts @@ -1,10 +1,8 @@ -import { GetBasicInfoCsReq, GetBasicInfoScRsp } from "../../data/proto/StarRail"; +import { GetBasicInfoScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetBasicInfoCsReq; - session.send("GetBasicInfoScRsp", { curDay: 1, exchangeTimes: 0, diff --git a/src/server/packets/GetChallengeCsReq.ts b/src/server/packets/GetChallengeCsReq.ts index 325d044..901b438 100644 --- a/src/server/packets/GetChallengeCsReq.ts +++ b/src/server/packets/GetChallengeCsReq.ts @@ -1,10 +1,8 @@ -import { GetChallengeCsReq, GetChallengeScRsp } from "../../data/proto/StarRail"; +import { GetChallengeScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetChallengeCsReq; - session.send("GetChallengeScRsp", { retcode: 0, challengeList: [] diff --git a/src/server/packets/GetChallengeRaidInfoCsReq.ts b/src/server/packets/GetChallengeRaidInfoCsReq.ts index d3bad49..7f8c02b 100644 --- a/src/server/packets/GetChallengeRaidInfoCsReq.ts +++ b/src/server/packets/GetChallengeRaidInfoCsReq.ts @@ -1,10 +1,8 @@ -import { GetChallengeRaidInfoCsReq, GetChallengeRaidInfoScRsp } from "../../data/proto/StarRail"; +import { GetChallengeRaidInfoScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetChallengeRaidInfoCsReq; - session.send("GetChallengeRaidInfoScRsp", { retcode: 0, challengeRaidList: [], diff --git a/src/server/packets/GetCurBattleInfoCsReq.ts b/src/server/packets/GetCurBattleInfoCsReq.ts index 525ab5b..15dc9d4 100644 --- a/src/server/packets/GetCurBattleInfoCsReq.ts +++ b/src/server/packets/GetCurBattleInfoCsReq.ts @@ -1,10 +1,8 @@ -import { AvatarType, BattleEndStatus, GetCurBattleInfoCsReq, GetCurBattleInfoScRsp } from "../../data/proto/StarRail"; +import { AvatarType, BattleEndStatus, GetCurBattleInfoScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetCurBattleInfoCsReq; - session.send("GetCurBattleInfoScRsp", { retcode: 0, avatarList: [{ diff --git a/src/server/packets/GetCurLineupDataCsReq.ts b/src/server/packets/GetCurLineupDataCsReq.ts index 16cc498..7f1a6e4 100644 --- a/src/server/packets/GetCurLineupDataCsReq.ts +++ b/src/server/packets/GetCurLineupDataCsReq.ts @@ -1,10 +1,8 @@ -import { AvatarSlotType, AvatarType, GetCurLineupDataCsReq, GetCurLineupDataScRsp } from "../../data/proto/StarRail"; +import { AvatarType, GetCurLineupDataCsReq, GetCurLineupDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetCurLineupDataCsReq; - session.send("GetCurLineupDataScRsp", { retcode: 0, lineup: { diff --git a/src/server/packets/GetCurSceneInfoCsReq.ts b/src/server/packets/GetCurSceneInfoCsReq.ts index 4891d8a..ae5b40f 100644 --- a/src/server/packets/GetCurSceneInfoCsReq.ts +++ b/src/server/packets/GetCurSceneInfoCsReq.ts @@ -1,10 +1,8 @@ -import { GetCurSceneInfoCsReq, GetCurSceneInfoScRsp } from "../../data/proto/StarRail"; +import { GetCurSceneInfoScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetCurSceneInfoCsReq; - session.send("GetCurSceneInfoScRsp", { retcode: 0, scene: { diff --git a/src/server/packets/GetDialogueEventDataCsReq.ts b/src/server/packets/GetDialogueEventDataCsReq.ts index 15eb14f..0af2e98 100644 --- a/src/server/packets/GetDialogueEventDataCsReq.ts +++ b/src/server/packets/GetDialogueEventDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetDialogueEventDataCsReq, GetDialogueEventDataScRsp } from "../../data/proto/StarRail"; +import { GetDialogueEventDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetDialogueEventDataCsReq; - session.send("GetDialogueEventDataScRsp", { dialogueEventList: [], retcode: 0 diff --git a/src/server/packets/GetExpeditionDataCsReq.ts b/src/server/packets/GetExpeditionDataCsReq.ts index 2a2e532..a2b23ca 100644 --- a/src/server/packets/GetExpeditionDataCsReq.ts +++ b/src/server/packets/GetExpeditionDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetExpeditionDataCsReq, GetExpeditionDataScRsp } from "../../data/proto/StarRail"; +import { GetExpeditionDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetExpeditionDataCsReq; - session.send("GetExpeditionDataScRsp", { retcode: 0, expedtionList: [], diff --git a/src/server/packets/GetFirstTalkNpcCsReq.ts b/src/server/packets/GetFirstTalkNpcCsReq.ts index 73dd33f..efa2624 100644 --- a/src/server/packets/GetFirstTalkNpcCsReq.ts +++ b/src/server/packets/GetFirstTalkNpcCsReq.ts @@ -1,10 +1,8 @@ -import { GetFirstTalkNpcCsReq, GetFirstTalkNpcScRsp } from "../../data/proto/StarRail"; +import { GetFirstTalkNpcScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetFirstTalkNpcCsReq; - session.send("GetFirstTalkNpcScRsp", { retcode: 0, } as GetFirstTalkNpcScRsp); diff --git a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts index d704930..91fb2da 100644 --- a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts +++ b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts @@ -1,10 +1,8 @@ -import { Gender, GetHeroBasicTypeInfoCsReq, GetHeroBasicTypeInfoScRsp, HeroBasicType } from "../../data/proto/StarRail"; +import { Gender, GetHeroBasicTypeInfoScRsp, HeroBasicType } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetHeroBasicTypeInfoCsReq; - session.send("GetHeroBasicTypeInfoScRsp", { retcode: 0, gender: Gender.GenderMan, diff --git a/src/server/packets/GetHeroPathCsReq.ts b/src/server/packets/GetHeroPathCsReq.ts index d27b668..950fa71 100644 --- a/src/server/packets/GetHeroPathCsReq.ts +++ b/src/server/packets/GetHeroPathCsReq.ts @@ -1,10 +1,8 @@ -import { GetHeroPathCsReq, GetHeroPathScRsp } from "../../data/proto/StarRail"; +import { GetHeroPathScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetHeroPathCsReq; - session.send("GetHeroPathScRsp", { retcode: 0, heroPathList: [] diff --git a/src/server/packets/GetLevelRewardTakenListCsReq.ts b/src/server/packets/GetLevelRewardTakenListCsReq.ts index aefb117..766e8b5 100644 --- a/src/server/packets/GetLevelRewardTakenListCsReq.ts +++ b/src/server/packets/GetLevelRewardTakenListCsReq.ts @@ -1,10 +1,8 @@ -import { GetLevelRewardTakenListCsReq, GetLevelRewardTakenListScRsp } from "../../data/proto/StarRail"; +import { GetLevelRewardTakenListScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetLevelRewardTakenListCsReq; - session.send("GetLevelRewardTakenListScRsp", { retcode: 0, takenLevelList: [] diff --git a/src/server/packets/GetLoginActivityCsReq.ts b/src/server/packets/GetLoginActivityCsReq.ts index d9b16f7..fa920ca 100644 --- a/src/server/packets/GetLoginActivityCsReq.ts +++ b/src/server/packets/GetLoginActivityCsReq.ts @@ -1,10 +1,8 @@ -import { GetLoginActivityCsReq, GetLoginActivityScRsp } from "../../data/proto/StarRail"; +import { GetLoginActivityScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetLoginActivityCsReq; - session.send("GetLoginActivityScRsp", { retcode: 0, loginActivityList: [] diff --git a/src/server/packets/GetMailCsReq.ts b/src/server/packets/GetMailCsReq.ts index 40b9cb3..13f4a7d 100644 --- a/src/server/packets/GetMailCsReq.ts +++ b/src/server/packets/GetMailCsReq.ts @@ -1,10 +1,8 @@ -import { GetMailCsReq, GetMailScRsp } from "../../data/proto/StarRail"; +import { GetMailScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetMailCsReq; - session.send("GetMailScRsp", { retcode: 0, mailList: [], diff --git a/src/server/packets/GetMazeTimeOfDayCsReq.ts b/src/server/packets/GetMazeTimeOfDayCsReq.ts index 30bf2db..c76c2da 100644 --- a/src/server/packets/GetMazeTimeOfDayCsReq.ts +++ b/src/server/packets/GetMazeTimeOfDayCsReq.ts @@ -1,10 +1,8 @@ -import { GetMazeTimeOfDayCsReq, GetMazeTimeOfDayScRsp } from "../../data/proto/StarRail"; +import { GetMazeTimeOfDayScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetMazeTimeOfDayCsReq; - session.send("GetMazeTimeOfDayScRsp", { retcode: 0, mazeTimeOfDayMap: {} diff --git a/src/server/packets/GetMissionDataCsReq.ts b/src/server/packets/GetMissionDataCsReq.ts index 01507f8..93cae07 100644 --- a/src/server/packets/GetMissionDataCsReq.ts +++ b/src/server/packets/GetMissionDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetMissionDataCsReq, GetMissionDataScRsp } from "../../data/proto/StarRail"; +import { GetMissionDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetMissionDataCsReq; - session.send("GetMissionDataScRsp", { retcode: 0, missionList: [] diff --git a/src/server/packets/GetMissionEventDataCsReq.ts b/src/server/packets/GetMissionEventDataCsReq.ts index 261e344..cf37c30 100644 --- a/src/server/packets/GetMissionEventDataCsReq.ts +++ b/src/server/packets/GetMissionEventDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetMissionEventDataCsReq, GetMissionEventDataScRsp } from "../../data/proto/StarRail"; +import { GetMissionEventDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetMissionEventDataCsReq; - session.send("GetMissionEventDataScRsp", { retcode: 0, missionEventList: [] diff --git a/src/server/packets/GetNpcStatusCsReq.ts b/src/server/packets/GetNpcStatusCsReq.ts index d941df2..040538a 100644 --- a/src/server/packets/GetNpcStatusCsReq.ts +++ b/src/server/packets/GetNpcStatusCsReq.ts @@ -1,10 +1,8 @@ -import { GetNpcStatusCsReq, GetNpcStatusScRsp } from "../../data/proto/StarRail"; +import { GetNpcStatusScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetNpcStatusCsReq; - session.send("GetNpcStatusScRsp", { retcode: 0, messageStatusList: [] diff --git a/src/server/packets/GetQuestDataCsReq.ts b/src/server/packets/GetQuestDataCsReq.ts index 102deab..599a783 100644 --- a/src/server/packets/GetQuestDataCsReq.ts +++ b/src/server/packets/GetQuestDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetQuestDataCsReq, GetQuestDataScRsp } from "../../data/proto/StarRail"; +import { GetQuestDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetQuestDataCsReq; - session.send("GetQuestDataScRsp", { questList: [], retcode: 0, diff --git a/src/server/packets/GetRogueInfoCsReq.ts b/src/server/packets/GetRogueInfoCsReq.ts index a360eec..7d17545 100644 --- a/src/server/packets/GetRogueInfoCsReq.ts +++ b/src/server/packets/GetRogueInfoCsReq.ts @@ -1,10 +1,8 @@ -import { GetRogueInfoCsReq, GetRogueInfoScRsp, RogueStatus } from "../../data/proto/StarRail"; +import { GetRogueInfoScRsp, RogueStatus } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetRogueInfoCsReq; - session.send("GetRogueInfoScRsp", { retcode: 0, rogueInfo: { diff --git a/src/server/packets/GetSpringRecoverDataCsReq.ts b/src/server/packets/GetSpringRecoverDataCsReq.ts index ede3959..75dd1c6 100644 --- a/src/server/packets/GetSpringRecoverDataCsReq.ts +++ b/src/server/packets/GetSpringRecoverDataCsReq.ts @@ -1,10 +1,8 @@ -import { GetSpringRecoverDataCsReq, GetSpringRecoverDataScRsp } from "../../data/proto/StarRail"; +import { GetSpringRecoverDataScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as GetSpringRecoverDataCsReq; - session.send("GetSpringRecoverDataScRsp", { retcode: 0, healPoolInfo: { diff --git a/src/server/packets/PlayerKeepAliveNotify.ts b/src/server/packets/PlayerKeepAliveNotify.ts index 046ac41..0916100 100644 --- a/src/server/packets/PlayerKeepAliveNotify.ts +++ b/src/server/packets/PlayerKeepAliveNotify.ts @@ -1,9 +1,6 @@ -import { PlayerKeepAliveNotify } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - const body = packet.body as PlayerKeepAliveNotify; - // We actually don't need to handle this } \ No newline at end of file