Commit df8c68bf authored by Chunchi Che's avatar Chunchi Che

add StocTimeLimit Adapter

parent 0a4ffd25
......@@ -13,6 +13,7 @@ import {
STOC_DECK_COUNT,
STOC_DUEL_START,
STOC_GAME_MSG,
STOC_TIME_LIMIT,
} from "./protoDecl";
import StocChat from "./stoc/stocChat";
import StocJoinGame from "./stoc/stocJoinGame";
......@@ -23,6 +24,7 @@ import StocTypeChange from "./stoc/stocTypeChange";
import StocSelectHand from "./stoc/stocSelectHand";
import StocSelectTp from "./stoc/stocSelectTp";
import StocDeckCount from "./stoc/stocDeckCount";
import StocTimeLimit from "./stoc/stocTimeLimit";
import StocGameMsg from "./stoc/stocGameMsg/mod";
/*
......@@ -94,6 +96,11 @@ export function adaptStoc(packet: YgoProPacket): ygopro.YgoStocMsg {
break;
}
case STOC_TIME_LIMIT: {
pb = new StocTimeLimit(packet).upcast();
break;
}
default: {
break;
}
......
......@@ -22,6 +22,7 @@ export const STOC_HAND_RESULT = 5;
export const STOC_DECK_COUNT = 9;
export const STOC_DUEL_START = 21;
export const STOC_GAME_MSG = 1;
export const STOC_TIME_LIMIT = 24;
export const MSG_START = 4;
export const MSG_DRAW = 90;
......
import { ygopro } from "../../idl/ocgcore";
import { YgoProPacket, StocAdapter } from "../packet";
import { BufferReader } from "../bufferIO";
/*
* STOC TimeLimit
*
* @usage - 同时客户端/前端时间限制
* */
export default class TimeLimit implements StocAdapter {
packet: YgoProPacket;
constructor(packet: YgoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
const reader = new BufferReader(this.packet.exData, true);
const player = reader.readInt8();
const leftTime = reader.readUint16();
return new ygopro.YgoStocMsg({
stoc_time_limit: new ygopro.StocTimeLimit({
player,
left_time: leftTime,
}),
});
}
}
......@@ -87,6 +87,11 @@ export default function handleSocketMessage(e: MessageEvent) {
break;
}
case "stoc_time_limit": {
// TODO
break;
}
default: {
console.log(packet);
......
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