From c4a02d7b803bcdd20e39641ff39d7dac54df25a0 Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Wed, 3 Aug 2022 04:30:32 +0200 Subject: [PATCH] implement SwapLineupCsReq --- src/server/packets/SwapLineupCsReq.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/server/packets/SwapLineupCsReq.ts diff --git a/src/server/packets/SwapLineupCsReq.ts b/src/server/packets/SwapLineupCsReq.ts new file mode 100644 index 0000000..f22c944 --- /dev/null +++ b/src/server/packets/SwapLineupCsReq.ts @@ -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); +} \ No newline at end of file