From 0ab4304f782fb1dbcac00035d3bf5fb08f16ee8f Mon Sep 17 00:00:00 2001 From: Areha11Fz Date: Tue, 2 Aug 2022 21:13:37 +0700 Subject: [PATCH] Basic Map Info Handler, Simple Giveall and Removeall Command (#17) * Change log color * Basic Floor Handler * Fix logger * Logger Back to All White * Add lightenSectionList to unlock area as explored * LET * Add giveall and removeall * CONST * lint * Left 1001 * Small grammar changes Co-authored-by: Areha11Fz Co-authored-by: memetrollsXD --- src/commands/avatar.ts | 26 +++++++++++++++++++---- src/server/packets/GetMazeMapInfoCsReq.ts | 24 +++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/server/packets/GetMazeMapInfoCsReq.ts diff --git a/src/commands/avatar.ts b/src/commands/avatar.ts index d455b1e..2aa8d81 100644 --- a/src/commands/avatar.ts +++ b/src/commands/avatar.ts @@ -1,4 +1,5 @@ import Avatar from "../db/Avatar"; +import AvatarExcelTable from "../data/excel/AvatarExcelTable.json"; import Logger from "../util/Logger"; import Interface, { Command } from "./Interface"; const c = new Logger("/avatar", "blue"); @@ -14,21 +15,38 @@ export default async function handle(command: Command) { const uid = Interface.target.player.db._id; switch (actionType) { - default: + default: { c.log(`Usage: /avatar `); break; - case "add": + } + case "add": { if (!avatarId) return c.log("No avatarId specified"); // Check if it already exists const avatar = await Avatar.fromUID(uid, avatarId); if (avatar.length > 0) return c.log(`Avatar ${avatarId} already exists`); Avatar.create(uid, avatarId).then(a => c.log(`Avatar ${avatarId} added to ${a.ownerUid}`)); break; - case "remove": + } + case "remove": { if (!avatarId) return c.log("No avatarId specified"); Avatar.remove(uid, avatarId).then(() => c.log(`Avatar ${avatarId} removed from ${uid}`)); break; + } + case "giveall": { + for (const id in AvatarExcelTable) { + Avatar.create(uid, parseInt(id)).then(() => c.log(`All avatars added to ${uid}`)); + } + break; + } + case "removeall": { + for (const id in AvatarExcelTable) { + if (!(id == '1001')) { + Avatar.remove(uid, parseInt(id)).then(() => c.log(`All avatars removed from ${uid}`)); + } + } + break; + } } Interface.target.sync(); -} \ No newline at end of file +} diff --git a/src/server/packets/GetMazeMapInfoCsReq.ts b/src/server/packets/GetMazeMapInfoCsReq.ts new file mode 100644 index 0000000..7875f10 --- /dev/null +++ b/src/server/packets/GetMazeMapInfoCsReq.ts @@ -0,0 +1,24 @@ +import { GetMazeMapInfoScRsp } 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 GetMazeMapInfoScRsp; + + const dataObj = { + retcode: 0, + entryId: body.entryId, + lightenSectionList: [], + mazePropList: [{ groupId: 0, configId: 0, state: 0 }], + mazeGroupList: [{ groupId: 0, modifyTime: 0 }], + opendChestNum: 0, + unlockTeleportList: [] + } as GetMazeMapInfoScRsp; + + // TODO: No excel info atm + for (let i = 0; i < 20; i++) { + dataObj.lightenSectionList.push(i) + } + + session.send("GetMazeMapInfoScRsp", dataObj); +} \ No newline at end of file