Handle EnterMazeCsReq + GetGachaInfoCsReq (#12)

* Handle Packets:

- EnterMazeCsReq + Excel Handler
- GetGachaInfoCsReq

* Lost forced me to remove unknown...

* Fix formatting for snowflake codefactror
This commit is contained in:
memetrollsXD 2022-08-02 03:30:14 +02:00 committed by GitHub
parent b298649e30
commit a802a91173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 106 additions and 2 deletions

View File

@ -13,8 +13,8 @@ export default async function handle(command: Command) {
return;
}
Config.VERBOSE_LEVEL = level as unknown as VerboseLevel;
Logger.VERBOSE_LEVEL = level as unknown as VerboseLevel;
Config.VERBOSE_LEVEL = level as VerboseLevel;
Logger.VERBOSE_LEVEL = level as VerboseLevel;
c.log(`VerboseLevel set to ${Config.VERBOSE_LEVEL} (${VerboseLevel[level]})`);
}
}

View File

@ -0,0 +1,24 @@
import { EnterMazeCsReq, EnterMazeScRsp } from "../../data/proto/StarRail";
import MazePlaneExcel from "../../util/excel/MazePlaneExcel";
import Packet from "../kcp/Packet";
import Session from "../kcp/Session";
export default async function handle(session: Session, packet: Packet) {
const body = packet.body as EnterMazeCsReq;
const mazeEntry = MazePlaneExcel.fromEntryId(body.entryId);
session.send("EnterMazeScRsp", {
retcode: 0,
maze: {
floor: {
floorId: mazeEntry.StartFloorID,
scene: {
}
},
id: mazeEntry.PlaneID,
mapEntryId: body.entryId,
}
} as EnterMazeScRsp);
}

View File

@ -0,0 +1,22 @@
import { GetGachaInfoScRsp } from "../../data/proto/StarRail";
import Packet from "../kcp/Packet";
import Session from "../kcp/Session";
const unix = () => Math.floor(Date.now() / 1000);
export default async function handle(session: Session, packet: Packet) {
session.send("GetGachaInfoScRsp", {
gachaRandom: 2503,
retcode: 0,
gachaInfoList: [{
beginTime: unix(),
endTime: unix() * 2,
newbieGachaCnt: 10,
todayGachaCnt: 1,
gachaId: 763, // TODO: Figure out gachaIDs
detailWebview: "https://omfgdogs.com/"
}],
todaySingleGachaMaxCnt: 10,
todayTotalGachaCnt: 1,
} as GetGachaInfoScRsp);
}

View File

@ -0,0 +1,58 @@
import _MapEntryExcelTable from "../../data/excel/MapEntryExcelTable.json";
import _MazePlaneExcelTable from "../../data/excel/MazePlaneExcelTable.json";
interface MazePlaneExcelTableEntry {
PlaneID: number;
PlaneType: string;
SubType: number;
WorldID: number;
PlaneName: string;
StartFloorID: number;
FloorIDList: number[];
}
interface TextMap {
hash: number;
}
type EntranceType = "Town" | "Mission" | "Explore";
interface MapEntryExcelTableEntry {
ID: number;
IsShowInMapMenu: boolean;
MapMenuSortID: number;
EntranceType: EntranceType | number; // Actually an enum. Town | Mission | Explore
EntranceGroupID: number;
Name: TextMap;
Desc: TextMap;
EntranceListIcon: string;
ImagePath: string;
MiniMapIconHintList: any[];
ShowReward: number;
PlaneID: number;
FloorID: number;
StartGroupID: number;
StartAnchorID: number;
TargetMission: number;
TargetMainMissionList: number[];
BeginMainMissionList: number[];
FinishMainMissionList: number[];
FinishQuestList: number[];
UnlockQuest: number;
}
const MazePlaneExcelTable = _MazePlaneExcelTable as { [key: string]: MazePlaneExcelTableEntry };
const MapEntryExcelTable = _MapEntryExcelTable as { [key: string]: MapEntryExcelTableEntry };
export default class MazePlaneExcel {
private constructor() { }
public static fromEntryId(entryId: number): MazePlaneExcelTableEntry {
const mapEntry = MapEntryExcelTable[entryId.toString()];
return MazePlaneExcelTable[mapEntry.PlaneID.toString()];
}
public static fromPlaneId(planeId: number): MazePlaneExcelTableEntry {
return MazePlaneExcelTable[planeId.toString()];
}
}