Commit 6fd15a9a authored by chechunchi's avatar chechunchi

handle swap_grave_deck

parent 80a60319
......@@ -225,5 +225,14 @@
"fieldType": "uint8"
}
]
},
"35": {
"protoType": "swap_grave_deck",
"fields": [
{
"fieldName": "player",
"fieldType": "uint8"
}
]
}
}
......@@ -36,6 +36,7 @@ const MsgConstructorMap: Map<string, Constructor> = new Map([
["become_target", ygopro.StocGameMessage.MsgBecomeTarget],
["shuffle_deck", ygopro.StocGameMessage.MsgShuffleDeck],
["rock_paper_scissors", ygopro.StocGameMessage.MsgRockPaperScissors],
["swap_grave_deck", ygopro.StocGameMessage.MsgSwapGraveDeck]
]);
export interface penetrateType {
......
......@@ -54,6 +54,7 @@ import onMsgUpdateData from "./updateData";
import onMsgUpdateHp from "./updateHp";
import onMsgWait from "./wait";
import onMsgWin from "./win";
import onMsgSwapGraveDeck from "./swapGraveDeck";
const ActiveList = [
"select_idle_cmd",
......@@ -339,6 +340,11 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "swap_grave_deck": {
await onMsgSwapGraveDeck(msg.swap_grave_deck);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented);
......
import { ygopro } from "@/api";
import { eventbus, Task } from "@/infra";
import { cardStore } from "@/stores";
import MsgSwapGraveDeck = ygopro.StocGameMessage.MsgSwapGraveDeck;
const {DECK, GRAVE} = ygopro.CardZone;
export default async (swapGraveDeck: MsgSwapGraveDeck) => {
const player = swapGraveDeck.player;
const deck = cardStore.at(DECK, player);
const grave = cardStore.at(GRAVE, player);
for (const card of deck) {
card.location.zone = GRAVE;
await eventbus.call(Task.Move, card.uuid);
}
for (const card of grave) {
card.location.zone = DECK;
await eventbus.call(Task.Move, card.uuid);
}
};
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