Commit 01450b66 authored by Chunchi Che's avatar Chunchi Che

fix

parent 0d4a92c5
Pipeline #17772 passed with stages
in 3 minutes and 16 seconds
import { ygoProPacket } from "./packet"; import { YgoProPacket } from "./packet";
import { ygopro } from "../idl/ocgcore"; import { ygopro } from "../idl/ocgcore";
import { import {
STOC_CHAT, STOC_CHAT,
...@@ -30,7 +30,7 @@ import StocDeckCount from "./stoc/stocDeckCount"; ...@@ -30,7 +30,7 @@ import StocDeckCount from "./stoc/stocDeckCount";
* @returns The ygopro.YgoStocMsg object * @returns The ygopro.YgoStocMsg object
* *
* */ * */
export function adaptStoc(packet: ygoProPacket): ygopro.YgoStocMsg { export function adaptStoc(packet: YgoProPacket): ygopro.YgoStocMsg {
let pb = new ygopro.YgoStocMsg({}); let pb = new ygopro.YgoStocMsg({});
switch (packet.proto) { switch (packet.proto) {
case STOC_JOIN_GAME: { case STOC_JOIN_GAME: {
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_HAND_RESULT } from "../protoDecl"; import { CTOS_HAND_RESULT } from "../protoDecl";
/* /*
...@@ -9,7 +9,7 @@ import { CTOS_HAND_RESULT } from "../protoDecl"; ...@@ -9,7 +9,7 @@ import { CTOS_HAND_RESULT } from "../protoDecl";
* *
* @usage - 告知服务端当前玩家的猜拳选择 * @usage - 告知服务端当前玩家的猜拳选择
* */ * */
export default class CtosHandResultPacket extends ygoProPacket { export default class CtosHandResultPacket extends YgoProPacket {
constructor(pb: ygopro.YgoCtosMsg) { constructor(pb: ygopro.YgoCtosMsg) {
const handResult = pb.ctos_hand_result; const handResult = pb.ctos_hand_result;
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_HS_READY } from "../protoDecl"; import { CTOS_HS_READY } from "../protoDecl";
/* /*
...@@ -7,7 +7,7 @@ import { CTOS_HS_READY } from "../protoDecl"; ...@@ -7,7 +7,7 @@ import { CTOS_HS_READY } from "../protoDecl";
* *
* @usage - 告诉ygopro服务端当前玩家准备完毕 * @usage - 告诉ygopro服务端当前玩家准备完毕
* */ * */
export default class CtosHsReady extends ygoProPacket { export default class CtosHsReady extends YgoProPacket {
constructor(_: ygopro.YgoCtosMsg) { constructor(_: ygopro.YgoCtosMsg) {
super(1, CTOS_HS_READY, new Uint8Array(0)); super(1, CTOS_HS_READY, new Uint8Array(0));
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_HS_START } from "../protoDecl"; import { CTOS_HS_START } from "../protoDecl";
/* /*
...@@ -7,7 +7,7 @@ import { CTOS_HS_START } from "../protoDecl"; ...@@ -7,7 +7,7 @@ import { CTOS_HS_START } from "../protoDecl";
* *
* @usage - 开始游戏对局 * @usage - 开始游戏对局
* */ * */
export default class CtosHsStartPacket extends ygoProPacket { export default class CtosHsStartPacket extends YgoProPacket {
constructor(_: ygopro.YgoCtosMsg) { constructor(_: ygopro.YgoCtosMsg) {
super(1, CTOS_HS_START, new Uint8Array(0)); super(1, CTOS_HS_START, new Uint8Array(0));
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_JOIN_GAME } from "../protoDecl"; import { CTOS_JOIN_GAME } from "../protoDecl";
import { strEncodeUTF16 } from "../util"; import { strEncodeUTF16 } from "../util";
...@@ -13,7 +13,7 @@ import { strEncodeUTF16 } from "../util"; ...@@ -13,7 +13,7 @@ import { strEncodeUTF16 } from "../util";
* *
* @usage - 加入房间 * @usage - 加入房间
* */ * */
export default class CtosJoinGamePacket extends ygoProPacket { export default class CtosJoinGamePacket extends YgoProPacket {
constructor(pb: ygopro.YgoCtosMsg) { constructor(pb: ygopro.YgoCtosMsg) {
const joinGame = pb.ctos_join_game; const joinGame = pb.ctos_join_game;
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_PLAYER_INFO } from "../protoDecl"; import { CTOS_PLAYER_INFO } from "../protoDecl";
import { strEncodeUTF16 } from "../util"; import { strEncodeUTF16 } from "../util";
...@@ -10,7 +10,7 @@ import { strEncodeUTF16 } from "../util"; ...@@ -10,7 +10,7 @@ import { strEncodeUTF16 } from "../util";
* *
* @usage - 告诉ygopro服务端当前玩家的昵称 * @usage - 告诉ygopro服务端当前玩家的昵称
* */ * */
export default class CtosPlayerInfoPacket extends ygoProPacket { export default class CtosPlayerInfoPacket extends YgoProPacket {
constructor(pb: ygopro.YgoCtosMsg) { constructor(pb: ygopro.YgoCtosMsg) {
const player = pb.ctos_player_info.name; const player = pb.ctos_player_info.name;
const exData = strEncodeUTF16(player); const exData = strEncodeUTF16(player);
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_TP_RESULT } from "../protoDecl"; import { CTOS_TP_RESULT } from "../protoDecl";
/* /*
...@@ -10,7 +10,7 @@ import { CTOS_TP_RESULT } from "../protoDecl"; ...@@ -10,7 +10,7 @@ import { CTOS_TP_RESULT } from "../protoDecl";
* @usage - 告知服务端当前玩家的先后攻选择 * @usage - 告知服务端当前玩家的先后攻选择
* *
* */ * */
export default class CtosTpResultPacket extends ygoProPacket { export default class CtosTpResultPacket extends YgoProPacket {
constructor(pb: ygopro.YgoCtosMsg) { constructor(pb: ygopro.YgoCtosMsg) {
const tpResult = pb.ctos_tp_result; const tpResult = pb.ctos_tp_result;
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet"; import { YgoProPacket } from "../packet";
import { CTOS_UPDATE_DECK } from "../protoDecl"; import { CTOS_UPDATE_DECK } from "../protoDecl";
const BYTES_PER_U32 = 4; const BYTES_PER_U32 = 4;
...@@ -16,7 +16,7 @@ const BYTES_PER_U32 = 4; ...@@ -16,7 +16,7 @@ const BYTES_PER_U32 = 4;
* *
* @usage - 更新对局的卡组信息 * @usage - 更新对局的卡组信息
* */ * */
export default class CtosUpdateDeck extends ygoProPacket { export default class CtosUpdateDeck extends YgoProPacket {
constructor(pb: ygopro.YgoCtosMsg) { constructor(pb: ygopro.YgoCtosMsg) {
const updateDeck = pb.ctos_update_deck; const updateDeck = pb.ctos_update_deck;
const main = updateDeck.main; const main = updateDeck.main;
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC Chat * STOC Chat
...@@ -10,9 +10,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -10,9 +10,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 更新聊天消息 * @usage - 更新聊天消息
* */ * */
export default class ChatAdapter implements StocAdapter { export default class ChatAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
const LITTLE_ENDIAN = true; const LITTLE_ENDIAN = true;
const INT16_BYTE_OFFSET = 2; const INT16_BYTE_OFFSET = 2;
...@@ -13,9 +13,9 @@ const INT16_BYTE_OFFSET = 2; ...@@ -13,9 +13,9 @@ const INT16_BYTE_OFFSET = 2;
* */ * */
export default class DeckCountAdapter implements StocAdapter { export default class DeckCountAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* */ * */
import { ygopro } from "../../../idl/ocgcore"; import { ygopro } from "../../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../../packet"; import { YgoProPacket, StocAdapter } from "../../packet";
/* /*
* STOC GameMsg * STOC GameMsg
...@@ -15,9 +15,9 @@ import { ygoProPacket, StocAdapter } from "../../packet"; ...@@ -15,9 +15,9 @@ import { ygoProPacket, StocAdapter } from "../../packet";
* @usage - 服务端告诉前端/客户端决斗对局中的UI展示逻辑 * @usage - 服务端告诉前端/客户端决斗对局中的UI展示逻辑
* */ * */
export default class GameMsgAdapter implements StocAdapter { export default class GameMsgAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC HsPlayerChange * STOC HsPlayerChange
...@@ -9,9 +9,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -9,9 +9,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 更新玩家状态 * @usage - 更新玩家状态
* */ * */
export default class HsPlayerChangeAdapter implements StocAdapter { export default class HsPlayerChangeAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
import { UTF16_BUFFER_MAX_LEN } from "../util"; import { UTF16_BUFFER_MAX_LEN } from "../util";
const UINT8_PER_UINT16 = 2; const UINT8_PER_UINT16 = 2;
...@@ -13,9 +13,9 @@ const UINT8_PER_UINT16 = 2; ...@@ -13,9 +13,9 @@ const UINT8_PER_UINT16 = 2;
* @usage - 有新玩家进入房间,更新状态 * @usage - 有新玩家进入房间,更新状态
* */ * */
export default class HsPlayerEnterAdapter implements StocAdapter { export default class HsPlayerEnterAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC HsWatchChange * STOC HsWatchChange
...@@ -9,9 +9,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -9,9 +9,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 更新观战者数量 * @usage - 更新观战者数量
* */ * */
export default class HsWatchChangeAdapter implements StocAdapter { export default class HsWatchChangeAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC JoinGame * STOC JoinGame
...@@ -7,9 +7,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -7,9 +7,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 告知客户端/前端已成功加入房间 * @usage - 告知客户端/前端已成功加入房间
* */ * */
export default class JoinGameAdapter implements StocAdapter { export default class JoinGameAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC SelectHand * STOC SelectHand
...@@ -7,9 +7,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -7,9 +7,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 通知客户端/前端提醒用户进行猜拳选择 * @usage - 通知客户端/前端提醒用户进行猜拳选择
* */ * */
export default class SelectHand implements StocAdapter { export default class SelectHand implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC SelectTp * STOC SelectTp
...@@ -7,9 +7,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -7,9 +7,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 通知客户端/前端提醒用户进行选先后攻 * @usage - 通知客户端/前端提醒用户进行选先后攻
* */ * */
export default class SelectTp implements StocAdapter { export default class SelectTp implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet"; import { YgoProPacket, StocAdapter } from "../packet";
/* /*
* STOC TypeChange * STOC TypeChange
...@@ -9,9 +9,9 @@ import { ygoProPacket, StocAdapter } from "../packet"; ...@@ -9,9 +9,9 @@ import { ygoProPacket, StocAdapter } from "../packet";
* @usage - 更新玩家状态 * @usage - 更新玩家状态
* */ * */
export default class TypeChangeAdapter implements StocAdapter { export default class TypeChangeAdapter implements StocAdapter {
packet: ygoProPacket; packet: YgoProPacket;
constructor(packet: ygoProPacket) { constructor(packet: YgoProPacket) {
this.packet = packet; this.packet = packet;
} }
......
...@@ -8,7 +8,7 @@ import handleHsPlayerEnter from "./room/hsPlayerEnter"; ...@@ -8,7 +8,7 @@ import handleHsPlayerEnter from "./room/hsPlayerEnter";
import handleJoinGame from "./room/joinGame"; import handleJoinGame from "./room/joinGame";
import handleChat from "./room/chat"; import handleChat from "./room/chat";
import handleHsWatchChange from "./room/hsWatchChange"; import handleHsWatchChange from "./room/hsWatchChange";
import { ygoProPacket } from "../api/ocgcore/ocgAdapter/packet"; import { YgoProPacket } from "../api/ocgcore/ocgAdapter/packet";
import { adaptStoc } from "../api/ocgcore/ocgAdapter/adapter"; import { adaptStoc } from "../api/ocgcore/ocgAdapter/adapter";
import handleSelectHand from "./mora/selectHand"; import handleSelectHand from "./mora/selectHand";
import handleSelectTp from "./mora/selectTp"; import handleSelectTp from "./mora/selectTp";
...@@ -20,7 +20,7 @@ import handleDeckCount from "./mora/deckCount"; ...@@ -20,7 +20,7 @@ import handleDeckCount from "./mora/deckCount";
* *
* */ * */
export default function handleSocketMessage(e: MessageEvent) { export default function handleSocketMessage(e: MessageEvent) {
const packet = ygoProPacket.deserialize(e.data); const packet = YgoProPacket.deserialize(e.data);
const pb = adaptStoc(packet); const pb = adaptStoc(packet);
switch (pb.msg) { switch (pb.msg) {
......
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