Commit 5a76679d authored by Chunchi Che's avatar Chunchi Che

add ctosChat

parent f3294270
Pipeline #20506 passed with stages
in 6 minutes and 42 seconds
import { ygopro } from "../../idl/ocgcore";
import { YgoProPacket } from "../packet";
import { CTOS_CHAT } from "../protoDecl";
import { strEncodeUTF16 } from "../util";
/*
* CTOS Chat
*
* @param message - 玩家发送的消息
*
* @usage - TODO*/
export default class CtosChat extends YgoProPacket {
constructor(pb: ygopro.YgoCtosMsg) {
const message = pb.ctos_chat.message;
const exData = strEncodeUTF16(message);
super(exData.length + 1, CTOS_CHAT, exData);
}
}
...@@ -11,6 +11,7 @@ export const CTOS_HAND_RESULT = 3; ...@@ -11,6 +11,7 @@ export const CTOS_HAND_RESULT = 3;
export const CTOS_TP_RESULT = 4; export const CTOS_TP_RESULT = 4;
export const CTOS_TIME_CONFIRM = 21; export const CTOS_TIME_CONFIRM = 21;
export const CTOS_RESPONSE = 1; export const CTOS_RESPONSE = 1;
export const CTOS_CHAT = 22;
export const STOC_JOIN_GAME = 18; export const STOC_JOIN_GAME = 18;
export const STOC_CHAT = 25; export const STOC_CHAT = 25;
......
...@@ -14,6 +14,7 @@ import HandResult from "./ocgAdapter/ctos/ctosHandResult"; ...@@ -14,6 +14,7 @@ import HandResult from "./ocgAdapter/ctos/ctosHandResult";
import TpResult from "./ocgAdapter/ctos/ctosTpResult"; import TpResult from "./ocgAdapter/ctos/ctosTpResult";
import TimeConfirm from "./ocgAdapter/ctos/ctosTimeConfirm"; import TimeConfirm from "./ocgAdapter/ctos/ctosTimeConfirm";
import GameMsgResponse from "./ocgAdapter/ctos/ctosGameMsgResponse/mod"; import GameMsgResponse from "./ocgAdapter/ctos/ctosGameMsgResponse/mod";
import Chat from "./ocgAdapter/ctos/ctosChat";
export function sendUpdateDeck(deck: IDeck) { export function sendUpdateDeck(deck: IDeck) {
const updateDeck = new ygopro.YgoCtosMsg({ const updateDeck = new ygopro.YgoCtosMsg({
...@@ -119,6 +120,15 @@ export function sendTimeConfirm() { ...@@ -119,6 +120,15 @@ export function sendTimeConfirm() {
socketMiddleWare({ cmd: socketCmd.SEND, payload }); socketMiddleWare({ cmd: socketCmd.SEND, payload });
} }
export function sendChat(message: string) {
const chat = new ygopro.YgoCtosMsg({
ctos_chat: new ygopro.CtosChat({ message }),
});
const payload = new Chat(chat).serialize();
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
export function sendSelectIdleCmdResponse(value: number) { export function sendSelectIdleCmdResponse(value: number) {
const response = new ygopro.YgoCtosMsg({ const response = new ygopro.YgoCtosMsg({
ctos_response: new ygopro.CtosGameMsgResponse({ ctos_response: new ygopro.CtosGameMsgResponse({
......
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