Commit abe4c3af authored by Chunchi Che's avatar Chunchi Che Committed by GitHub

Merge pull request #11 from DarkNeos/dev

Dev
parents 0472f9eb 31664f9f
Subproject commit 27613d3f1ebddafc11739501100d8f5973aa0e7b Subproject commit b76a7b646366e85d3a1d7652525790e08c1be39d
...@@ -62,10 +62,46 @@ export default function WaitRoom() { ...@@ -62,10 +62,46 @@ export default function WaitRoom() {
break; break;
} }
case "stoc_hs_player_change": { case "stoc_hs_player_change": {
// todo: rerange neos-protobuf, design better API for neos-ts const change = pb.stoc_hs_player_change;
const status = pb.stoc_hs_player_change.status;
switch (change.state) {
case ygopro.StocHsPlayerChange.State.UNKNOWN: {
console.log("Unknown HsPlayerChange State");
break;
}
case ygopro.StocHsPlayerChange.State.MOVE: {
console.log(
"Player " + change.pos + " moved to " + change.moved_pos
);
break;
}
case ygopro.StocHsPlayerChange.State.READY: {
console.log("Player " + change.pos + " has ready");
break;
}
case ygopro.StocHsPlayerChange.State.NO_READY: {
console.log("Player " + change.pos + " not ready");
break;
}
case ygopro.StocHsPlayerChange.State.LEAVE: {
console.log("Player " + change.pos + " has leave");
break;
}
case ygopro.StocHsPlayerChange.State.TO_OBSERVER: {
console.log("Player " + change.pos + " has moved to observer");
break;
}
default: {
break;
}
}
console.log("Hs player changed, status=" + status);
break; break;
} }
default: { default: {
......
...@@ -1248,37 +1248,73 @@ export namespace ygopro { ...@@ -1248,37 +1248,73 @@ export namespace ygopro {
export class StocHsPlayerChange extends pb_1.Message { export class StocHsPlayerChange extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
status?: number; state?: StocHsPlayerChange.State;
pos?: number;
moved_pos?: number;
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { if (!Array.isArray(data) && typeof data == "object") {
if ("status" in data && data.status != undefined) { if ("state" in data && data.state != undefined) {
this.status = data.status; this.state = data.state;
}
if ("pos" in data && data.pos != undefined) {
this.pos = data.pos;
}
if ("moved_pos" in data && data.moved_pos != undefined) {
this.moved_pos = data.moved_pos;
} }
} }
} }
get status() { get state() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number; return pb_1.Message.getFieldWithDefault(this, 1, StocHsPlayerChange.State.UNKNOWN) as StocHsPlayerChange.State;
} }
set status(value: number) { set state(value: StocHsPlayerChange.State) {
pb_1.Message.setField(this, 1, value); pb_1.Message.setField(this, 1, value);
} }
get pos() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set pos(value: number) {
pb_1.Message.setField(this, 2, value);
}
get moved_pos() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set moved_pos(value: number) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: { static fromObject(data: {
status?: number; state?: StocHsPlayerChange.State;
pos?: number;
moved_pos?: number;
}): StocHsPlayerChange { }): StocHsPlayerChange {
const message = new StocHsPlayerChange({}); const message = new StocHsPlayerChange({});
if (data.status != null) { if (data.state != null) {
message.status = data.status; message.state = data.state;
}
if (data.pos != null) {
message.pos = data.pos;
}
if (data.moved_pos != null) {
message.moved_pos = data.moved_pos;
} }
return message; return message;
} }
toObject() { toObject() {
const data: { const data: {
status?: number; state?: StocHsPlayerChange.State;
pos?: number;
moved_pos?: number;
} = {}; } = {};
if (this.status != null) { if (this.state != null) {
data.status = this.status; data.state = this.state;
}
if (this.pos != null) {
data.pos = this.pos;
}
if (this.moved_pos != null) {
data.moved_pos = this.moved_pos;
} }
return data; return data;
} }
...@@ -1286,8 +1322,12 @@ export namespace ygopro { ...@@ -1286,8 +1322,12 @@ 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.status != 0) if (this.state != StocHsPlayerChange.State.UNKNOWN)
writer.writeInt32(1, this.status); writer.writeEnum(1, this.state);
if (this.pos != 0)
writer.writeInt32(2, this.pos);
if (this.moved_pos != 0)
writer.writeInt32(3, this.moved_pos);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
...@@ -1298,7 +1338,13 @@ export namespace ygopro { ...@@ -1298,7 +1338,13 @@ export namespace ygopro {
break; break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
case 1: case 1:
message.status = reader.readInt32(); message.state = reader.readEnum();
break;
case 2:
message.pos = reader.readInt32();
break;
case 3:
message.moved_pos = reader.readInt32();
break; break;
default: reader.skipField(); default: reader.skipField();
} }
...@@ -1312,4 +1358,14 @@ export namespace ygopro { ...@@ -1312,4 +1358,14 @@ export namespace ygopro {
return StocHsPlayerChange.deserialize(bytes); return StocHsPlayerChange.deserialize(bytes);
} }
} }
export namespace StocHsPlayerChange {
export enum State {
UNKNOWN = 0,
MOVE = 1,
READY = 2,
NO_READY = 3,
LEAVE = 4,
TO_OBSERVER = 5
}
}
} }
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