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 <arifrh97z@gmail.com>
Co-authored-by: memetrollsXD <memetrollsxd@gmail.com>
This commit is contained in:
Areha11Fz 2022-08-02 21:13:37 +07:00 committed by GitHub
parent f7668fb783
commit 0ab4304f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import Avatar from "../db/Avatar"; import Avatar from "../db/Avatar";
import AvatarExcelTable from "../data/excel/AvatarExcelTable.json";
import Logger from "../util/Logger"; import Logger from "../util/Logger";
import Interface, { Command } from "./Interface"; import Interface, { Command } from "./Interface";
const c = new Logger("/avatar", "blue"); const c = new Logger("/avatar", "blue");
@ -14,21 +15,38 @@ export default async function handle(command: Command) {
const uid = Interface.target.player.db._id; const uid = Interface.target.player.db._id;
switch (actionType) { switch (actionType) {
default: default: {
c.log(`Usage: /avatar <add|remove> <avatarId>`); c.log(`Usage: /avatar <add|remove> <avatarId>`);
break; break;
case "add": }
case "add": {
if (!avatarId) return c.log("No avatarId specified"); if (!avatarId) return c.log("No avatarId specified");
// Check if it already exists // Check if it already exists
const avatar = await Avatar.fromUID(uid, avatarId); const avatar = await Avatar.fromUID(uid, avatarId);
if (avatar.length > 0) return c.log(`Avatar ${avatarId} already exists`); 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}`)); Avatar.create(uid, avatarId).then(a => c.log(`Avatar ${avatarId} added to ${a.ownerUid}`));
break; break;
case "remove": }
case "remove": {
if (!avatarId) return c.log("No avatarId specified"); if (!avatarId) return c.log("No avatarId specified");
Avatar.remove(uid, avatarId).then(() => c.log(`Avatar ${avatarId} removed from ${uid}`)); Avatar.remove(uid, avatarId).then(() => c.log(`Avatar ${avatarId} removed from ${uid}`));
break; 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(); Interface.target.sync();
} }

View File

@ -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);
}