Commit 51be8259 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/page/mora' into 'main'

Feat/page/mora

See merge request mycard/Neos!12
parents f2c72f63 11db95f1
Subproject commit d1e33713852a59ad63e7d0ead32f5a0e032f4644
Subproject commit 53a9cf4cf7cdfc55f1bfa7d86d74e61c56a5533f
......@@ -5,8 +5,14 @@
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export namespace ygopro {
export enum HandType {
UNKNOWN = 0,
SCISSORS = 1,
ROCK = 2,
PAPER = 3,
}
export class YgoCtosMsg 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, 8]];
constructor(
data?:
| any[]
......@@ -18,6 +24,8 @@ export namespace ygopro {
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
......@@ -26,6 +34,8 @@ export namespace ygopro {
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
......@@ -34,6 +44,8 @@ export namespace ygopro {
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
......@@ -42,6 +54,8 @@ export namespace ygopro {
ctos_hs_ready?: CtosHsReady;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
......@@ -50,6 +64,8 @@ export namespace ygopro {
ctos_hs_ready?: never;
ctos_hs_start?: CtosHsStart;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
......@@ -58,6 +74,28 @@ export namespace ygopro {
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: CtosHsNotReady;
ctos_hand_result?: never;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
ctos_join_game?: never;
ctos_update_deck?: never;
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: CtosHandResult;
ctos_tp_result?: never;
}
| {
ctos_player_info?: never;
ctos_join_game?: never;
ctos_update_deck?: never;
ctos_hs_ready?: never;
ctos_hs_start?: never;
ctos_hs_not_ready?: never;
ctos_hand_result?: never;
ctos_tp_result?: CtosTpResult;
}
))
) {
......@@ -92,6 +130,12 @@ export namespace ygopro {
) {
this.ctos_hs_not_ready = data.ctos_hs_not_ready;
}
if ("ctos_hand_result" in data && data.ctos_hand_result != undefined) {
this.ctos_hand_result = data.ctos_hand_result;
}
if ("ctos_tp_result" in data && data.ctos_tp_result != undefined) {
this.ctos_tp_result = data.ctos_tp_result;
}
}
}
get ctos_player_info() {
......@@ -164,6 +208,32 @@ export namespace ygopro {
get has_ctos_hs_not_ready() {
return pb_1.Message.getField(this, 6) != null;
}
get ctos_hand_result() {
return pb_1.Message.getWrapperField(
this,
CtosHandResult,
7
) as CtosHandResult;
}
set ctos_hand_result(value: CtosHandResult) {
pb_1.Message.setOneofWrapperField(this, 7, this.#one_of_decls[0], value);
}
get has_ctos_hand_result() {
return pb_1.Message.getField(this, 7) != null;
}
get ctos_tp_result() {
return pb_1.Message.getWrapperField(
this,
CtosTpResult,
8
) as CtosTpResult;
}
set ctos_tp_result(value: CtosTpResult) {
pb_1.Message.setOneofWrapperField(this, 8, this.#one_of_decls[0], value);
}
get has_ctos_tp_result() {
return pb_1.Message.getField(this, 8) != null;
}
get msg() {
const cases: {
[index: number]:
......@@ -173,7 +243,9 @@ export namespace ygopro {
| "ctos_update_deck"
| "ctos_hs_ready"
| "ctos_hs_start"
| "ctos_hs_not_ready";
| "ctos_hs_not_ready"
| "ctos_hand_result"
| "ctos_tp_result";
} = {
0: "none",
1: "ctos_player_info",
......@@ -182,8 +254,12 @@ export namespace ygopro {
4: "ctos_hs_ready",
5: "ctos_hs_start",
6: "ctos_hs_not_ready",
7: "ctos_hand_result",
8: "ctos_tp_result",
};
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, 8])
];
}
static fromObject(data: {
ctos_player_info?: ReturnType<typeof CtosPlayerInfo.prototype.toObject>;
......@@ -192,6 +268,8 @@ export namespace ygopro {
ctos_hs_ready?: ReturnType<typeof CtosHsReady.prototype.toObject>;
ctos_hs_start?: ReturnType<typeof CtosHsStart.prototype.toObject>;
ctos_hs_not_ready?: ReturnType<typeof CtosHsNotReady.prototype.toObject>;
ctos_hand_result?: ReturnType<typeof CtosHandResult.prototype.toObject>;
ctos_tp_result?: ReturnType<typeof CtosTpResult.prototype.toObject>;
}): YgoCtosMsg {
const message = new YgoCtosMsg({});
if (data.ctos_player_info != null) {
......@@ -218,6 +296,14 @@ export namespace ygopro {
data.ctos_hs_not_ready
);
}
if (data.ctos_hand_result != null) {
message.ctos_hand_result = CtosHandResult.fromObject(
data.ctos_hand_result
);
}
if (data.ctos_tp_result != null) {
message.ctos_tp_result = CtosTpResult.fromObject(data.ctos_tp_result);
}
return message;
}
toObject() {
......@@ -230,6 +316,8 @@ export namespace ygopro {
ctos_hs_not_ready?: ReturnType<
typeof CtosHsNotReady.prototype.toObject
>;
ctos_hand_result?: ReturnType<typeof CtosHandResult.prototype.toObject>;
ctos_tp_result?: ReturnType<typeof CtosTpResult.prototype.toObject>;
} = {};
if (this.ctos_player_info != null) {
data.ctos_player_info = this.ctos_player_info.toObject();
......@@ -249,6 +337,12 @@ export namespace ygopro {
if (this.ctos_hs_not_ready != null) {
data.ctos_hs_not_ready = this.ctos_hs_not_ready.toObject();
}
if (this.ctos_hand_result != null) {
data.ctos_hand_result = this.ctos_hand_result.toObject();
}
if (this.ctos_tp_result != null) {
data.ctos_tp_result = this.ctos_tp_result.toObject();
}
return data;
}
serialize(): Uint8Array;
......@@ -279,6 +373,14 @@ export namespace ygopro {
writer.writeMessage(6, this.ctos_hs_not_ready, () =>
this.ctos_hs_not_ready.serialize(writer)
);
if (this.has_ctos_hand_result)
writer.writeMessage(7, this.ctos_hand_result, () =>
this.ctos_hand_result.serialize(writer)
);
if (this.has_ctos_tp_result)
writer.writeMessage(8, this.ctos_tp_result, () =>
this.ctos_tp_result.serialize(writer)
);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): YgoCtosMsg {
......@@ -329,6 +431,19 @@ export namespace ygopro {
(message.ctos_hs_not_ready = CtosHsNotReady.deserialize(reader))
);
break;
case 7:
reader.readMessage(
message.ctos_hand_result,
() =>
(message.ctos_hand_result = CtosHandResult.deserialize(reader))
);
break;
case 8:
reader.readMessage(
message.ctos_tp_result,
() => (message.ctos_tp_result = CtosTpResult.deserialize(reader))
);
break;
default:
reader.skipField();
}
......@@ -343,7 +458,7 @@ export namespace ygopro {
}
}
export class YgoStocMsg 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, 8, 9]];
constructor(
data?:
| any[]
......@@ -355,6 +470,9 @@ export namespace ygopro {
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
......@@ -363,6 +481,9 @@ export namespace ygopro {
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
......@@ -371,6 +492,9 @@ export namespace ygopro {
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
......@@ -379,6 +503,9 @@ export namespace ygopro {
stoc_type_change?: StocTypeChange;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
......@@ -387,6 +514,9 @@ export namespace ygopro {
stoc_type_change?: never;
stoc_hs_player_change?: StocHsPlayerChange;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
......@@ -395,6 +525,42 @@ export namespace ygopro {
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: StocHsWatchChange;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
stoc_chat?: never;
stoc_hs_player_enter?: never;
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: StocSelectHand;
stoc_hand_result?: never;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
stoc_chat?: never;
stoc_hs_player_enter?: never;
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: StocHandResult;
stoc_select_tp?: never;
}
| {
stoc_join_game?: never;
stoc_chat?: never;
stoc_hs_player_enter?: never;
stoc_type_change?: never;
stoc_hs_player_change?: never;
stoc_hs_watch_change?: never;
stoc_select_hand?: never;
stoc_hand_result?: never;
stoc_select_tp?: StocSelectTp;
}
))
) {
......@@ -435,6 +601,15 @@ export namespace ygopro {
) {
this.stoc_hs_watch_change = data.stoc_hs_watch_change;
}
if ("stoc_select_hand" in data && data.stoc_select_hand != undefined) {
this.stoc_select_hand = data.stoc_select_hand;
}
if ("stoc_hand_result" in data && data.stoc_hand_result != undefined) {
this.stoc_hand_result = data.stoc_hand_result;
}
if ("stoc_select_tp" in data && data.stoc_select_tp != undefined) {
this.stoc_select_tp = data.stoc_select_tp;
}
}
}
get stoc_join_game() {
......@@ -511,6 +686,45 @@ export namespace ygopro {
get has_stoc_hs_watch_change() {
return pb_1.Message.getField(this, 6) != null;
}
get stoc_select_hand() {
return pb_1.Message.getWrapperField(
this,
StocSelectHand,
7
) as StocSelectHand;
}
set stoc_select_hand(value: StocSelectHand) {
pb_1.Message.setOneofWrapperField(this, 7, this.#one_of_decls[0], value);
}
get has_stoc_select_hand() {
return pb_1.Message.getField(this, 7) != null;
}
get stoc_hand_result() {
return pb_1.Message.getWrapperField(
this,
StocHandResult,
8
) as StocHandResult;
}
set stoc_hand_result(value: StocHandResult) {
pb_1.Message.setOneofWrapperField(this, 8, this.#one_of_decls[0], value);
}
get has_stoc_hand_result() {
return pb_1.Message.getField(this, 8) != null;
}
get stoc_select_tp() {
return pb_1.Message.getWrapperField(
this,
StocSelectTp,
9
) as StocSelectTp;
}
set stoc_select_tp(value: StocSelectTp) {
pb_1.Message.setOneofWrapperField(this, 9, this.#one_of_decls[0], value);
}
get has_stoc_select_tp() {
return pb_1.Message.getField(this, 9) != null;
}
get msg() {
const cases: {
[index: number]:
......@@ -520,7 +734,10 @@ export namespace ygopro {
| "stoc_hs_player_enter"
| "stoc_type_change"
| "stoc_hs_player_change"
| "stoc_hs_watch_change";
| "stoc_hs_watch_change"
| "stoc_select_hand"
| "stoc_hand_result"
| "stoc_select_tp";
} = {
0: "none",
1: "stoc_join_game",
......@@ -529,8 +746,13 @@ export namespace ygopro {
4: "stoc_type_change",
5: "stoc_hs_player_change",
6: "stoc_hs_watch_change",
7: "stoc_select_hand",
8: "stoc_hand_result",
9: "stoc_select_tp",
};
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, 8, 9])
];
}
static fromObject(data: {
stoc_join_game?: ReturnType<typeof StocJoinGame.prototype.toObject>;
......@@ -545,6 +767,9 @@ export namespace ygopro {
stoc_hs_watch_change?: ReturnType<
typeof StocHsWatchChange.prototype.toObject
>;
stoc_select_hand?: ReturnType<typeof StocSelectHand.prototype.toObject>;
stoc_hand_result?: ReturnType<typeof StocHandResult.prototype.toObject>;
stoc_select_tp?: ReturnType<typeof StocSelectTp.prototype.toObject>;
}): YgoStocMsg {
const message = new YgoStocMsg({});
if (data.stoc_join_game != null) {
......@@ -573,6 +798,19 @@ export namespace ygopro {
data.stoc_hs_watch_change
);
}
if (data.stoc_select_hand != null) {
message.stoc_select_hand = StocSelectHand.fromObject(
data.stoc_select_hand
);
}
if (data.stoc_hand_result != null) {
message.stoc_hand_result = StocHandResult.fromObject(
data.stoc_hand_result
);
}
if (data.stoc_select_tp != null) {
message.stoc_select_tp = StocSelectTp.fromObject(data.stoc_select_tp);
}
return message;
}
toObject() {
......@@ -589,6 +827,9 @@ export namespace ygopro {
stoc_hs_watch_change?: ReturnType<
typeof StocHsWatchChange.prototype.toObject
>;
stoc_select_hand?: ReturnType<typeof StocSelectHand.prototype.toObject>;
stoc_hand_result?: ReturnType<typeof StocHandResult.prototype.toObject>;
stoc_select_tp?: ReturnType<typeof StocSelectTp.prototype.toObject>;
} = {};
if (this.stoc_join_game != null) {
data.stoc_join_game = this.stoc_join_game.toObject();
......@@ -608,6 +849,15 @@ export namespace ygopro {
if (this.stoc_hs_watch_change != null) {
data.stoc_hs_watch_change = this.stoc_hs_watch_change.toObject();
}
if (this.stoc_select_hand != null) {
data.stoc_select_hand = this.stoc_select_hand.toObject();
}
if (this.stoc_hand_result != null) {
data.stoc_hand_result = this.stoc_hand_result.toObject();
}
if (this.stoc_select_tp != null) {
data.stoc_select_tp = this.stoc_select_tp.toObject();
}
return data;
}
serialize(): Uint8Array;
......@@ -638,6 +888,18 @@ export namespace ygopro {
writer.writeMessage(6, this.stoc_hs_watch_change, () =>
this.stoc_hs_watch_change.serialize(writer)
);
if (this.has_stoc_select_hand)
writer.writeMessage(7, this.stoc_select_hand, () =>
this.stoc_select_hand.serialize(writer)
);
if (this.has_stoc_hand_result)
writer.writeMessage(8, this.stoc_hand_result, () =>
this.stoc_hand_result.serialize(writer)
);
if (this.has_stoc_select_tp)
writer.writeMessage(9, this.stoc_select_tp, () =>
this.stoc_select_tp.serialize(writer)
);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): YgoStocMsg {
......@@ -692,6 +954,26 @@ export namespace ygopro {
StocHsWatchChange.deserialize(reader))
);
break;
case 7:
reader.readMessage(
message.stoc_select_hand,
() =>
(message.stoc_select_hand = StocSelectHand.deserialize(reader))
);
break;
case 8:
reader.readMessage(
message.stoc_hand_result,
() =>
(message.stoc_hand_result = StocHandResult.deserialize(reader))
);
break;
case 9:
reader.readMessage(
message.stoc_select_tp,
() => (message.stoc_select_tp = StocSelectTp.deserialize(reader))
);
break;
default:
reader.skipField();
}
......@@ -1184,6 +1466,177 @@ export namespace ygopro {
return CtosHsStart.deserialize(bytes);
}
}
export class CtosHandResult extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
hand?: HandType;
}
) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
if ("hand" in data && data.hand != undefined) {
this.hand = data.hand;
}
}
}
get hand() {
return pb_1.Message.getFieldWithDefault(
this,
1,
HandType.UNKNOWN
) as HandType;
}
set hand(value: HandType) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: { hand?: HandType }): CtosHandResult {
const message = new CtosHandResult({});
if (data.hand != null) {
message.hand = data.hand;
}
return message;
}
toObject() {
const data: {
hand?: HandType;
} = {};
if (this.hand != null) {
data.hand = this.hand;
}
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.hand != HandType.UNKNOWN) writer.writeEnum(1, this.hand);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CtosHandResult {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new CtosHandResult();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.hand = reader.readEnum();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CtosHandResult {
return CtosHandResult.deserialize(bytes);
}
}
export class CtosTpResult extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
tp?: CtosTpResult.TpType;
}
) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
if ("tp" in data && data.tp != undefined) {
this.tp = data.tp;
}
}
}
get tp() {
return pb_1.Message.getFieldWithDefault(
this,
1,
CtosTpResult.TpType.UNKNOWN
) as CtosTpResult.TpType;
}
set tp(value: CtosTpResult.TpType) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: { tp?: CtosTpResult.TpType }): CtosTpResult {
const message = new CtosTpResult({});
if (data.tp != null) {
message.tp = data.tp;
}
return message;
}
toObject() {
const data: {
tp?: CtosTpResult.TpType;
} = {};
if (this.tp != null) {
data.tp = this.tp;
}
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.tp != CtosTpResult.TpType.UNKNOWN) writer.writeEnum(1, this.tp);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CtosTpResult {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new CtosTpResult();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.tp = reader.readEnum();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CtosTpResult {
return CtosTpResult.deserialize(bytes);
}
}
export namespace CtosTpResult {
export enum TpType {
UNKNOWN = 0,
FIRST = 1,
SECOND = 2,
}
}
export class StocJoinGame extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
......@@ -2006,4 +2459,216 @@ export namespace ygopro {
return StocHsWatchChange.deserialize(bytes);
}
}
export class StocSelectHand extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
}
}
static fromObject(data: {}): StocSelectHand {
const message = new StocSelectHand({});
return message;
}
toObject() {
const data: {} = {};
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 (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StocSelectHand {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new StocSelectHand();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): StocSelectHand {
return StocSelectHand.deserialize(bytes);
}
}
export class StocHandResult extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
meResult?: HandType;
opResult?: HandType;
}
) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
if ("meResult" in data && data.meResult != undefined) {
this.meResult = data.meResult;
}
if ("opResult" in data && data.opResult != undefined) {
this.opResult = data.opResult;
}
}
}
get meResult() {
return pb_1.Message.getFieldWithDefault(
this,
1,
HandType.UNKNOWN
) as HandType;
}
set meResult(value: HandType) {
pb_1.Message.setField(this, 1, value);
}
get opResult() {
return pb_1.Message.getFieldWithDefault(
this,
2,
HandType.UNKNOWN
) as HandType;
}
set opResult(value: HandType) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
meResult?: HandType;
opResult?: HandType;
}): StocHandResult {
const message = new StocHandResult({});
if (data.meResult != null) {
message.meResult = data.meResult;
}
if (data.opResult != null) {
message.opResult = data.opResult;
}
return message;
}
toObject() {
const data: {
meResult?: HandType;
opResult?: HandType;
} = {};
if (this.meResult != null) {
data.meResult = this.meResult;
}
if (this.opResult != null) {
data.opResult = this.opResult;
}
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.meResult != HandType.UNKNOWN) writer.writeEnum(1, this.meResult);
if (this.opResult != HandType.UNKNOWN) writer.writeEnum(2, this.opResult);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StocHandResult {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new StocHandResult();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.meResult = reader.readEnum();
break;
case 2:
message.opResult = reader.readEnum();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): StocHandResult {
return StocHandResult.deserialize(bytes);
}
}
export class StocSelectTp extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(
this,
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == "object") {
}
}
static fromObject(data: {}): StocSelectTp {
const message = new StocSelectTp({});
return message;
}
toObject() {
const data: {} = {};
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 (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StocSelectTp {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new StocSelectTp();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): StocSelectTp {
return StocSelectTp.deserialize(bytes);
}
}
}
......@@ -7,6 +7,9 @@ import {
STOC_HS_WATCH_CHANGE,
STOC_JOIN_GAME,
STOC_TYPE_CHANGE,
STOC_SELECT_HAND,
STOC_SELECT_TP,
STOC_HAND_RESULT,
} from "./protoDecl";
import StocChat from "./stoc/stocChat";
import StocJoinGame from "./stoc/stocJoinGame";
......@@ -14,6 +17,8 @@ import StocHsPlayerEnter from "./stoc/stocHsPlayerEnter";
import StocHsPlayerChange from "./stoc/stocHsPlayerChange";
import StocHsWatchChange from "./stoc/stocHsWatchChange";
import StocTypeChange from "./stoc/stocTypeChange";
import StocSelectHand from "./stoc/stocSelectHand";
import StocSelectTp from "./stoc/stocSelectTp";
/*
* 将[`ygoProPacket`]对象转换成[`ygopro.YgoStocMsg`]对象
......@@ -55,6 +60,20 @@ export function adaptStoc(packet: ygoProPacket): ygopro.YgoStocMsg {
break;
}
case STOC_SELECT_HAND: {
pb = new StocSelectHand(packet).upcast();
break;
}
case STOC_SELECT_TP: {
pb = new StocSelectTp(packet).upcast();
break;
}
case STOC_HAND_RESULT: {
// TODO
break;
}
default: {
break;
}
......
import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet";
import { CTOS_HAND_RESULT } from "../protoDecl";
/*
* CTOS HandResult
*
* @param res: unsigned char - 玩家的猜拳选择
*
* @usage - 告知服务端当前玩家的猜拳选择
* */
export default class CtosHandResultPacket extends ygoProPacket {
constructor(pb: ygopro.YgoCtosMsg) {
const handResult = pb.ctos_hand_result;
const hand = handResult.hand;
const exData = new Uint8Array(1);
const dataView = new DataView(exData.buffer);
switch (hand) {
case ygopro.HandType.SCISSORS: {
dataView.setUint8(0, 1);
break;
}
case ygopro.HandType.ROCK: {
dataView.setUint8(0, 2);
break;
}
case ygopro.HandType.PAPER: {
dataView.setUint8(0, 3);
break;
}
default: {
console.log("Unknown HandResult type" + hand);
}
}
super(exData.length + 1, CTOS_HAND_RESULT, exData);
}
}
import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket } from "../packet";
import { CTOS_TP_RESULT } from "../protoDecl";
/*
* CTOS CTOS_TP_RESULT
*
* @param res: unsigned char - 玩家的先后攻选择
*
* @usage - 告知服务端当前玩家的先后攻选择
*
* */
export default class CtosTpResultPacket extends ygoProPacket {
constructor(pb: ygopro.YgoCtosMsg) {
const tpResult = pb.ctos_tp_result;
const tp = tpResult.tp;
const exData = new Uint8Array(1);
const dataView = new DataView(exData.buffer);
switch (tp) {
case ygopro.CtosTpResult.TpType.FIRST: {
dataView.setUint8(0, 1);
break;
}
case ygopro.CtosTpResult.TpType.SECOND: {
dataView.setUint8(0, 0);
break;
}
default: {
console.log("Unknown HandResult type" + tp);
}
}
super(exData.length + 1, CTOS_TP_RESULT, exData);
}
}
......@@ -7,6 +7,8 @@ export const CTOS_JOIN_GAME = 18;
export const CTOS_UPDATE_DECK = 2;
export const CTOS_HS_READY = 34;
export const CTOS_HS_START = 37;
export const CTOS_HAND_RESULT = 3;
export const CTOS_TP_RESULT = 4;
export const STOC_JOIN_GAME = 18;
export const STOC_CHAT = 25;
......@@ -14,3 +16,6 @@ export const STOC_HS_PLAYER_ENTER = 32;
export const STOC_HS_PLAYER_CHANGE = 33;
export const STOC_HS_WATCH_CHANGE = 34;
export const STOC_TYPE_CHANGE = 19;
export const STOC_SELECT_HAND = 3;
export const STOC_SELECT_TP = 4;
export const STOC_HAND_RESULT = 5;
import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet";
/*
* STOC SelectHand
*
* @usage - 通知客户端/前端提醒用户进行猜拳选择
* */
export default class selectHand implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
return new ygopro.YgoStocMsg({
stoc_select_hand: new ygopro.StocSelectHand({}),
});
}
}
import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, StocAdapter } from "../packet";
/*
* STOC SelectTp
*
* @usage - 通知客户端/前端提醒用户进行选先后攻
* */
export default class selectTp implements StocAdapter {
packet: ygoProPacket;
constructor(packet: ygoProPacket) {
this.packet = packet;
}
upcast(): ygopro.YgoStocMsg {
return new ygopro.YgoStocMsg({
stoc_select_tp: new ygopro.StocSelectTp({}),
});
}
}
......@@ -10,6 +10,8 @@ import JoinGameAdapter from "./ocgAdapter/ctos/ctosJoinGame";
import UpdateDeckAdapter from "./ocgAdapter/ctos/ctosUpdateDeck";
import HsReadyAdapter from "./ocgAdapter/ctos/ctosHsReady";
import HsStartAdapter from "./ocgAdapter/ctos/ctosHsStart";
import HandResult from "./ocgAdapter/ctos/ctosHandResult";
import TpResult from "./ocgAdapter/ctos/ctosTpResult";
export function sendUpdateDeck(deck: IDeck) {
const updateDeck = new ygopro.YgoCtosMsg({
......@@ -67,3 +69,41 @@ export function sendJoinGame(ws: WebSocket, version: number, passWd: string) {
ws.send(packet.serialize());
}
export function sendHandResult(result: string) {
let hand = ygopro.HandType.UNKNOWN;
if (result === "scissors") {
hand = ygopro.HandType.SCISSORS;
} else if (result === "rock") {
hand = ygopro.HandType.ROCK;
} else if (result === "paper") {
hand = ygopro.HandType.PAPER;
}
const handResult = new ygopro.YgoCtosMsg({
ctos_hand_result: new ygopro.CtosHandResult({
hand,
}),
});
const payload = new HandResult(handResult).serialize();
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
export function sendTpResult(isFirst: boolean) {
let tp = ygopro.CtosTpResult.TpType.UNKNOWN;
if (isFirst) {
tp = ygopro.CtosTpResult.TpType.FIRST;
} else {
tp = ygopro.CtosTpResult.TpType.SECOND;
}
const tpResult = new ygopro.YgoCtosMsg({
ctos_tp_result: new ygopro.CtosTpResult({
tp,
}),
});
const payload = new TpResult(tpResult).serialize();
socketMiddleWare({ cmd: socketCmd.SEND, payload });
}
.container {
display: flex;
margin: auto;
padding: 0;
}
.item {
text-align: center;
flex: 1;
}
......@@ -21,7 +21,7 @@
* */
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./ui/App";
import Neos from "./ui/Neos";
import { BrowserRouter } from "react-router-dom";
import { Provider } from "react-redux";
import { store } from "./store";
......@@ -33,7 +33,7 @@ root.render(
<React.StrictMode>
<BrowserRouter>
<Provider store={store}>
<App />
<Neos />
</Provider>
</BrowserRouter>
</React.StrictMode>
......
/*
* 猜拳页面的状态更新逻辑
*
* */
import { createSlice } from "@reduxjs/toolkit";
import { RootState } from "../store";
export interface moraState {
selectHandAble: boolean;
selectTpAble: boolean;
}
const initialState: moraState = {
selectHandAble: false,
selectTpAble: false,
};
const moraSlice = createSlice({
name: "mora",
initialState,
reducers: {
selectHandAble: (state) => {
state.selectHandAble = true;
},
unSelectHandAble: (state) => {
state.selectHandAble = false;
},
selectTpAble: (state) => {
state.selectTpAble = true;
},
unSelectTpAble: (state) => {
state.selectTpAble = false;
},
},
});
export const {
selectHandAble,
unSelectHandAble,
selectTpAble,
unSelectTpAble,
} = moraSlice.actions;
export const selectHandSelectAble = (state: RootState) =>
state.mora.selectHandAble;
export const selectTpSelectAble = (state: RootState) => state.mora.selectTpAble;
export default moraSlice.reducer;
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { store } from "../../store";
import { selectHandAble } from "../../reducers/moraSlice";
export default function handleSelectHand(_: ygopro.YgoStocMsg) {
const dispatch = store.dispatch;
dispatch(selectHandAble());
}
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { store } from "../../store";
import { selectTpAble } from "../../reducers/moraSlice";
export default function handleSelectTp(_: ygopro.YgoStocMsg) {
const dispatch = store.dispatch;
dispatch(selectTpAble());
}
......@@ -10,6 +10,8 @@ import handleChat from "./room/chat";
import handleHsWatchChange from "./room/hsWatchChange";
import { ygoProPacket } from "../api/ocgcore/ocgAdapter/packet";
import { adaptStoc } from "../api/ocgcore/ocgAdapter/adapter";
import handleSelectHand from "./mora/selectHand";
import handleSelectTp from "./mora/selectTp";
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
......@@ -51,6 +53,22 @@ export default function handleSocketMessage(e: MessageEvent) {
break;
}
case "stoc_select_hand": {
handleSelectHand(pb);
break;
}
case "stoc_hand_result": {
// TODO
console.log("TODO: handle STOC HandResult.");
break;
}
case "stoc_select_tp": {
handleSelectTp(pb);
break;
}
default: {
break;
}
......
......@@ -5,12 +5,14 @@ import { configureStore } from "@reduxjs/toolkit";
import joinedReducer from "./reducers/joinSlice";
import chatReducer from "./reducers/chatSlice";
import playerReducer from "./reducers/playerSlice";
import moraReducer from "./reducers/moraSlice";
export const store = configureStore({
reducer: {
join: joinedReducer,
chat: chatReducer,
player: playerReducer,
mora: moraReducer,
},
});
......
/*
* 猜拳页面
*
* */
import React from "react";
import { sendHandResult, sendTpResult } from "../api/ocgcore/ocgHelper";
import "../css/Mora.css";
import { useAppSelector } from "../hook";
import {
selectHandSelectAble,
unSelectHandAble,
selectTpSelectAble,
unSelectTpAble,
} from "../reducers/moraSlice";
import { store } from "../store";
// TODO: 应该展示对手卡组信息和聊天信息
export default function Mora() {
const dispatch = store.dispatch;
const selectHandAble = useAppSelector(selectHandSelectAble);
const selectTpAble = useAppSelector(selectTpSelectAble);
const handleSelectScissors = () => {
sendHandResult("scissors");
dispatch(unSelectHandAble());
};
const handleSelectRock = () => {
sendHandResult("rock");
dispatch(unSelectHandAble());
};
const handleSelectPaper = () => {
sendHandResult("paper");
dispatch(unSelectHandAble());
};
const handleSelectFirst = () => {
sendTpResult(true);
dispatch(unSelectTpAble());
};
const handleSelectSecond = () => {
sendTpResult(false);
dispatch(unSelectTpAble());
};
return (
<div className="container">
<div className="item">
<button disabled={!selectHandAble} onClick={handleSelectScissors}>
scissors
</button>
<button disabled={!selectHandAble} onClick={handleSelectRock}>
rock
</button>
<button disabled={!selectHandAble} onClick={handleSelectPaper}>
paper
</button>
</div>
<div className="item">
<button disabled={!selectTpAble} onClick={handleSelectFirst}>
first
</button>
<button disabled={!selectTpAble} onClick={handleSelectSecond}>
second
</button>
</div>
</div>
);
}
......@@ -4,16 +4,17 @@ import WaitRoom from "./WaitRoom";
import ThreeJs from "./ThreeJs";
import BabylonJs from "./BabylonJs";
import { Routes, Route } from "react-router-dom";
import Mora from "./Mora";
function App() {
export default function () {
// FIXME: 这里Mora路由应该由每个房间指定一个路径
return (
<Routes>
<Route path="/" element={<JoinRoom />} />
<Route path="/:player/:passWd/:ip" element={<WaitRoom />} />
<Route path="/mora" element={<Mora />} />
<Route path="/three" element={<ThreeJs />} />
<Route path="/babylon" element={<BabylonJs />} />
</Routes>
);
}
export default App;
......@@ -3,7 +3,7 @@
*
* */
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import { fetchDeck } from "../api/Card";
import "../css/WaitRoom.css";
import { useAppSelector } from "../hook";
......@@ -88,17 +88,13 @@ export default function WaitRoom() {
<p>
<button
disabled={
!(
isHost &&
player0.state != undefined &&
player0.state === READY_STATE &&
player1.state != undefined &&
player1.state === READY_STATE
)
!isHost ||
player0.state != READY_STATE ||
player1.state != READY_STATE
}
onClick={handleChoseStart}
>
start
<Link to={{ pathname: `/mora` }}>start</Link>
</button>
</p>
</div>
......
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