Commit e585e471 authored by chechunchi's avatar chechunchi

fix compile error

parent fd39976c
Pipeline #22501 passed with stages
in 15 minutes and 4 seconds
......@@ -20,20 +20,6 @@
}
]
},
"33": {
"protoType": "shuffle_hand",
"fields": [
{
"fieldName": "player",
"fieldType": "uint8"
},
{
"fieldName": "hands",
"fieldType": "repeated",
"repeatedType": "uint32"
}
]
},
"53": {
"protoType": "pos_change",
"fields": [
......
......@@ -17,7 +17,6 @@ const ReadFieldHandlerMap: Map<string, readFieldHandler> = new Map([
]);
const MsgConstructorMap: Map<string, Constructor> = new Map([
["move", ygopro.StocGameMessage.MsgMove as Constructor],
["shuffle_hand", ygopro.StocGameMessage.MsgShuffleHand],
["pos_change", ygopro.StocGameMessage.MsgPosChange],
["select_yes_no", ygopro.StocGameMessage.MsgSelectYesNo],
["set", ygopro.StocGameMessage.MsgSet],
......
......@@ -38,7 +38,7 @@ import onMsgSelectUnselectCard from "./selectUnselectCard";
import onMsgSelectYesNo from "./selectYesNo";
import onMsgSet from "./set";
import onMsgShuffleDeck from "./shuffleDeck";
import onMsgShuffleHand from "./shuffleHand";
import onMsgShuffleHandExtra from "./shuffleHandExtra";
import onMsgShuffleSetCard from "./shuffleSetCard";
import onMsgSortCard from "./sortCard";
import onMsgSpSummoned from "./spSummoned";
......@@ -149,8 +149,8 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "shuffle_hand": {
await onMsgShuffleHand(msg.shuffle_hand);
case "shuffle_hand_extra": {
await onMsgShuffleHandExtra(msg.shuffle_hand_extra);
break;
}
......
......@@ -2,37 +2,37 @@ import { ygopro } from "@/api";
import { eventbus, Task } from "@/infra";
import { cardStore } from "@/stores";
type MsgShuffleHand = ygopro.StocGameMessage.MsgShuffleHand;
type MsgShuffleHandExtra = ygopro.StocGameMessage.MsgShuffleHandExtra;
export default async (shuffleHand: MsgShuffleHand) => {
const { hands: codes, player: controller } = shuffleHand;
export default async (shuffleHandExtra: MsgShuffleHandExtra) => {
const { cards: codes, player: controller, zone } = shuffleHandExtra;
// 本质上是要将手卡的sequence变成和codes一样的顺序
const hands = cardStore.at(ygopro.CardZone.HAND, controller);
// 本质上是要将手卡/额外卡组的sequence变成和codes一样的顺序
const cards = cardStore.at(zone, controller);
const hash = new Map(codes.map((code) => [code, new Array()]));
codes.forEach((code, sequence) => {
hash.get(code)?.push(sequence);
});
for (const hand of hands) {
const sequences = hash.get(hand.code);
for (const card of cards) {
const sequences = hash.get(card.code);
if (sequences !== undefined) {
const sequence = sequences.pop();
if (sequence !== undefined) {
hand.location.sequence = sequence;
hash.set(hand.code, sequences);
card.location.sequence = sequence;
hash.set(card.code, sequences);
// 触发动画
await eventbus.call(Task.Move, hand.uuid);
await eventbus.call(Task.Move, card.uuid);
} else {
console.warn(
`<ShuffleHand>sequence poped is none, controller=${controller}, code=${hand.code}, sequence=${sequence}`
`<ShuffleHandExtra>sequence poped is none, controller=${controller}, code=${card.code}, sequence=${sequence}`
);
}
} else {
console.warn(
`<ShuffleHand>target from records is null, controller=${controller}, hands=${hands.map(
(hand) => hand.code
`<ShuffleHandExtra>target from records is null, controller=${controller}, cards=${cards.map(
(card) => card.code
)}, codes=${codes}`
);
}
......
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