Commit c34e2a38 authored by Chunchi Che's avatar Chunchi Che

handle select_counter_response

parent 2984f1c7
......@@ -102,6 +102,14 @@ impl BufferWriter {
self.array.extend(value.to_le_bytes());
}
pub fn writeUint16(&mut self, value: u16) {
self.array.extend(value.to_le_bytes());
}
pub fn writeInt16(&mut self, value: i16) {
self.array.extend(value.to_le_bytes());
}
pub fn writeUint32(&mut self, value: u32) {
self.array.extend(value.to_le_bytes());
}
......
......@@ -10,6 +10,7 @@ import adaptSelectPositionResponse from "./selectPosition";
import adaptSelectOptionResponse from "./selectOption";
import adaptSelectBattleCmdResponse from "./selectBattleCmd";
import adaptSelectUnselectCardResponse from "./selectUnselectCard";
import adaptSelectCounterResponse from "./selectCounter";
/*
* CTOS CTOS_RESPONSE
......@@ -72,6 +73,13 @@ export default class CtosResponsePacket extends YgoProPacket {
break;
}
case "select_counter_response": {
extraData = adaptSelectCounterResponse(
response.select_counter_response
);
break;
}
default: {
break;
}
......
import { ygopro } from "../../../idl/ocgcore";
// @ts-ignore
import { BufferWriter } from "rust-src";
export default (response: ygopro.CtosGameMsgResponse.SelectCounterResponse) => {
const writer = new BufferWriter();
for (const count of response.selected_count) {
writer.writeInt16(count);
}
return writer.toArray();
};
......@@ -268,3 +268,17 @@ export function sendSelectUnselectCardResponse(value: {
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
export function sendSelectCounterResponse(counts: number[]) {
const response = new ygopro.YgoCtosMsg({
ctos_response: new ygopro.CtosGameMsgResponse({
select_counter_response:
new ygopro.CtosGameMsgResponse.SelectCounterResponse({
selected_count: counts,
}),
}),
});
const payload = new GameMsgResponse(response).serialize();
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
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