Fallback on lineupname

This commit is contained in:
memetrollsXD 2022-08-02 19:00:47 +02:00
parent a06f36f46b
commit d7e0d42906
No known key found for this signature in database
GPG Key ID: 105C2F3417AC32CD
2 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import Session from "../server/kcp/Session"; import Session from "../server/kcp/Session";
import { ExtraLineupType, HeroBasicType, LineupInfo, Vector } from "../data/proto/StarRail"; import { AvatarType, ExtraLineupType, HeroBasicType, LineupInfo, Vector } from "../data/proto/StarRail";
import Logger from "../util/Logger"; import Logger from "../util/Logger";
import Account from "./Account"; import Account from "./Account";
import Avatar from "./Avatar"; import Avatar from "./Avatar";
@ -77,6 +77,15 @@ export default class Player {
const avatars = await Avatar.fromLineup(this.uid, lineup); const avatars = await Avatar.fromLineup(this.uid, lineup);
let slot = 0; let slot = 0;
avatars.forEach(avatar => { avatars.forEach(avatar => {
// Fallback lineup
if (!avatar.lineup) avatar.lineup = {
avatarType: AvatarType.AVATAR_FORMAL_TYPE,
hp: 10000,
id: 1001,
satiety: 100,
slot: slot,
sp: 10000
}
avatar.lineup.slot = slot++; avatar.lineup.slot = slot++;
}); });
return { return {

View File

@ -5,10 +5,14 @@ import Session from "../kcp/Session";
export default async function handle(session: Session, packet: Packet) { export default async function handle(session: Session, packet: Packet) {
const body = packet.body as SetLineupNameCsReq; const body = packet.body as SetLineupNameCsReq;
let curLineup = await session.player.getLineup(); try {
curLineup.name = body.name; let curLineup = await session.player.getLineup();
session.player.setLineup(curLineup); curLineup.name = body.name;
session.player.save(); session.player.setLineup(curLineup);
session.player.save();
} catch {
session.c.error("Failed to set lineup name", false);
}
session.send("SetLineupNameScRsp", { session.send("SetLineupNameScRsp", {
retcode: 0, retcode: 0,