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() {
break;
}
case "stoc_hs_player_change": {
// todo: rerange neos-protobuf, design better API for neos-ts
const status = pb.stoc_hs_player_change.status;
const change = pb.stoc_hs_player_change;
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;
}
default: {
......
......@@ -1248,37 +1248,73 @@ export namespace ygopro {
export class StocHsPlayerChange extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
status?: number;
state?: StocHsPlayerChange.State;
pos?: number;
moved_pos?: 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 ("status" in data && data.status != undefined) {
this.status = data.status;
if ("state" in data && data.state != undefined) {
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() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set status(value: number) {
get state() {
return pb_1.Message.getFieldWithDefault(this, 1, StocHsPlayerChange.State.UNKNOWN) as StocHsPlayerChange.State;
}
set state(value: StocHsPlayerChange.State) {
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: {
status?: number;
state?: StocHsPlayerChange.State;
pos?: number;
moved_pos?: number;
}): StocHsPlayerChange {
const message = new StocHsPlayerChange({});
if (data.status != null) {
message.status = data.status;
if (data.state != null) {
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;
}
toObject() {
const data: {
status?: number;
state?: StocHsPlayerChange.State;
pos?: number;
moved_pos?: number;
} = {};
if (this.status != null) {
data.status = this.status;
if (this.state != null) {
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;
}
......@@ -1286,8 +1322,12 @@ export namespace ygopro {
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.status != 0)
writer.writeInt32(1, this.status);
if (this.state != StocHsPlayerChange.State.UNKNOWN)
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)
return writer.getResultBuffer();
}
......@@ -1298,7 +1338,13 @@ export namespace ygopro {
break;
switch (reader.getFieldNumber()) {
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;
default: reader.skipField();
}
......@@ -1312,4 +1358,14 @@ export namespace ygopro {
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