Commit 8a9039bf authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/service/select_chain_response' into 'main'

Feat/service/select chain response

See merge request mycard/Neos!63
parents f38abf22 3a76038f
neos-protobuf @ 779d9d9c
Subproject commit e34d37c57a4bbbefcd18c790856f19bf947955e7 Subproject commit 779d9d9c18d393df432570d80753a6fd9134c21e
...@@ -2412,7 +2412,7 @@ export namespace ygopro { ...@@ -2412,7 +2412,7 @@ export namespace ygopro {
} }
} }
export class CtosGameMsgResponse extends pb_1.Message { export class CtosGameMsgResponse extends pb_1.Message {
#one_of_decls: number[][] = [[1, 2, 3]]; #one_of_decls: number[][] = [[1, 2, 3, 4]];
constructor( constructor(
data?: data?:
| any[] | any[]
...@@ -2421,16 +2421,25 @@ export namespace ygopro { ...@@ -2421,16 +2421,25 @@ export namespace ygopro {
select_idle_cmd?: CtosGameMsgResponse.SelectIdleCmdResponse; select_idle_cmd?: CtosGameMsgResponse.SelectIdleCmdResponse;
select_place?: never; select_place?: never;
select_card?: never; select_card?: never;
select_chain?: never;
} }
| { | {
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: CtosGameMsgResponse.SelectPlaceResponse; select_place?: CtosGameMsgResponse.SelectPlaceResponse;
select_card?: never; select_card?: never;
select_chain?: never;
} }
| { | {
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: never; select_place?: never;
select_card?: CtosGameMsgResponse.SelectCardResponse; select_card?: CtosGameMsgResponse.SelectCardResponse;
select_chain?: never;
}
| {
select_idle_cmd?: never;
select_place?: never;
select_card?: never;
select_chain?: CtosGameMsgResponse.SelectChainResponse;
} }
)) ))
) { ) {
...@@ -2453,6 +2462,9 @@ export namespace ygopro { ...@@ -2453,6 +2462,9 @@ export namespace ygopro {
if ("select_card" in data && data.select_card != undefined) { if ("select_card" in data && data.select_card != undefined) {
this.select_card = data.select_card; this.select_card = data.select_card;
} }
if ("select_chain" in data && data.select_chain != undefined) {
this.select_chain = data.select_chain;
}
} }
} }
get select_idle_cmd() { get select_idle_cmd() {
...@@ -2494,20 +2506,35 @@ export namespace ygopro { ...@@ -2494,20 +2506,35 @@ export namespace ygopro {
get has_select_card() { get has_select_card() {
return pb_1.Message.getField(this, 3) != null; return pb_1.Message.getField(this, 3) != null;
} }
get select_chain() {
return pb_1.Message.getWrapperField(
this,
CtosGameMsgResponse.SelectChainResponse,
4
) as CtosGameMsgResponse.SelectChainResponse;
}
set select_chain(value: CtosGameMsgResponse.SelectChainResponse) {
pb_1.Message.setOneofWrapperField(this, 4, this.#one_of_decls[0], value);
}
get has_select_chain() {
return pb_1.Message.getField(this, 4) != null;
}
get gameMsgResponse() { get gameMsgResponse() {
const cases: { const cases: {
[index: number]: [index: number]:
| "none" | "none"
| "select_idle_cmd" | "select_idle_cmd"
| "select_place" | "select_place"
| "select_card"; | "select_card"
| "select_chain";
} = { } = {
0: "none", 0: "none",
1: "select_idle_cmd", 1: "select_idle_cmd",
2: "select_place", 2: "select_place",
3: "select_card", 3: "select_card",
4: "select_chain",
}; };
return cases[pb_1.Message.computeOneofCase(this, [1, 2, 3])]; return cases[pb_1.Message.computeOneofCase(this, [1, 2, 3, 4])];
} }
static fromObject(data: { static fromObject(data: {
select_idle_cmd?: ReturnType< select_idle_cmd?: ReturnType<
...@@ -2519,6 +2546,9 @@ export namespace ygopro { ...@@ -2519,6 +2546,9 @@ export namespace ygopro {
select_card?: ReturnType< select_card?: ReturnType<
typeof CtosGameMsgResponse.SelectCardResponse.prototype.toObject typeof CtosGameMsgResponse.SelectCardResponse.prototype.toObject
>; >;
select_chain?: ReturnType<
typeof CtosGameMsgResponse.SelectChainResponse.prototype.toObject
>;
}): CtosGameMsgResponse { }): CtosGameMsgResponse {
const message = new CtosGameMsgResponse({}); const message = new CtosGameMsgResponse({});
if (data.select_idle_cmd != null) { if (data.select_idle_cmd != null) {
...@@ -2536,6 +2566,10 @@ export namespace ygopro { ...@@ -2536,6 +2566,10 @@ export namespace ygopro {
data.select_card data.select_card
); );
} }
if (data.select_chain != null) {
message.select_chain =
CtosGameMsgResponse.SelectChainResponse.fromObject(data.select_chain);
}
return message; return message;
} }
toObject() { toObject() {
...@@ -2549,6 +2583,9 @@ export namespace ygopro { ...@@ -2549,6 +2583,9 @@ export namespace ygopro {
select_card?: ReturnType< select_card?: ReturnType<
typeof CtosGameMsgResponse.SelectCardResponse.prototype.toObject typeof CtosGameMsgResponse.SelectCardResponse.prototype.toObject
>; >;
select_chain?: ReturnType<
typeof CtosGameMsgResponse.SelectChainResponse.prototype.toObject
>;
} = {}; } = {};
if (this.select_idle_cmd != null) { if (this.select_idle_cmd != null) {
data.select_idle_cmd = this.select_idle_cmd.toObject(); data.select_idle_cmd = this.select_idle_cmd.toObject();
...@@ -2559,6 +2596,9 @@ export namespace ygopro { ...@@ -2559,6 +2596,9 @@ export namespace ygopro {
if (this.select_card != null) { if (this.select_card != null) {
data.select_card = this.select_card.toObject(); data.select_card = this.select_card.toObject();
} }
if (this.select_chain != null) {
data.select_chain = this.select_chain.toObject();
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
...@@ -2577,6 +2617,10 @@ export namespace ygopro { ...@@ -2577,6 +2617,10 @@ export namespace ygopro {
writer.writeMessage(3, this.select_card, () => writer.writeMessage(3, this.select_card, () =>
this.select_card.serialize(writer) this.select_card.serialize(writer)
); );
if (this.has_select_chain)
writer.writeMessage(4, this.select_chain, () =>
this.select_chain.serialize(writer)
);
if (!w) return writer.getResultBuffer(); if (!w) return writer.getResultBuffer();
} }
static deserialize( static deserialize(
...@@ -2614,6 +2658,14 @@ export namespace ygopro { ...@@ -2614,6 +2658,14 @@ export namespace ygopro {
CtosGameMsgResponse.SelectCardResponse.deserialize(reader)) CtosGameMsgResponse.SelectCardResponse.deserialize(reader))
); );
break; break;
case 4:
reader.readMessage(
message.select_chain,
() =>
(message.select_chain =
CtosGameMsgResponse.SelectChainResponse.deserialize(reader))
);
break;
default: default:
reader.skipField(); reader.skipField();
} }
...@@ -2921,6 +2973,86 @@ export namespace ygopro { ...@@ -2921,6 +2973,86 @@ export namespace ygopro {
return SelectCardResponse.deserialize(bytes); return SelectCardResponse.deserialize(bytes);
} }
} }
export class SelectChainResponse extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
selected_ptr?: number;
}
) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
if ("selected_ptr" in data && data.selected_ptr != undefined) {
this.selected_ptr = data.selected_ptr;
}
}
}
get selected_ptr() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set selected_ptr(value: number) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: { selected_ptr?: number }): SelectChainResponse {
const message = new SelectChainResponse({});
if (data.selected_ptr != null) {
message.selected_ptr = data.selected_ptr;
}
return message;
}
toObject() {
const data: {
selected_ptr?: number;
} = {};
if (this.selected_ptr != null) {
data.selected_ptr = this.selected_ptr;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.selected_ptr != 0) writer.writeInt32(1, this.selected_ptr);
if (!w) return writer.getResultBuffer();
}
static deserialize(
bytes: Uint8Array | pb_1.BinaryReader
): SelectChainResponse {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new SelectChainResponse();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.selected_ptr = reader.readInt32();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SelectChainResponse {
return SelectChainResponse.deserialize(bytes);
}
}
} }
export class StocJoinGame extends pb_1.Message { export class StocJoinGame extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
...@@ -7060,13 +7192,18 @@ export namespace ygopro { ...@@ -7060,13 +7192,18 @@ export namespace ygopro {
} }
} }
export namespace MsgSelectChain { export namespace MsgSelectChain {
export enum ChainFlag {
COMMON = 0,
EDESC_OPERATION = 1,
EDESC_RESET = 2,
}
export class Chain extends pb_1.Message { export class Chain extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor( constructor(
data?: data?:
| any[] | any[]
| { | {
flag?: number; flag?: StocGameMessage.MsgSelectChain.ChainFlag;
code?: number; code?: number;
location?: CardLocation; location?: CardLocation;
effect_description?: number; effect_description?: number;
...@@ -7104,9 +7241,13 @@ export namespace ygopro { ...@@ -7104,9 +7241,13 @@ export namespace ygopro {
} }
} }
get flag() { get flag() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number; return pb_1.Message.getFieldWithDefault(
this,
1,
StocGameMessage.MsgSelectChain.ChainFlag.COMMON
) as StocGameMessage.MsgSelectChain.ChainFlag;
} }
set flag(value: number) { set flag(value: StocGameMessage.MsgSelectChain.ChainFlag) {
pb_1.Message.setField(this, 1, value); pb_1.Message.setField(this, 1, value);
} }
get code() { get code() {
...@@ -7141,7 +7282,7 @@ export namespace ygopro { ...@@ -7141,7 +7282,7 @@ export namespace ygopro {
pb_1.Message.setField(this, 5, value); pb_1.Message.setField(this, 5, value);
} }
static fromObject(data: { static fromObject(data: {
flag?: number; flag?: StocGameMessage.MsgSelectChain.ChainFlag;
code?: number; code?: number;
location?: ReturnType<typeof CardLocation.prototype.toObject>; location?: ReturnType<typeof CardLocation.prototype.toObject>;
effect_description?: number; effect_description?: number;
...@@ -7167,7 +7308,7 @@ export namespace ygopro { ...@@ -7167,7 +7308,7 @@ export namespace ygopro {
} }
toObject() { toObject() {
const data: { const data: {
flag?: number; flag?: StocGameMessage.MsgSelectChain.ChainFlag;
code?: number; code?: number;
location?: ReturnType<typeof CardLocation.prototype.toObject>; location?: ReturnType<typeof CardLocation.prototype.toObject>;
effect_description?: number; effect_description?: number;
...@@ -7194,7 +7335,8 @@ export namespace ygopro { ...@@ -7194,7 +7335,8 @@ export namespace ygopro {
serialize(w: pb_1.BinaryWriter): void; serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void { serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter(); const writer = w || new pb_1.BinaryWriter();
if (this.flag != 0) writer.writeInt32(1, this.flag); if (this.flag != StocGameMessage.MsgSelectChain.ChainFlag.COMMON)
writer.writeEnum(1, this.flag);
if (this.code != 0) writer.writeInt32(2, this.code); if (this.code != 0) writer.writeInt32(2, this.code);
if (this.has_location) if (this.has_location)
writer.writeMessage(3, this.location, () => writer.writeMessage(3, this.location, () =>
...@@ -7215,7 +7357,7 @@ export namespace ygopro { ...@@ -7215,7 +7357,7 @@ export namespace ygopro {
if (reader.isEndGroup()) break; if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
case 1: case 1:
message.flag = reader.readInt32(); message.flag = reader.readEnum();
break; break;
case 2: case 2:
message.code = reader.readInt32(); message.code = reader.readInt32();
......
...@@ -4,6 +4,7 @@ import { CTOS_RESPONSE } from "../../protoDecl"; ...@@ -4,6 +4,7 @@ import { CTOS_RESPONSE } from "../../protoDecl";
import adaptSelectIdleCmdResponse from "./selectIdleCmd"; import adaptSelectIdleCmdResponse from "./selectIdleCmd";
import adaptSelectPlaceResponse from "./selectPlace"; import adaptSelectPlaceResponse from "./selectPlace";
import adaptSelectCardResponse from "./selectCard"; import adaptSelectCardResponse from "./selectCard";
import adaptSelectChainResponse from "./selectChain";
/* /*
* CTOS CTOS_RESPONSE * CTOS CTOS_RESPONSE
...@@ -34,6 +35,11 @@ export default class CtosResponsePacket extends YgoProPacket { ...@@ -34,6 +35,11 @@ export default class CtosResponsePacket extends YgoProPacket {
break; break;
} }
case "select_chain": {
extraData = adaptSelectChainResponse(response.select_chain);
break;
}
default: { default: {
break; break;
} }
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferWriter } from "../../bufferIO";
export default (response: ygopro.CtosGameMsgResponse.SelectChainResponse) => {
const array = new Uint8Array(4);
const writer = new BufferWriter(array, true);
writer.writeUint32(response.selected_ptr);
return array;
};
import { ygopro } from "../../../idl/ocgcore"; import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO"; import { BufferReader } from "../../bufferIO";
import MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain; import MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain;
import { numberToChainFlag } from "../../util";
/* /*
* Msg Select Chain * Msg Select Chain
...@@ -37,7 +38,7 @@ export default (data: Uint8Array) => { ...@@ -37,7 +38,7 @@ export default (data: Uint8Array) => {
msg.chains.push( msg.chains.push(
new MsgSelectChain.Chain({ new MsgSelectChain.Chain({
flag, flag: numberToChainFlag(flag),
code, code,
location, location,
effect_description: effect_desc, effect_description: effect_desc,
......
...@@ -191,3 +191,22 @@ export function numberToCardPosition( ...@@ -191,3 +191,22 @@ export function numberToCardPosition(
} }
} }
} }
export function numberToChainFlag(
flag: number
): ygopro.StocGameMessage.MsgSelectChain.ChainFlag | undefined {
switch (flag) {
case 0: {
return ygopro.StocGameMessage.MsgSelectChain.ChainFlag.COMMON;
}
case 1: {
return ygopro.StocGameMessage.MsgSelectChain.ChainFlag.EDESC_OPERATION;
}
case 2: {
return ygopro.StocGameMessage.MsgSelectChain.ChainFlag.EDESC_RESET;
}
default: {
return undefined;
}
}
}
...@@ -163,3 +163,16 @@ export function sendSelectCardResponse(value: number[]) { ...@@ -163,3 +163,16 @@ export function sendSelectCardResponse(value: number[]) {
socketMiddleWare({ cmd: socketCmd.SEND, payload }); socketMiddleWare({ cmd: socketCmd.SEND, payload });
} }
export function sendSelectChainResponse(value: number) {
const response = new ygopro.YgoCtosMsg({
ctos_response: new ygopro.CtosGameMsgResponse({
select_chain: new ygopro.CtosGameMsgResponse.SelectChainResponse({
selected_ptr: value,
}),
}),
});
const payload = new GameMsgResponse(response).serialize();
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
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