implement SwapLineupCsReq

This commit is contained in:
memetrollsXD 2022-08-03 04:30:32 +02:00
parent 87c5fe3e0e
commit c4a02d7b80
No known key found for this signature in database
GPG Key ID: 105C2F3417AC32CD

View File

@ -0,0 +1,21 @@
import { SwapLineupCsReq, SwapLineupScRsp, SyncLineupNotify, SyncLineupReason } 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 SwapLineupCsReq;
session.send("SwapLineupScRsp", { retcode: 0 } as SwapLineupScRsp);
let lineup = await session.player.getLineup();
const _copy = lineup.avatarList[body.dstSlot];
lineup.avatarList[body.dstSlot] = lineup.avatarList[body.srcSlot];
lineup.avatarList[body.srcSlot] = _copy;
session.player.setLineup(lineup);
session.player.save();
session.send("SyncLineupNotify", {
lineup: lineup,
reasonList: [SyncLineupReason.SYNC_REASON_NONE]
} as SyncLineupNotify);
}