Commit 0d4a92c5 authored by Chunchi Che's avatar Chunchi Che

update

parent e3fef171
Pipeline #17771 failed with stages
in 2 minutes and 43 seconds
......@@ -8,7 +8,7 @@ const littleEndian: boolean = true;
const PACKET_MIN_LEN = 3;
// Ref: https://www.icode9.com/content-1-1341344.html
export class ygoProPacket {
export class YgoProPacket {
packetLen: number; // 数据包长度
proto: number; // ygopro协议标识
exData: Uint8Array; // 数据包内容
......@@ -40,7 +40,7 @@ export class ygoProPacket {
* 返回值可用于业务逻辑处理。
*
* */
static deserialize(array: ArrayBuffer): ygoProPacket {
static deserialize(array: ArrayBuffer): YgoProPacket {
try {
if (array.byteLength < PACKET_MIN_LEN) {
throw new Error(
......@@ -57,7 +57,7 @@ export class ygoProPacket {
const proto = dataView.getInt8(2);
const exData = array.slice(3, packetLen + 2);
return new ygoProPacket(packetLen, proto, new Uint8Array(exData));
return new YgoProPacket(packetLen, proto, new Uint8Array(exData));
}
}
......@@ -68,5 +68,5 @@ export interface StocAdapter {
export interface CtosAdapter {
readonly protobuf: ygopro.YgoCtosMsg;
downcast(): ygoProPacket;
downcast(): YgoProPacket;
}
......@@ -9,7 +9,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 更新聊天消息
* */
export default class chatAdapter implements StocAdapter {
export default class ChatAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -12,7 +12,7 @@ const INT16_BYTE_OFFSET = 2;
* @usage - 展示双方卡组信息
* */
export default class deckCountAdapter implements StocAdapter {
export default class DeckCountAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
/*
* STOC GameMsg协议Adapter逻辑
*
* */
import { ygopro } from "../../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../../packet";
/*
* STOC GameMsg
*
* @param function: unsigned chat - GameMsg协议的function编号
* @param data: binary bytes - GameMsg协议的数据
*
* @usage - 服务端告诉前端/客户端决斗对局中的UI展示逻辑
* */
export default class GameMsgAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
// TODO
return new ygopro.YgoStocMsg({});
}
}
......@@ -8,7 +8,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 更新玩家状态
* */
export default class hsPlayerChangeAdapter implements StocAdapter {
export default class HsPlayerChangeAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -12,7 +12,7 @@ const UINT8_PER_UINT16 = 2;
*
* @usage - 有新玩家进入房间,更新状态
* */
export default class hsPlayerEnterAdapter implements StocAdapter {
export default class HsPlayerEnterAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -8,7 +8,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 更新观战者数量
* */
export default class hsWatchChangeAdapter implements StocAdapter {
export default class HsWatchChangeAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -6,7 +6,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 告知客户端/前端已成功加入房间
* */
export default class joinGameAdapter implements StocAdapter {
export default class JoinGameAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -6,7 +6,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 通知客户端/前端提醒用户进行猜拳选择
* */
export default class selectHand implements StocAdapter {
export default class SelectHand implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -6,7 +6,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 通知客户端/前端提醒用户进行选先后攻
* */
export default class selectTp implements StocAdapter {
export default class SelectTp implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
......@@ -8,7 +8,7 @@ import { ygoProPacket, StocAdapter } from "../packet";
*
* @usage - 更新玩家状态
* */
export default class typeChangeAdapter implements StocAdapter {
export default class TypeChangeAdapter implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
......
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