Commit 58ce6d5e authored by Chunchi Che's avatar Chunchi Che

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

Feat/service/select place

See merge request !48
parents e0fc2b96 6dad97f5
neos-protobuf @ 8cfeb7ac
Subproject commit 1ba7de35c6c717fe9f361dcdada8ffd6c43f9a8b Subproject commit 8cfeb7ac4563b27f2f56e36b53b1453a953d9a9c
...@@ -5,12 +5,171 @@ ...@@ -5,12 +5,171 @@
* git: https://github.com/thesayyn/protoc-gen-ts */ * git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf"; import * as pb_1 from "google-protobuf";
export namespace ygopro { export namespace ygopro {
export enum CardZone {
DECK = 0,
HAND = 1,
MZONE = 2,
SZONE = 3,
GRAVE = 4,
REMOVED = 5,
EXTRA = 6,
OVERLAY = 7,
ONFIELD = 8,
FZONE = 9,
PZONE = 10,
}
export enum HandType { export enum HandType {
UNKNOWN = 0, UNKNOWN = 0,
SCISSORS = 1, SCISSORS = 1,
ROCK = 2, ROCK = 2,
PAPER = 3, PAPER = 3,
} }
export class CardInfo extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
code?: number;
controler?: number;
location?: number;
sequence?: 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 ("code" in data && data.code != undefined) {
this.code = data.code;
}
if ("controler" in data && data.controler != undefined) {
this.controler = data.controler;
}
if ("location" in data && data.location != undefined) {
this.location = data.location;
}
if ("sequence" in data && data.sequence != undefined) {
this.sequence = data.sequence;
}
}
}
get code() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set code(value: number) {
pb_1.Message.setField(this, 1, value);
}
get controler() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set controler(value: number) {
pb_1.Message.setField(this, 2, value);
}
get location() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set location(value: number) {
pb_1.Message.setField(this, 3, value);
}
get sequence() {
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
}
set sequence(value: number) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: {
code?: number;
controler?: number;
location?: number;
sequence?: number;
}): CardInfo {
const message = new CardInfo({});
if (data.code != null) {
message.code = data.code;
}
if (data.controler != null) {
message.controler = data.controler;
}
if (data.location != null) {
message.location = data.location;
}
if (data.sequence != null) {
message.sequence = data.sequence;
}
return message;
}
toObject() {
const data: {
code?: number;
controler?: number;
location?: number;
sequence?: number;
} = {};
if (this.code != null) {
data.code = this.code;
}
if (this.controler != null) {
data.controler = this.controler;
}
if (this.location != null) {
data.location = this.location;
}
if (this.sequence != null) {
data.sequence = this.sequence;
}
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.code != 0) writer.writeInt32(1, this.code);
if (this.controler != 0) writer.writeInt32(2, this.controler);
if (this.location != 0) writer.writeInt32(3, this.location);
if (this.sequence != 0) writer.writeInt32(4, this.sequence);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CardInfo {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new CardInfo();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.code = reader.readInt32();
break;
case 2:
message.controler = reader.readInt32();
break;
case 3:
message.location = reader.readInt32();
break;
case 4:
message.sequence = reader.readInt32();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CardInfo {
return CardInfo.deserialize(bytes);
}
}
export class YgoCtosMsg extends pb_1.Message { export class YgoCtosMsg extends pb_1.Message {
#one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]; #one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]];
constructor( constructor(
...@@ -2069,13 +2228,20 @@ export namespace ygopro { ...@@ -2069,13 +2228,20 @@ export namespace ygopro {
} }
} }
export class CtosGameMsgResponse extends pb_1.Message { export class CtosGameMsgResponse extends pb_1.Message {
#one_of_decls: number[][] = [[1]]; #one_of_decls: number[][] = [[1, 2]];
constructor( constructor(
data?: data?:
| any[] | any[]
| ({} & { | ({} & (
select_idle_cmd?: CtosGameMsgResponse.SelectIdleCmdResponse; | {
}) select_idle_cmd?: CtosGameMsgResponse.SelectIdleCmdResponse;
select_place?: never;
}
| {
select_idle_cmd?: never;
select_place?: CtosGameMsgResponse.SelectPlaceResponse;
}
))
) { ) {
super(); super();
pb_1.Message.initialize( pb_1.Message.initialize(
...@@ -2090,6 +2256,9 @@ export namespace ygopro { ...@@ -2090,6 +2256,9 @@ export namespace ygopro {
if ("select_idle_cmd" in data && data.select_idle_cmd != undefined) { if ("select_idle_cmd" in data && data.select_idle_cmd != undefined) {
this.select_idle_cmd = data.select_idle_cmd; this.select_idle_cmd = data.select_idle_cmd;
} }
if ("select_place" in data && data.select_place != undefined) {
this.select_place = data.select_place;
}
} }
} }
get select_idle_cmd() { get select_idle_cmd() {
...@@ -2105,19 +2274,36 @@ export namespace ygopro { ...@@ -2105,19 +2274,36 @@ export namespace ygopro {
get has_select_idle_cmd() { get has_select_idle_cmd() {
return pb_1.Message.getField(this, 1) != null; return pb_1.Message.getField(this, 1) != null;
} }
get select_place() {
return pb_1.Message.getWrapperField(
this,
CtosGameMsgResponse.SelectPlaceResponse,
2
) as CtosGameMsgResponse.SelectPlaceResponse;
}
set select_place(value: CtosGameMsgResponse.SelectPlaceResponse) {
pb_1.Message.setOneofWrapperField(this, 2, this.#one_of_decls[0], value);
}
get has_select_place() {
return pb_1.Message.getField(this, 2) != null;
}
get gameMsgResponse() { get gameMsgResponse() {
const cases: { const cases: {
[index: number]: "none" | "select_idle_cmd"; [index: number]: "none" | "select_idle_cmd" | "select_place";
} = { } = {
0: "none", 0: "none",
1: "select_idle_cmd", 1: "select_idle_cmd",
2: "select_place",
}; };
return cases[pb_1.Message.computeOneofCase(this, [1])]; return cases[pb_1.Message.computeOneofCase(this, [1, 2])];
} }
static fromObject(data: { static fromObject(data: {
select_idle_cmd?: ReturnType< select_idle_cmd?: ReturnType<
typeof CtosGameMsgResponse.SelectIdleCmdResponse.prototype.toObject typeof CtosGameMsgResponse.SelectIdleCmdResponse.prototype.toObject
>; >;
select_place?: ReturnType<
typeof CtosGameMsgResponse.SelectPlaceResponse.prototype.toObject
>;
}): CtosGameMsgResponse { }): CtosGameMsgResponse {
const message = new CtosGameMsgResponse({}); const message = new CtosGameMsgResponse({});
if (data.select_idle_cmd != null) { if (data.select_idle_cmd != null) {
...@@ -2126,6 +2312,10 @@ export namespace ygopro { ...@@ -2126,6 +2312,10 @@ export namespace ygopro {
data.select_idle_cmd data.select_idle_cmd
); );
} }
if (data.select_place != null) {
message.select_place =
CtosGameMsgResponse.SelectPlaceResponse.fromObject(data.select_place);
}
return message; return message;
} }
toObject() { toObject() {
...@@ -2133,10 +2323,16 @@ export namespace ygopro { ...@@ -2133,10 +2323,16 @@ export namespace ygopro {
select_idle_cmd?: ReturnType< select_idle_cmd?: ReturnType<
typeof CtosGameMsgResponse.SelectIdleCmdResponse.prototype.toObject typeof CtosGameMsgResponse.SelectIdleCmdResponse.prototype.toObject
>; >;
select_place?: ReturnType<
typeof CtosGameMsgResponse.SelectPlaceResponse.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();
} }
if (this.select_place != null) {
data.select_place = this.select_place.toObject();
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
...@@ -2147,6 +2343,10 @@ export namespace ygopro { ...@@ -2147,6 +2343,10 @@ export namespace ygopro {
writer.writeMessage(1, this.select_idle_cmd, () => writer.writeMessage(1, this.select_idle_cmd, () =>
this.select_idle_cmd.serialize(writer) this.select_idle_cmd.serialize(writer)
); );
if (this.has_select_place)
writer.writeMessage(2, this.select_place, () =>
this.select_place.serialize(writer)
);
if (!w) return writer.getResultBuffer(); if (!w) return writer.getResultBuffer();
} }
static deserialize( static deserialize(
...@@ -2168,6 +2368,14 @@ export namespace ygopro { ...@@ -2168,6 +2368,14 @@ export namespace ygopro {
CtosGameMsgResponse.SelectIdleCmdResponse.deserialize(reader)) CtosGameMsgResponse.SelectIdleCmdResponse.deserialize(reader))
); );
break; break;
case 2:
reader.readMessage(
message.select_place,
() =>
(message.select_place =
CtosGameMsgResponse.SelectPlaceResponse.deserialize(reader))
);
break;
default: default:
reader.skipField(); reader.skipField();
} }
...@@ -2262,6 +2470,136 @@ export namespace ygopro { ...@@ -2262,6 +2470,136 @@ export namespace ygopro {
return SelectIdleCmdResponse.deserialize(bytes); return SelectIdleCmdResponse.deserialize(bytes);
} }
} }
export class SelectPlaceResponse extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
player?: number;
zone?: CardZone;
sequence?: 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 ("player" in data && data.player != undefined) {
this.player = data.player;
}
if ("zone" in data && data.zone != undefined) {
this.zone = data.zone;
}
if ("sequence" in data && data.sequence != undefined) {
this.sequence = data.sequence;
}
}
}
get player() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set player(value: number) {
pb_1.Message.setField(this, 1, value);
}
get zone() {
return pb_1.Message.getFieldWithDefault(
this,
2,
CardZone.DECK
) as CardZone;
}
set zone(value: CardZone) {
pb_1.Message.setField(this, 2, value);
}
get sequence() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set sequence(value: number) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
player?: number;
zone?: CardZone;
sequence?: number;
}): SelectPlaceResponse {
const message = new SelectPlaceResponse({});
if (data.player != null) {
message.player = data.player;
}
if (data.zone != null) {
message.zone = data.zone;
}
if (data.sequence != null) {
message.sequence = data.sequence;
}
return message;
}
toObject() {
const data: {
player?: number;
zone?: CardZone;
sequence?: number;
} = {};
if (this.player != null) {
data.player = this.player;
}
if (this.zone != null) {
data.zone = this.zone;
}
if (this.sequence != null) {
data.sequence = this.sequence;
}
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.player != 0) writer.writeInt32(1, this.player);
if (this.zone != CardZone.DECK) writer.writeEnum(2, this.zone);
if (this.sequence != 0) writer.writeInt32(3, this.sequence);
if (!w) return writer.getResultBuffer();
}
static deserialize(
bytes: Uint8Array | pb_1.BinaryReader
): SelectPlaceResponse {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new SelectPlaceResponse();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.player = reader.readInt32();
break;
case 2:
message.zone = reader.readEnum();
break;
case 3:
message.sequence = reader.readInt32();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SelectPlaceResponse {
return SelectPlaceResponse.deserialize(bytes);
}
}
} }
export class StocJoinGame extends pb_1.Message { export class StocJoinGame extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
...@@ -3641,7 +3979,7 @@ export namespace ygopro { ...@@ -3641,7 +3979,7 @@ export namespace ygopro {
} }
} }
export class StocGameMessage extends pb_1.Message { export class StocGameMessage extends pb_1.Message {
#one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6]]; #one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7]];
constructor( constructor(
data?: data?:
| any[] | any[]
...@@ -3653,6 +3991,7 @@ export namespace ygopro { ...@@ -3653,6 +3991,7 @@ export namespace ygopro {
new_phase?: never; new_phase?: never;
hint?: never; hint?: never;
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: never;
} }
| { | {
start?: never; start?: never;
...@@ -3661,6 +4000,7 @@ export namespace ygopro { ...@@ -3661,6 +4000,7 @@ export namespace ygopro {
new_phase?: never; new_phase?: never;
hint?: never; hint?: never;
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: never;
} }
| { | {
start?: never; start?: never;
...@@ -3669,6 +4009,7 @@ export namespace ygopro { ...@@ -3669,6 +4009,7 @@ export namespace ygopro {
new_phase?: never; new_phase?: never;
hint?: never; hint?: never;
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: never;
} }
| { | {
start?: never; start?: never;
...@@ -3677,6 +4018,7 @@ export namespace ygopro { ...@@ -3677,6 +4018,7 @@ export namespace ygopro {
new_phase?: StocGameMessage.MsgNewPhase; new_phase?: StocGameMessage.MsgNewPhase;
hint?: never; hint?: never;
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: never;
} }
| { | {
start?: never; start?: never;
...@@ -3685,6 +4027,7 @@ export namespace ygopro { ...@@ -3685,6 +4027,7 @@ export namespace ygopro {
new_phase?: never; new_phase?: never;
hint?: StocGameMessage.MsgHint; hint?: StocGameMessage.MsgHint;
select_idle_cmd?: never; select_idle_cmd?: never;
select_place?: never;
} }
| { | {
start?: never; start?: never;
...@@ -3693,6 +4036,16 @@ export namespace ygopro { ...@@ -3693,6 +4036,16 @@ export namespace ygopro {
new_phase?: never; new_phase?: never;
hint?: never; hint?: never;
select_idle_cmd?: StocGameMessage.MsgSelectIdleCmd; select_idle_cmd?: StocGameMessage.MsgSelectIdleCmd;
select_place?: never;
}
| {
start?: never;
draw?: never;
new_turn?: never;
new_phase?: never;
hint?: never;
select_idle_cmd?: never;
select_place?: StocGameMessage.MsgSelectPlace;
} }
)) ))
) { ) {
...@@ -3724,6 +4077,9 @@ export namespace ygopro { ...@@ -3724,6 +4077,9 @@ export namespace ygopro {
if ("select_idle_cmd" in data && data.select_idle_cmd != undefined) { if ("select_idle_cmd" in data && data.select_idle_cmd != undefined) {
this.select_idle_cmd = data.select_idle_cmd; this.select_idle_cmd = data.select_idle_cmd;
} }
if ("select_place" in data && data.select_place != undefined) {
this.select_place = data.select_place;
}
} }
} }
get start() { get start() {
...@@ -3804,6 +4160,19 @@ export namespace ygopro { ...@@ -3804,6 +4160,19 @@ export namespace ygopro {
get has_select_idle_cmd() { get has_select_idle_cmd() {
return pb_1.Message.getField(this, 6) != null; return pb_1.Message.getField(this, 6) != null;
} }
get select_place() {
return pb_1.Message.getWrapperField(
this,
StocGameMessage.MsgSelectPlace,
7
) as StocGameMessage.MsgSelectPlace;
}
set select_place(value: StocGameMessage.MsgSelectPlace) {
pb_1.Message.setOneofWrapperField(this, 7, this.#one_of_decls[0], value);
}
get has_select_place() {
return pb_1.Message.getField(this, 7) != null;
}
get gameMsg() { get gameMsg() {
const cases: { const cases: {
[index: number]: [index: number]:
...@@ -3813,7 +4182,8 @@ export namespace ygopro { ...@@ -3813,7 +4182,8 @@ export namespace ygopro {
| "new_turn" | "new_turn"
| "new_phase" | "new_phase"
| "hint" | "hint"
| "select_idle_cmd"; | "select_idle_cmd"
| "select_place";
} = { } = {
0: "none", 0: "none",
1: "start", 1: "start",
...@@ -3822,8 +4192,9 @@ export namespace ygopro { ...@@ -3822,8 +4192,9 @@ export namespace ygopro {
4: "new_phase", 4: "new_phase",
5: "hint", 5: "hint",
6: "select_idle_cmd", 6: "select_idle_cmd",
7: "select_place",
}; };
return cases[pb_1.Message.computeOneofCase(this, [1, 2, 3, 4, 5, 6])]; return cases[pb_1.Message.computeOneofCase(this, [1, 2, 3, 4, 5, 6, 7])];
} }
static fromObject(data: { static fromObject(data: {
start?: ReturnType<typeof StocGameMessage.MsgStart.prototype.toObject>; start?: ReturnType<typeof StocGameMessage.MsgStart.prototype.toObject>;
...@@ -3838,6 +4209,9 @@ export namespace ygopro { ...@@ -3838,6 +4209,9 @@ export namespace ygopro {
select_idle_cmd?: ReturnType< select_idle_cmd?: ReturnType<
typeof StocGameMessage.MsgSelectIdleCmd.prototype.toObject typeof StocGameMessage.MsgSelectIdleCmd.prototype.toObject
>; >;
select_place?: ReturnType<
typeof StocGameMessage.MsgSelectPlace.prototype.toObject
>;
}): StocGameMessage { }): StocGameMessage {
const message = new StocGameMessage({}); const message = new StocGameMessage({});
if (data.start != null) { if (data.start != null) {
...@@ -3862,6 +4236,11 @@ export namespace ygopro { ...@@ -3862,6 +4236,11 @@ export namespace ygopro {
data.select_idle_cmd data.select_idle_cmd
); );
} }
if (data.select_place != null) {
message.select_place = StocGameMessage.MsgSelectPlace.fromObject(
data.select_place
);
}
return message; return message;
} }
toObject() { toObject() {
...@@ -3878,6 +4257,9 @@ export namespace ygopro { ...@@ -3878,6 +4257,9 @@ export namespace ygopro {
select_idle_cmd?: ReturnType< select_idle_cmd?: ReturnType<
typeof StocGameMessage.MsgSelectIdleCmd.prototype.toObject typeof StocGameMessage.MsgSelectIdleCmd.prototype.toObject
>; >;
select_place?: ReturnType<
typeof StocGameMessage.MsgSelectPlace.prototype.toObject
>;
} = {}; } = {};
if (this.start != null) { if (this.start != null) {
data.start = this.start.toObject(); data.start = this.start.toObject();
...@@ -3897,6 +4279,9 @@ export namespace ygopro { ...@@ -3897,6 +4279,9 @@ export namespace ygopro {
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();
} }
if (this.select_place != null) {
data.select_place = this.select_place.toObject();
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
...@@ -3921,6 +4306,10 @@ export namespace ygopro { ...@@ -3921,6 +4306,10 @@ export namespace ygopro {
writer.writeMessage(6, this.select_idle_cmd, () => writer.writeMessage(6, this.select_idle_cmd, () =>
this.select_idle_cmd.serialize(writer) this.select_idle_cmd.serialize(writer)
); );
if (this.has_select_place)
writer.writeMessage(7, this.select_place, () =>
this.select_place.serialize(writer)
);
if (!w) return writer.getResultBuffer(); if (!w) return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StocGameMessage { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StocGameMessage {
...@@ -3975,6 +4364,14 @@ export namespace ygopro { ...@@ -3975,6 +4364,14 @@ export namespace ygopro {
StocGameMessage.MsgSelectIdleCmd.deserialize(reader)) StocGameMessage.MsgSelectIdleCmd.deserialize(reader))
); );
break; break;
case 7:
reader.readMessage(
message.select_place,
() =>
(message.select_place =
StocGameMessage.MsgSelectPlace.deserialize(reader))
);
break;
default: default:
reader.skipField(); reader.skipField();
} }
...@@ -3989,153 +4386,7 @@ export namespace ygopro { ...@@ -3989,153 +4386,7 @@ export namespace ygopro {
} }
} }
export namespace StocGameMessage { export namespace StocGameMessage {
export class CardInfo extends pb_1.Message { export class MsgStart extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
code?: number;
controler?: number;
location?: number;
sequence?: 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 ("code" in data && data.code != undefined) {
this.code = data.code;
}
if ("controler" in data && data.controler != undefined) {
this.controler = data.controler;
}
if ("location" in data && data.location != undefined) {
this.location = data.location;
}
if ("sequence" in data && data.sequence != undefined) {
this.sequence = data.sequence;
}
}
}
get code() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set code(value: number) {
pb_1.Message.setField(this, 1, value);
}
get controler() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set controler(value: number) {
pb_1.Message.setField(this, 2, value);
}
get location() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set location(value: number) {
pb_1.Message.setField(this, 3, value);
}
get sequence() {
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
}
set sequence(value: number) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: {
code?: number;
controler?: number;
location?: number;
sequence?: number;
}): CardInfo {
const message = new CardInfo({});
if (data.code != null) {
message.code = data.code;
}
if (data.controler != null) {
message.controler = data.controler;
}
if (data.location != null) {
message.location = data.location;
}
if (data.sequence != null) {
message.sequence = data.sequence;
}
return message;
}
toObject() {
const data: {
code?: number;
controler?: number;
location?: number;
sequence?: number;
} = {};
if (this.code != null) {
data.code = this.code;
}
if (this.controler != null) {
data.controler = this.controler;
}
if (this.location != null) {
data.location = this.location;
}
if (this.sequence != null) {
data.sequence = this.sequence;
}
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.code != 0) writer.writeInt32(1, this.code);
if (this.controler != 0) writer.writeInt32(2, this.controler);
if (this.location != 0) writer.writeInt32(3, this.location);
if (this.sequence != 0) writer.writeInt32(4, this.sequence);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CardInfo {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new CardInfo();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.code = reader.readInt32();
break;
case 2:
message.controler = reader.readInt32();
break;
case 3:
message.location = reader.readInt32();
break;
case 4:
message.sequence = reader.readInt32();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CardInfo {
return CardInfo.deserialize(bytes);
}
}
export class MsgStart extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor( constructor(
data?: data?:
...@@ -5165,7 +5416,7 @@ export namespace ygopro { ...@@ -5165,7 +5416,7 @@ export namespace ygopro {
data?: data?:
| any[] | any[]
| { | {
card_info?: StocGameMessage.CardInfo; card_info?: CardInfo;
effect_description?: number; effect_description?: number;
response?: number; response?: number;
} }
...@@ -5195,13 +5446,9 @@ export namespace ygopro { ...@@ -5195,13 +5446,9 @@ export namespace ygopro {
} }
} }
get card_info() { get card_info() {
return pb_1.Message.getWrapperField( return pb_1.Message.getWrapperField(this, CardInfo, 1) as CardInfo;
this,
StocGameMessage.CardInfo,
1
) as StocGameMessage.CardInfo;
} }
set card_info(value: StocGameMessage.CardInfo) { set card_info(value: CardInfo) {
pb_1.Message.setWrapperField(this, 1, value); pb_1.Message.setWrapperField(this, 1, value);
} }
get has_card_info() { get has_card_info() {
...@@ -5220,17 +5467,13 @@ export namespace ygopro { ...@@ -5220,17 +5467,13 @@ export namespace ygopro {
pb_1.Message.setField(this, 3, value); pb_1.Message.setField(this, 3, value);
} }
static fromObject(data: { static fromObject(data: {
card_info?: ReturnType< card_info?: ReturnType<typeof CardInfo.prototype.toObject>;
typeof StocGameMessage.CardInfo.prototype.toObject
>;
effect_description?: number; effect_description?: number;
response?: number; response?: number;
}): IdleData { }): IdleData {
const message = new IdleData({}); const message = new IdleData({});
if (data.card_info != null) { if (data.card_info != null) {
message.card_info = StocGameMessage.CardInfo.fromObject( message.card_info = CardInfo.fromObject(data.card_info);
data.card_info
);
} }
if (data.effect_description != null) { if (data.effect_description != null) {
message.effect_description = data.effect_description; message.effect_description = data.effect_description;
...@@ -5242,9 +5485,7 @@ export namespace ygopro { ...@@ -5242,9 +5485,7 @@ export namespace ygopro {
} }
toObject() { toObject() {
const data: { const data: {
card_info?: ReturnType< card_info?: ReturnType<typeof CardInfo.prototype.toObject>;
typeof StocGameMessage.CardInfo.prototype.toObject
>;
effect_description?: number; effect_description?: number;
response?: number; response?: number;
} = {}; } = {};
...@@ -5284,9 +5525,7 @@ export namespace ygopro { ...@@ -5284,9 +5525,7 @@ export namespace ygopro {
case 1: case 1:
reader.readMessage( reader.readMessage(
message.card_info, message.card_info,
() => () => (message.card_info = CardInfo.deserialize(reader))
(message.card_info =
StocGameMessage.CardInfo.deserialize(reader))
); );
break; break;
case 2: case 2:
...@@ -5310,5 +5549,291 @@ export namespace ygopro { ...@@ -5310,5 +5549,291 @@ export namespace ygopro {
} }
} }
} }
export class MsgSelectPlace extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
player?: number;
count?: number;
places?: StocGameMessage.MsgSelectPlace.SelectAblePlace[];
}
) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[3],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
if ("player" in data && data.player != undefined) {
this.player = data.player;
}
if ("count" in data && data.count != undefined) {
this.count = data.count;
}
if ("places" in data && data.places != undefined) {
this.places = data.places;
}
}
}
get player() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set player(value: number) {
pb_1.Message.setField(this, 1, value);
}
get count() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set count(value: number) {
pb_1.Message.setField(this, 2, value);
}
get places() {
return pb_1.Message.getRepeatedWrapperField(
this,
StocGameMessage.MsgSelectPlace.SelectAblePlace,
3
) as StocGameMessage.MsgSelectPlace.SelectAblePlace[];
}
set places(value: StocGameMessage.MsgSelectPlace.SelectAblePlace[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
static fromObject(data: {
player?: number;
count?: number;
places?: ReturnType<
typeof StocGameMessage.MsgSelectPlace.SelectAblePlace.prototype.toObject
>[];
}): MsgSelectPlace {
const message = new MsgSelectPlace({});
if (data.player != null) {
message.player = data.player;
}
if (data.count != null) {
message.count = data.count;
}
if (data.places != null) {
message.places = data.places.map((item) =>
StocGameMessage.MsgSelectPlace.SelectAblePlace.fromObject(item)
);
}
return message;
}
toObject() {
const data: {
player?: number;
count?: number;
places?: ReturnType<
typeof StocGameMessage.MsgSelectPlace.SelectAblePlace.prototype.toObject
>[];
} = {};
if (this.player != null) {
data.player = this.player;
}
if (this.count != null) {
data.count = this.count;
}
if (this.places != null) {
data.places = this.places.map(
(item: StocGameMessage.MsgSelectPlace.SelectAblePlace) =>
item.toObject()
);
}
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.player != 0) writer.writeInt32(1, this.player);
if (this.count != 0) writer.writeInt32(2, this.count);
if (this.places.length)
writer.writeRepeatedMessage(
3,
this.places,
(item: StocGameMessage.MsgSelectPlace.SelectAblePlace) =>
item.serialize(writer)
);
if (!w) return writer.getResultBuffer();
}
static deserialize(
bytes: Uint8Array | pb_1.BinaryReader
): MsgSelectPlace {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new MsgSelectPlace();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.player = reader.readInt32();
break;
case 2:
message.count = reader.readInt32();
break;
case 3:
reader.readMessage(message.places, () =>
pb_1.Message.addToRepeatedWrapperField(
message,
3,
StocGameMessage.MsgSelectPlace.SelectAblePlace.deserialize(
reader
),
StocGameMessage.MsgSelectPlace.SelectAblePlace
)
);
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgSelectPlace {
return MsgSelectPlace.deserialize(bytes);
}
}
export namespace MsgSelectPlace {
export class SelectAblePlace extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
controler?: number;
zone?: CardZone;
sequence?: 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 ("controler" in data && data.controler != undefined) {
this.controler = data.controler;
}
if ("zone" in data && data.zone != undefined) {
this.zone = data.zone;
}
if ("sequence" in data && data.sequence != undefined) {
this.sequence = data.sequence;
}
}
}
get controler() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set controler(value: number) {
pb_1.Message.setField(this, 1, value);
}
get zone() {
return pb_1.Message.getFieldWithDefault(
this,
2,
CardZone.DECK
) as CardZone;
}
set zone(value: CardZone) {
pb_1.Message.setField(this, 2, value);
}
get sequence() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set sequence(value: number) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
controler?: number;
zone?: CardZone;
sequence?: number;
}): SelectAblePlace {
const message = new SelectAblePlace({});
if (data.controler != null) {
message.controler = data.controler;
}
if (data.zone != null) {
message.zone = data.zone;
}
if (data.sequence != null) {
message.sequence = data.sequence;
}
return message;
}
toObject() {
const data: {
controler?: number;
zone?: CardZone;
sequence?: number;
} = {};
if (this.controler != null) {
data.controler = this.controler;
}
if (this.zone != null) {
data.zone = this.zone;
}
if (this.sequence != null) {
data.sequence = this.sequence;
}
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.controler != 0) writer.writeInt32(1, this.controler);
if (this.zone != CardZone.DECK) writer.writeEnum(2, this.zone);
if (this.sequence != 0) writer.writeInt32(3, this.sequence);
if (!w) return writer.getResultBuffer();
}
static deserialize(
bytes: Uint8Array | pb_1.BinaryReader
): SelectAblePlace {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new SelectAblePlace();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.controler = reader.readInt32();
break;
case 2:
message.zone = reader.readEnum();
break;
case 3:
message.sequence = reader.readInt32();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SelectAblePlace {
return SelectAblePlace.deserialize(bytes);
}
}
}
} }
} }
...@@ -52,8 +52,8 @@ export class BufferReader { ...@@ -52,8 +52,8 @@ export class BufferReader {
return ret; return ret;
} }
readCardInfo(): ygopro.StocGameMessage.CardInfo { readCardInfo(): ygopro.CardInfo {
const cardInfo = new ygopro.StocGameMessage.CardInfo({}); const cardInfo = new ygopro.CardInfo({});
cardInfo.code = this.readUint32(); cardInfo.code = this.readUint32();
cardInfo.controler = this.readUint8(); cardInfo.controler = this.readUint8();
......
...@@ -32,3 +32,4 @@ export const MSG_NEW_TURN = 40; ...@@ -32,3 +32,4 @@ export const MSG_NEW_TURN = 40;
export const MSG_NEW_PHASE = 41; export const MSG_NEW_PHASE = 41;
export const MSG_HINT = 2; export const MSG_HINT = 2;
export const MSG_SELECT_IDLE_CMD = 11; export const MSG_SELECT_IDLE_CMD = 11;
export const MSG_SELECT_PLACE = 18;
...@@ -12,6 +12,7 @@ import MsgNewTurnAdapter from "./newTurn"; ...@@ -12,6 +12,7 @@ import MsgNewTurnAdapter from "./newTurn";
import MsgNewPhaseAdapter from "./newPhase"; import MsgNewPhaseAdapter from "./newPhase";
import MsgHintAdapter from "./hint"; import MsgHintAdapter from "./hint";
import MsgSelectIdleCmdAdapter from "./selectIdleCmd"; import MsgSelectIdleCmdAdapter from "./selectIdleCmd";
import MsgSelectPlaceAdapter from "./selectPlace";
/* /*
* STOC GameMsg * STOC GameMsg
...@@ -67,6 +68,11 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -67,6 +68,11 @@ export default class GameMsgAdapter implements StocAdapter {
break; break;
} }
case GAME_MSG.MSG_SELECT_PLACE: {
gameMsg.select_place = MsgSelectPlaceAdapter(gameData);
break;
}
default: { default: {
console.log("Unhandled GameMessage function=", func); console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
import MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace;
/*
* Msg Select Place
*
* @param - see: https://code.mycard.moe/mycard/neos-protobuf/-/blob/main/idl/ocgcore.proto
*
* @usage - 玩家可选择的位置
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, true);
const player = reader.readUint8();
let count = reader.readUint8();
const _field = ~reader.readUint32();
// TODO: 暂时和`ygopro2`一样不支持取消操作,后续需要再考虑加上
if (count == 0) {
count = 1;
}
const msg = new MsgSelectPlace({
player,
count,
places: [],
});
for (let i = 0; i < 2; i++) {
const controler = i == 0 ? player : 1 - player;
const field = i == 0 ? _field & 0xffff : _field >> 16;
if ((field & 0x7f) != 0) {
// 怪兽区
const zone = ygopro.CardZone.MZONE;
const filter = field & 0x7f;
for (let sequence = 0; sequence < 7; sequence++) {
if ((filter & (1 << sequence)) != 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controler,
zone,
sequence: sequence,
})
);
}
}
}
if ((field & 0x1f00) != 0) {
// 魔法陷阱区
const zone = ygopro.CardZone.SZONE;
const filter = (field >> 8) & 0x1f;
for (let sequence = 0; sequence < 5; sequence++) {
if ((filter & (1 << sequence)) != 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controler,
zone,
sequence,
})
);
}
}
}
if ((field & 0xc000) != 0) {
// 灵摆区?
const zone = ygopro.CardZone.SZONE;
const filter = (field >> 14) & 0x3;
if ((filter & 0x1) != 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controler,
zone,
sequence: 6,
})
);
}
if ((filter & 0x2) != 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controler,
zone,
sequence: 7,
})
);
}
}
}
return msg;
};
...@@ -2,6 +2,7 @@ import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit"; ...@@ -2,6 +2,7 @@ import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit";
import { DuelState } from "./mod"; import { DuelState } from "./mod";
import { RootState } from "../../store"; import { RootState } from "../../store";
import { fetchStrings } from "../../api/strings"; import { fetchStrings } from "../../api/strings";
import { fetchCard } from "../../api/cards";
import { judgeSelf } from "./util"; import { judgeSelf } from "./util";
export interface HintState { export interface HintState {
...@@ -9,8 +10,8 @@ export interface HintState { ...@@ -9,8 +10,8 @@ export interface HintState {
msg?: string; msg?: string;
} }
export const fetchHintMeta = createAsyncThunk( export const fetchCommonHintMeta = createAsyncThunk(
"duel/fetchHintMeta", "duel/fetchCommonHintMeta",
async (param: [number, number]) => { async (param: [number, number]) => {
const player = param[0]; const player = param[0];
const hintData = param[1]; const hintData = param[1];
...@@ -22,8 +23,21 @@ export const fetchHintMeta = createAsyncThunk( ...@@ -22,8 +23,21 @@ export const fetchHintMeta = createAsyncThunk(
} }
); );
export const fetchSelectPlaceHintMeta = createAsyncThunk(
"duel/fetchSelectPlaceHintMeta",
async (param: [number, number]) => {
const player = param[0];
const hintData = param[1];
const hintMeta = (await fetchCard(hintData)).text.name || "[?]";
const response: [number, string] = [player, hintMeta];
return response;
}
);
export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => { export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
builder.addCase(fetchHintMeta.pending, (state, action) => { builder.addCase(fetchCommonHintMeta.pending, (state, action) => {
const player = action.meta.arg[0]; const player = action.meta.arg[0];
const code = action.meta.arg[1]; const code = action.meta.arg[1];
...@@ -33,7 +47,7 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => { ...@@ -33,7 +47,7 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
state.opHint = { code }; state.opHint = { code };
} }
}); });
builder.addCase(fetchHintMeta.fulfilled, (state, action) => { builder.addCase(fetchCommonHintMeta.fulfilled, (state, action) => {
const player = action.payload[0]; const player = action.payload[0];
const hintMeta = action.payload[1]; const hintMeta = action.payload[1];
...@@ -42,6 +56,31 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => { ...@@ -42,6 +56,31 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
hint.msg = hintMeta; hint.msg = hintMeta;
} }
}); });
builder.addCase(fetchSelectPlaceHintMeta.pending, (state, action) => {
const player = action.meta.arg[0];
const code = action.meta.arg[1];
if (judgeSelf(player, state)) {
state.meHint = { code };
} else {
state.opHint = { code };
}
});
builder.addCase(fetchSelectPlaceHintMeta.fulfilled, (state, action) => {
const player = action.payload[0];
const hintMeta = action.payload[1];
// TODO: 国际化文案
const hintMsg = judgeSelf(player, state)
? `请为我方的<${hintMeta}>选择位置`
: `请为对方的<${hintMeta}>选择位置`;
const hint = judgeSelf(player, state) ? state.meHint : state.opHint;
if (hint) {
hint.msg = hintMsg;
}
});
}; };
export const selectMeHint = (state: RootState) => state.duel.meHint; export const selectMeHint = (state: RootState) => state.duel.meHint;
......
...@@ -6,6 +6,7 @@ import onMsgNewTurn from "./newTurn"; ...@@ -6,6 +6,7 @@ import onMsgNewTurn from "./newTurn";
import onMsgNewPhase from "./newPhase"; import onMsgNewPhase from "./newPhase";
import onMsgHint from "./hint"; import onMsgHint from "./hint";
import onMsgSelectIdleCmd from "./selectIdleCmd"; import onMsgSelectIdleCmd from "./selectIdleCmd";
import onMsgSelectPlace from "./selectPlace";
export default function handleGameMsg(pb: ygopro.YgoStocMsg) { export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
const dispatch = store.dispatch; const dispatch = store.dispatch;
...@@ -54,6 +55,13 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -54,6 +55,13 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break; break;
} }
case "select_place": {
const selectPlace = msg.select_place;
onMsgSelectPlace(selectPlace, dispatch);
break;
}
default: { default: {
break; break;
} }
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore"; import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store"; import { AppDispatch } from "../../store";
import { fetchHintMeta } from "../../reducers/duel/hintSlice"; import {
fetchCommonHintMeta,
fetchSelectPlaceHintMeta,
} from "../../reducers/duel/hintSlice";
import MsgHint = ygopro.StocGameMessage.MsgHint; import MsgHint = ygopro.StocGameMessage.MsgHint;
export default (hint: MsgHint, dispatch: AppDispatch) => { export default (hint: MsgHint, dispatch: AppDispatch) => {
...@@ -8,7 +11,11 @@ export default (hint: MsgHint, dispatch: AppDispatch) => { ...@@ -8,7 +11,11 @@ export default (hint: MsgHint, dispatch: AppDispatch) => {
switch (hint.hint_type) { switch (hint.hint_type) {
case MsgHint.HintType.HINT_EVENT: case MsgHint.HintType.HINT_EVENT:
case MsgHint.HintType.HINT_MESSAGE: { case MsgHint.HintType.HINT_MESSAGE: {
dispatch(fetchHintMeta([player, hint.hint_data])); dispatch(fetchCommonHintMeta([player, hint.hint_data]));
break;
}
case MsgHint.HintType.HINT_SELECTMSG: {
dispatch(fetchSelectPlaceHintMeta([player, hint.hint_data]));
break; break;
} }
default: { default: {
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace;
export default (selectPlace: MsgSelectPlace, dispatch: AppDispatch) => {
// TODO
console.log(selectPlace);
};
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