Commit bb0b665d authored by chechunchi's avatar chechunchi

handle MsgHandResult and MsgRockPaperScissors and format some code

parent 70465eab
Pipeline #22390 failed with stages
in 26 minutes and 21 seconds
import { ygopro } from "@/api/ocgcore/idl/ocgcore";
import { BufferReader } from "../../../../../../rust-src/pkg/rust_src";
/*
* Msg Hand Result
* @param - TODO
*
* @usage - 后端告诉前端玩家选择的猜拳结果
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data);
const x = reader.readUint8();
const result1 = x & 0x3;
const result2 = (x >> 2) & 0x3;
return new ygopro.StocGameMessage.MsgHandResult({
result1,
result2,
});
};
......@@ -244,5 +244,13 @@
"fieldType":"uint8"
}
]
},
"132":{
"protoType":"rock_paper_scissors",
"fields":[
{
"fieldName":"player",
"fieldType":"uint8"
}
}
}
......@@ -36,6 +36,7 @@ const MsgConstructorMap: Map<string, Constructor> = new Map([
["confirm_cards", ygopro.StocGameMessage.MsgConfirmCards],
["become_target", ygopro.StocGameMessage.MsgBecomeTarget],
["shuffle_deck", ygopro.StocGameMessage.MsgShuffleDeck],
["rock_paper_scissors", ygopro.StocGameMessage.MsgRockPaperScissors],
]);
export interface penetrateType {
......
import { ygopro } from "@/api";
import { sleep } from "@/infra";
import { matStore } from "@/stores";
import { showWaiting } from "@/ui/Duel/Message";
import onAnnounce from "./announce";
......@@ -15,6 +14,7 @@ import onMsgDraw from "./draw";
import onMsgFieldDisabled from "./fieldDisabled";
import onMsgFilpSummoned from "./flipSummoned";
import onMsgFlipSummoning from "./flipSummoning";
import onMsgHandResult from "./handResult";
import onMsgHint from "./hint";
import onLpUpdate from "./lpUpdate";
import onMsgMove from "./move";
......@@ -22,6 +22,7 @@ import onMsgNewPhase from "./newPhase";
import onMsgNewTurn from "./newTurn";
import onMsgPosChange from "./posChange";
import onMsgReloadField from "./reloadField";
import onMsgRockPaperScissors from "./rockPaperScissors";
import onMsgSelectBattleCmd from "./selectBattleCmd";
import onMsgSelectCard from "./selectCard";
import onMsgSelectChain from "./selectChain";
......@@ -328,6 +329,16 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "rock_paper_scissors": {
onMsgRockPaperScissors(msg.rock_paper_scissors);
break;
}
case "hand_res": {
onMsgHandResult(msg.hand_res);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented);
......
import { ygopro } from "@/api";
import MsgHandResult = ygopro.StocGameMessage.MsgHandResult;
export default (res: MsgHandResult) => {
console.log(res);
// TODO
};
import { ygopro } from "@/api";
export default (mora: ygopro.StocGameMessage.MsgRockPaperScissors) => {
console.log(mora);
// TODO
};
import "./index.scss";
import { message, notification } from "antd";
import React, { useEffect } from "react";
import { useSnapshot } from "valtio";
......@@ -6,7 +8,6 @@ import { fetchStrings } from "@/api";
import { Phase2StringCodeMap } from "@/common";
import { useConfig } from "@/config";
import { matStore } from "@/stores";
import "./index.scss";
const style = {
borderStyle: "groove",
......
import "./index.scss";
import { type FC } from "react";
import { proxy, useSnapshot, INTERNAL_Snapshot as Snapshot } from "valtio";
import { INTERNAL_Snapshot as Snapshot, proxy, useSnapshot } from "valtio";
import { sendSelectMultiResponse, sendSelectSingleResponse } from "@/api";
import { SelectCardsModal, type Option } from "../SelectCardsModal";
import { type Option, SelectCardsModal } from "../SelectCardsModal";
const CANCEL_RESPONSE = -1;
const FINISH_RESPONSE = -1;
......
......@@ -3,7 +3,7 @@ import "./index.scss";
import { CheckCard } from "@ant-design/pro-components";
import { Button, Segmented, Space, Tooltip } from "antd";
import { type FC, useEffect, useState } from "react";
import { useSnapshot, INTERNAL_Snapshot as Snapshot } from "valtio";
import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio";
import type { CardMeta, ygopro } from "@/api";
import { fetchStrings } from "@/api";
......
// import "./index.scss";
import { type FC } from "react";
import { proxy, useSnapshot, INTERNAL_Snapshot as Snapshot } from "valtio";
import { INTERNAL_Snapshot as Snapshot, proxy, useSnapshot } from "valtio";
import { SelectCardsModal, type Option } from "../SelectCardsModal";
import { type Option, SelectCardsModal } from "../SelectCardsModal";
const defaultProps = {
isOpen: false,
......
......@@ -235,11 +235,11 @@ const onFieldClick = (card: CardType) => {
};
// >>> 下拉菜单:点击动作 >>>
type Interactivy = {
interface Interactivy {
desc: string;
response: number;
effectCode: number | undefined;
};
}
type DropdownItem = NonNullable<MenuProps["items"]>[number] & {
onClick: () => void;
......
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