Commit 14051878 authored by Chunchi Che's avatar Chunchi Che

add win adapter and service

parent 8e94b5ed
Pipeline #20560 passed with stages
in 6 minutes and 21 seconds
...@@ -45,3 +45,4 @@ export const MSG_SELECT_UNSELECT_CARD = 26; ...@@ -45,3 +45,4 @@ export const MSG_SELECT_UNSELECT_CARD = 26;
export const MSG_DAMAGE = 91; export const MSG_DAMAGE = 91;
export const MSG_RECOVER = 92; export const MSG_RECOVER = 92;
export const MSG_PAY_LP_COST = 100; export const MSG_PAY_LP_COST = 100;
export const MSG_WIN = 5;
...@@ -22,6 +22,7 @@ import MsgSelectBattleCmdAdapter from "./selectBattleCmd"; ...@@ -22,6 +22,7 @@ import MsgSelectBattleCmdAdapter from "./selectBattleCmd";
import MsgSelectUnselectCardAdapter from "./selectUnselectCard"; import MsgSelectUnselectCardAdapter from "./selectUnselectCard";
import MsgDamage from "./damage"; import MsgDamage from "./damage";
import MsgRecover from "./recover"; import MsgRecover from "./recover";
import MsgWin from "./win";
import PENETRATE from "./penetrate"; import PENETRATE from "./penetrate";
/* /*
...@@ -130,6 +131,11 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -130,6 +131,11 @@ export default class GameMsgAdapter implements StocAdapter {
break; break;
} }
case GAME_MSG.MSG_WIN: {
gameMsg.win = MsgWin(gameData);
break;
}
default: { default: {
console.log("Unhandled GameMessage function=", func); console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
import MsgWin = ygopro.StocGameMessage.MsgWin;
/*
* Msg Win
*
* @param player - 玩家编号
* @param winType - 结果类型
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, true);
const player = reader.readUint8();
const winType = reader.readUint8();
const type_ =
player == 0 || winType == 4
? MsgWin.ActionType.Win
: player == 1
? MsgWin.ActionType.Defeated
: MsgWin.ActionType.UNKNOWN;
return new MsgWin({
player,
type_,
});
};
...@@ -19,6 +19,7 @@ import onMsgPosChange from "./posChange"; ...@@ -19,6 +19,7 @@ import onMsgPosChange from "./posChange";
import onMsgSelectUnselectCard from "./selectUnselectCard"; import onMsgSelectUnselectCard from "./selectUnselectCard";
import onMsgSelectYesNo from "./selectYesNo"; import onMsgSelectYesNo from "./selectYesNo";
import onMsgUpdateHp from "./updateHp"; import onMsgUpdateHp from "./updateHp";
import onMsgWin from "./win";
export default function handleGameMsg(pb: ygopro.YgoStocMsg) { export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
const dispatch = store.dispatch; const dispatch = store.dispatch;
...@@ -120,6 +121,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -120,6 +121,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break; break;
} }
case "win": {
onMsgWin(msg.win, dispatch);
break;
}
default: { default: {
break; break;
} }
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
export default (win: ygopro.StocGameMessage.MsgWin, dispatch: AppDispatch) => {
console.log(win);
};
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