Commit 074a7764 authored by Chunchi Che's avatar Chunchi Che Committed by WANG HE

add selectHand adapter

parent e89215a9
......@@ -7,6 +7,7 @@ import {
STOC_HS_WATCH_CHANGE,
STOC_JOIN_GAME,
STOC_TYPE_CHANGE,
STOC_SELECT_HAND,
} from "./protoDecl";
import StocChat from "./stoc/stocChat";
import StocJoinGame from "./stoc/stocJoinGame";
......@@ -14,6 +15,7 @@ import StocHsPlayerEnter from "./stoc/stocHsPlayerEnter";
import StocHsPlayerChange from "./stoc/stocHsPlayerChange";
import StocHsWatchChange from "./stoc/stocHsWatchChange";
import StocTypeChange from "./stoc/stocTypeChange";
import StocSelectHand from "./stoc/stocSelectHand";
/*
* 将[`ygoProPacket`]对象转换成[`ygopro.YgoStocMsg`]对象
......@@ -55,6 +57,11 @@ export function adaptStoc(packet: ygoProPacket): ygopro.YgoStocMsg {
break;
}
case STOC_SELECT_HAND: {
pb = new StocSelectHand(packet).upcast();
break;
}
default: {
break;
}
......
......@@ -14,3 +14,4 @@ export const STOC_HS_PLAYER_ENTER = 32;
export const STOC_HS_PLAYER_CHANGE = 33;
export const STOC_HS_WATCH_CHANGE = 34;
export const STOC_TYPE_CHANGE = 19;
export const STOC_SELECT_HAND = 3;
import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet";
/*
* STOC SelectHand
*
* @usage - 通知客户端/前端提醒用户进行猜拳选择
* */
export default class selectHand implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
return new ygopro.YgoStocMsg({
stoc_select_hand: new ygopro.StocSelectHand({}),
});
}
}
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
export default function handleSelectHand(_: ygopro.YgoStocMsg) {
console.log("in handleSelectHand!");
}
......@@ -10,6 +10,7 @@ import handleChat from "./room/chat";
import handleHsWatchChange from "./room/hsWatchChange";
import { ygoProPacket } from "../api/ocgcore/ocgAdapter/packet";
import { adaptStoc } from "../api/ocgcore/ocgAdapter/adapter";
import handleSelectHand from "./mora/selectHand";
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
......@@ -51,6 +52,11 @@ export default function handleSocketMessage(e: MessageEvent) {
break;
}
case "stoc_select_hand": {
handleSelectHand(pb);
break;
}
default: {
break;
}
......
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