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