Commit f83338e9 authored by Chunchi Che's avatar Chunchi Che

finish

parent e3b0dc68
...@@ -11,6 +11,7 @@ import adaptSelectOptionResponse from "./selectOption"; ...@@ -11,6 +11,7 @@ import adaptSelectOptionResponse from "./selectOption";
import adaptSelectBattleCmdResponse from "./selectBattleCmd"; import adaptSelectBattleCmdResponse from "./selectBattleCmd";
import adaptSelectUnselectCardResponse from "./selectUnselectCard"; import adaptSelectUnselectCardResponse from "./selectUnselectCard";
import adaptSelectCounterResponse from "./selectCounter"; import adaptSelectCounterResponse from "./selectCounter";
import adaptSortCardResponse from "./sortCard";
/* /*
* CTOS CTOS_RESPONSE * CTOS CTOS_RESPONSE
...@@ -80,6 +81,11 @@ export default class CtosResponsePacket extends YgoProPacket { ...@@ -80,6 +81,11 @@ export default class CtosResponsePacket extends YgoProPacket {
break; break;
} }
case "sort_card": {
extraData = adaptSortCardResponse(response.sort_card);
break;
}
default: { default: {
break; break;
} }
......
import { ygopro } from "../../../idl/ocgcore";
// @ts-ignore
import { BufferWriter } from "rust-src";
export default (response: ygopro.CtosGameMsgResponse.SortCardResponse) => {
const writer = new BufferWriter();
for (const index of response.sorted_index) {
writer.writeUint8(index);
}
return writer.toArray();
};
...@@ -282,3 +282,16 @@ export function sendSelectCounterResponse(counts: number[]) { ...@@ -282,3 +282,16 @@ export function sendSelectCounterResponse(counts: number[]) {
socketMiddleWare({ cmd: socketCmd.SEND, payload }); socketMiddleWare({ cmd: socketCmd.SEND, payload });
} }
export function sendSortCardResponse(sortedIndexes: number[]) {
const response = new ygopro.YgoCtosMsg({
ctos_response: new ygopro.CtosGameMsgResponse({
sort_card: new ygopro.CtosGameMsgResponse.SortCardResponse({
sorted_index: sortedIndexes,
}),
}),
});
const payload = new GameMsgResponse(response).serialize();
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
import { useAppSelector } from "../../hook"; import { useAppSelector } from "../../hook";
import { selectSortCardModal } from "../../reducers/duel/modal/sortCardModalSlice"; import { selectSortCardModal } from "../../reducers/duel/modal/sortCardModalSlice";
import { sendSelectCardResponse } from "../../api/ocgcore/ocgHelper"; import { sendSortCardResponse } from "../../api/ocgcore/ocgHelper";
import { store } from "../../store"; import { store } from "../../store";
import { resetSortCardModal } from "../../reducers/duel/mod"; import { resetSortCardModal } from "../../reducers/duel/mod";
import DragModal from "./dragModal"; import DragModal from "./dragModal";
...@@ -41,7 +41,7 @@ const SortCardModal = () => { ...@@ -41,7 +41,7 @@ const SortCardModal = () => {
const draggleRef = useRef<HTMLDivElement>(null); const draggleRef = useRef<HTMLDivElement>(null);
const onFinish = () => { const onFinish = () => {
sendSelectCardResponse(items.map((item) => item.response)); sendSortCardResponse(items.map((item) => item.response));
dispatch(resetSortCardModal()); dispatch(resetSortCardModal());
}; };
const onDragEnd = (event: DragEndEvent) => { const onDragEnd = (event: DragEndEvent) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment