Commit d7bd1852 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/win' into 'main'

Fix/win

See merge request mycard/Neos!221
parents 40f0cdde 7bf462f2
neos-protobuf @ b38ac93e
Subproject commit 44727f7136ec5708c86d6ed09d5bec8b48f13efc Subproject commit b38ac93eef4ec235d1be4cfb689754a0e360e2ab
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
1, 1,
6, 6,
7, 7,
30,
31,
32, 32,
34, 34,
54, 54,
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
1, 1,
6, 6,
7, 7,
30,
31,
32, 32,
34, 34,
54, 54,
......
This diff is collapsed.
...@@ -12,18 +12,11 @@ import MsgWin = ygopro.StocGameMessage.MsgWin; ...@@ -12,18 +12,11 @@ import MsgWin = ygopro.StocGameMessage.MsgWin;
export default (data: Uint8Array) => { export default (data: Uint8Array) => {
const reader = new BufferReader(data); const reader = new BufferReader(data);
const player = reader.readUint8(); const win_player = reader.readUint8();
const winType = reader.readUint8(); const reason = reader.readUint8();
const type_ =
player == 0 || winType == 4
? MsgWin.ActionType.Win
: player == 1
? MsgWin.ActionType.Defeated
: MsgWin.ActionType.UNKNOWN;
return new MsgWin({ return new MsgWin({
player, win_player,
type_, reason,
}); });
}; };
import { ygopro } from "@/api"; import { fetchStrings, ygopro } from "@/api";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import MsgWin = ygopro.StocGameMessage.MsgWin; import MsgWin = ygopro.StocGameMessage.MsgWin;
export default (win: MsgWin) => { export default (win: MsgWin) => {
const player = win.player; const { win_player, reason } = win;
if (matStore.isMe(player)) { matStore.result = {
matStore.result = win.type_; isWin: matStore.isMe(win_player),
} else { reason: fetchStrings("!victory", `0x${reason.toString(16)}`),
matStore.result = };
win.type_ == MsgWin.ActionType.Win
? MsgWin.ActionType.Defeated
: MsgWin.ActionType.Win;
}
}; };
...@@ -80,7 +80,6 @@ export const matStore: MatState = proxy<MatState>({ ...@@ -80,7 +80,6 @@ export const matStore: MatState = proxy<MatState>({
enableM2: false, // 允许进入M2阶段 enableM2: false, // 允许进入M2阶段
enableEp: false, // 允许回合结束 enableEp: false, // 允许回合结束
}, },
result: ygopro.StocGameMessage.MsgWin.ActionType.UNKNOWN,
waiting: false, waiting: false,
unimplemented: 0, unimplemented: 0,
// methods // methods
......
...@@ -28,7 +28,10 @@ export interface MatState { ...@@ -28,7 +28,10 @@ export interface MatState {
phase: PhaseState; phase: PhaseState;
result: ygopro.StocGameMessage.MsgWin.ActionType; result?: {
isWin: boolean;
reason: string;
};
waiting: boolean; waiting: boolean;
......
...@@ -20,7 +20,7 @@ export const CheckCounterModal = () => { ...@@ -20,7 +20,7 @@ export const CheckCounterModal = () => {
const counterName = fetchStrings( const counterName = fetchStrings(
"!counter", "!counter",
`0x${snapCheckCounterModal.counterType!}` `0x${snapCheckCounterModal.counterType!}`
); ); // FIXME: 这里转十六进制的逻辑有问题
const [selected, setSelected] = useState(new Array(options.length)); const [selected, setSelected] = useState(new Array(options.length));
const sum = selected.reduce((sum, current) => sum + current, 0); const sum = selected.reduce((sum, current) => sum + current, 0);
......
...@@ -2,7 +2,7 @@ import { notification } from "antd"; ...@@ -2,7 +2,7 @@ import { notification } from "antd";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { fetchStrings, ygopro } from "@/api"; import { fetchStrings } from "@/api";
import { Phase2StringCodeMap } from "@/common"; import { Phase2StringCodeMap } from "@/common";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
...@@ -13,8 +13,6 @@ const style = { ...@@ -13,8 +13,6 @@ const style = {
backgroundColor: "#303030", backgroundColor: "#303030",
}; };
const MsgWin = ygopro.StocGameMessage.MsgWin;
const NeosConfig = useConfig(); const NeosConfig = useConfig();
export const HintNotification = () => { export const HintNotification = () => {
const snap = useSnapshot(matStore); const snap = useSnapshot(matStore);
...@@ -67,12 +65,7 @@ export const HintNotification = () => { ...@@ -67,12 +65,7 @@ export const HintNotification = () => {
useEffect(() => { useEffect(() => {
if (result) { if (result) {
const message = const message = result.isWin ? "Win" : "Defeated" + " " + result.reason;
result == MsgWin.ActionType.Win
? "胜利"
: MsgWin.ActionType.Defeated
? "失败"
: "未知结果";
api.open({ api.open({
message, message,
placement: "bottom", placement: "bottom",
......
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