Fallback on lineupname
This commit is contained in:
parent
a06f36f46b
commit
d7e0d42906
@ -1,5 +1,5 @@
|
||||
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 Account from "./Account";
|
||||
import Avatar from "./Avatar";
|
||||
@ -77,6 +77,15 @@ export default class Player {
|
||||
const avatars = await Avatar.fromLineup(this.uid, lineup);
|
||||
let slot = 0;
|
||||
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++;
|
||||
});
|
||||
return {
|
||||
|
@ -5,10 +5,14 @@ import Session from "../kcp/Session";
|
||||
export default async function handle(session: Session, packet: Packet) {
|
||||
const body = packet.body as SetLineupNameCsReq;
|
||||
|
||||
let curLineup = await session.player.getLineup();
|
||||
curLineup.name = body.name;
|
||||
session.player.setLineup(curLineup);
|
||||
session.player.save();
|
||||
try {
|
||||
let curLineup = await session.player.getLineup();
|
||||
curLineup.name = body.name;
|
||||
session.player.setLineup(curLineup);
|
||||
session.player.save();
|
||||
} catch {
|
||||
session.c.error("Failed to set lineup name", false);
|
||||
}
|
||||
|
||||
session.send("SetLineupNameScRsp", {
|
||||
retcode: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user