diff --git a/src/db/Player.ts b/src/db/Player.ts index c08b2d4..338dc35 100644 --- a/src/db/Player.ts +++ b/src/db/Player.ts @@ -1,4 +1,4 @@ -import { ExtraLineupType, LineupInfo, Vector } from "../data/proto/StarRail"; +import { ExtraLineupType, HeroBasicType, LineupInfo, Vector } from "../data/proto/StarRail"; import Logger from "../util/Logger"; import Account from "./Account"; import Avatar from "./Avatar"; @@ -20,6 +20,7 @@ interface PlayerI { name: string; token: string; banned: boolean; + heroBasicType: HeroBasicType; basicInfo: { nickname: string; level: number; @@ -101,6 +102,36 @@ export default class Player { _id: acc.uid, name: acc.name, token: acc.token, + heroBasicType: HeroBasicType.BoyWarrior, + basicInfo: { + exp: 0, + level: 1, + hcoin: 0, + mcoin: 0, + nickname: acc.name, + scoin: 0, + stamina: 100, + worldLevel: 1, + }, + lineup: { + curIndex: 0, + lineups: { + 0: { + avatarList: [1001], + extraLineupType: ExtraLineupType.LINEUP_NONE, + index: 0, + isVirtual: false, + leaderSlot: 0, + mp: 100, // ?? Not sure what this is + name: "Default Lineup", + planeId: 10001 + } + } + }, + posData: { + floorID: 10001001, + planeID: 10001 + }, banned: false } as PlayerI diff --git a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts index 91fb2da..121fe4f 100644 --- a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts +++ b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts @@ -3,15 +3,17 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { + let gender: Gender = (session.player.db.heroBasicType % 2 === 0) ? Gender.GenderWoman : Gender.GenderMan; + session.send("GetHeroBasicTypeInfoScRsp", { retcode: 0, - gender: Gender.GenderMan, + gender: gender, basicTypeInfoList: [{ - basicType: HeroBasicType.BoyMage, + basicType: session.player.db.heroBasicType, rank: 1, skillTreeList: [] }], - curBasicType: HeroBasicType.BoyMage, + curBasicType: session.player.db.heroBasicType, heroPathList: [], isPlayerInfoModified: false, isGenderModified: false diff --git a/src/server/packets/PlayerLoginCsReq.ts b/src/server/packets/PlayerLoginCsReq.ts index a7c0c65..ee8a12a 100644 --- a/src/server/packets/PlayerLoginCsReq.ts +++ b/src/server/packets/PlayerLoginCsReq.ts @@ -1,4 +1,4 @@ -import { AvatarType, ExtraLineupType, PlayerBasicInfo, PlayerLoginCsReq, PlayerLoginScRsp } from "../../data/proto/StarRail"; +import { AvatarType, ExtraLineupType, HeroBasicType, PlayerBasicInfo, PlayerLoginCsReq, PlayerLoginScRsp } from "../../data/proto/StarRail"; import Avatar from "../../db/Avatar"; import Player from "../../db/Player"; import Packet from "../kcp/Packet"; @@ -25,6 +25,11 @@ export default async function handle(session: Session, packet: Packet) { const plr = await Player.fromUID(session.player.db._id); if (!plr) return; + if (!plr.db.heroBasicType) { + plr.db.heroBasicType = HeroBasicType.BoyWarrior; + plr.save(); + } + if (!plr.db.basicInfo) { plr.db.basicInfo = { exp: 0,