Commit aafb9b87 authored by Chunchi Che's avatar Chunchi Che

handle side service

parent 4669c900
Pipeline #23179 passed with stages
in 11 minutes and 16 seconds
neos-protobuf @ a02a8caa
Subproject commit 12f48aa7901f81f4b356b968bc7a8281a1a2d848
Subproject commit a02a8caa38767bb06e1a9d5be97773af5a0fc4b2
This diff is collapsed.
import { ygopro } from "../idl/ocgcore";
import { YgoProPacket } from "./packet";
import {
STOC_CHANGE_SIDE,
STOC_CHAT,
STOC_DECK_COUNT,
STOC_DUEL_START,
......@@ -15,7 +16,9 @@ import {
STOC_SELECT_TP,
STOC_TIME_LIMIT,
STOC_TYPE_CHANGE,
STOC_WAITING_SIDE,
} from "./protoDecl";
import StocChangeSide from "./stoc/stocChangeSide";
import StocChat from "./stoc/stocChat";
import StocDeckCount from "./stoc/stocDeckCount";
import StocDuelStart from "./stoc/stocDuelStart";
......@@ -30,6 +33,7 @@ import StocSelectHand from "./stoc/stocSelectHand";
import StocSelectTp from "./stoc/stocSelectTp";
import StocTimeLimit from "./stoc/stocTimeLimit";
import StocTypeChange from "./stoc/stocTypeChange";
import StocWaitingSide from "./stoc/stocWaitingSide";
/*
* 将[`ygoProPacket`]对象转换成[`ygopro.YgoStocMsg`]对象
......@@ -97,6 +101,14 @@ export function adaptStoc(packet: YgoProPacket): ygopro.YgoStocMsg {
pb = new StocErrorMsg(packet).upcast();
break;
}
case STOC_CHANGE_SIDE: {
pb = new StocChangeSide(packet).upcast();
break;
}
case STOC_WAITING_SIDE: {
pb = new StocWaitingSide(packet).upcast();
break;
}
default: {
break;
}
......
......@@ -31,6 +31,8 @@ export const STOC_DUEL_START = 21;
export const STOC_GAME_MSG = 1;
export const STOC_TIME_LIMIT = 24;
export const STOC_ERROR_MSG = 2;
export const STOC_CHANGE_SIDE = 7;
export const STOC_WAITING_SIDE = 8;
export const MSG_START = 4;
export const MSG_DRAW = 90;
......
import { ygopro } from "../../idl/ocgcore";
import { StocAdapter, YgoProPacket } from "../packet";
export default class ChangeSide implements StocAdapter {
packet: YgoProPacket;
constructor(packet: YgoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
return new ygopro.YgoStocMsg({
stoc_change_side: new ygopro.StocChangeSide({}),
});
}
}
import { ygopro } from "../../idl/ocgcore";
import { StocAdapter, YgoProPacket } from "../packet";
export default class WaitingSide implements StocAdapter {
packet: YgoProPacket;
constructor(packet: YgoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
return new ygopro.YgoStocMsg({
stoc_waiting_side: new ygopro.StocWaitingSide({}),
});
}
}
......@@ -20,6 +20,8 @@ import handleHsPlayerEnter from "./room/hsPlayerEnter";
import handleHsWatchChange from "./room/hsWatchChange";
import handleJoinGame from "./room/joinGame";
import handleTypeChange from "./room/typeChange";
import { handleChangeSide } from "./side/changeSide";
import { handleWaitingSide } from "./side/waitingSide";
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
......@@ -93,6 +95,14 @@ export default async function handleSocketMessage(e: MessageEvent) {
await handleErrorMsg(pb.stoc_error_msg);
break;
}
case "stoc_change_side": {
handleChangeSide(pb.stoc_change_side);
break;
}
case "stoc_waiting_side": {
handleWaitingSide(pb.stoc_waiting_side);
break;
}
default: {
console.log(packet);
......
import { ygopro } from "@/api";
export function handleChangeSide(_: ygopro.StocChangeSide) {
console.log("on StocChangeSide");
}
import { ygopro } from "@/api";
export function handleWaitingSide(_: ygopro.StocWaitingSide) {
console.log("on StocWaitingSide");
}
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