Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Biluo Shen
Neos
Commits
e831f456
Commit
e831f456
authored
Mar 25, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/counter' into 'main'
Feat/counter See merge request
mycard/Neos!154
parents
f586fbb6
ec0e0263
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
467 additions
and
6 deletions
+467
-6
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+278
-3
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+2
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/addCounter.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/addCounter.ts
+24
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
+12
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/removeCounter.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/removeCounter.ts
+24
-0
src/api/strings.ts
src/api/strings.ts
+1
-1
src/reducers/duel/cemeretySlice.ts
src/reducers/duel/cemeretySlice.ts
+1
-0
src/reducers/duel/deckSlice.ts
src/reducers/duel/deckSlice.ts
+1
-0
src/reducers/duel/exclusionSlice.ts
src/reducers/duel/exclusionSlice.ts
+1
-0
src/reducers/duel/extraDeckSlice.ts
src/reducers/duel/extraDeckSlice.ts
+2
-0
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+3
-0
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+3
-0
src/reducers/duel/magicSlice.ts
src/reducers/duel/magicSlice.ts
+6
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+7
-1
src/reducers/duel/modal/cardModalSlice.ts
src/reducers/duel/modal/cardModalSlice.ts
+10
-0
src/reducers/duel/modal/mod.ts
src/reducers/duel/modal/mod.ts
+1
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+48
-0
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+6
-0
src/service/duel/updateCounter.ts
src/service/duel/updateCounter.ts
+8
-0
src/ui/Duel/cardModal.tsx
src/ui/Duel/cardModal.tsx
+26
-0
src/ui/Duel/fixedSlot.tsx
src/ui/Duel/fixedSlot.tsx
+2
-0
No files found.
neos-protobuf
@
76135099
Subproject commit
12d819b3b0c69b334f475b01fdbf2f7fc6f5e2d9
Subproject commit
76135099fbeb0a69b7f8562bd755975593794e4b
src/api/ocgcore/idl/ocgcore.ts
View file @
e831f456
...
...
@@ -5446,7 +5446,7 @@ export namespace ygopro {
#one_of_decls: number[][] = [
[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21
,
22
,
23
,
24
,
25
,
26
,
21, 22, 23, 24, 25, 26,
27,
],
];
constructor(
...
...
@@ -5480,6 +5480,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5508,6 +5509,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5536,6 +5538,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5564,6 +5567,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5592,6 +5596,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5620,6 +5625,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5648,6 +5654,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5676,6 +5683,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5704,6 +5712,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5732,6 +5741,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5760,6 +5770,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5788,6 +5799,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5816,6 +5828,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5844,6 +5857,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5872,6 +5886,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5900,6 +5915,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5928,6 +5944,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5956,6 +5973,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -5984,6 +6002,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6012,6 +6031,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6040,6 +6060,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6068,6 +6089,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6096,6 +6118,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6124,6 +6147,7 @@ export namespace ygopro {
reload_field?: StocGameMessage.MsgReloadField;
select_sum?: never;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6152,6 +6176,7 @@ export namespace ygopro {
reload_field?: never;
select_sum?: StocGameMessage.MsgSelectSum;
select_tribute?: never;
update_counter?: never;
}
| {
start?: never;
...
...
@@ -6180,6 +6205,36 @@ export namespace ygopro {
reload_field?: never;
select_sum?: never;
select_tribute?: StocGameMessage.MsgSelectTribute;
update_counter?: never;
}
| {
start?: never;
draw?: never;
new_turn?: never;
new_phase?: never;
hint?: never;
select_idle_cmd?: never;
select_place?: never;
move?: never;
select_card?: never;
select_chain?: never;
select_effect_yn?: never;
select_position?: never;
select_option?: never;
shuffle_hand?: never;
select_battle_cmd?: never;
pos_change?: never;
select_unselect_card?: never;
select_yes_no?: never;
update_hp?: never;
win?: never;
wait?: never;
unimplemented?: never;
update_data?: never;
reload_field?: never;
select_sum?: never;
select_tribute?: never;
update_counter?: StocGameMessage.MsgUpdateCounter;
}
))
) {
...
...
@@ -6277,6 +6332,9 @@ export namespace ygopro {
if ("select_tribute" in data && data.select_tribute != undefined) {
this.select_tribute = data.select_tribute;
}
if ("update_counter" in data && data.update_counter != undefined) {
this.update_counter = data.update_counter;
}
}
}
get start() {
...
...
@@ -6617,6 +6675,19 @@ export namespace ygopro {
get has_select_tribute() {
return pb_1.Message.getField(this, 26) != null;
}
get update_counter() {
return pb_1.Message.getWrapperField(
this,
StocGameMessage.MsgUpdateCounter,
27
) as StocGameMessage.MsgUpdateCounter;
}
set update_counter(value: StocGameMessage.MsgUpdateCounter) {
pb_1.Message.setOneofWrapperField(this, 27, this.#one_of_decls[0], value);
}
get has_update_counter() {
return pb_1.Message.getField(this, 27) != null;
}
get gameMsg() {
const cases: {
[index: number]:
...
...
@@ -6646,7 +6717,8 @@ export namespace ygopro {
| "update_data"
| "reload_field"
| "select_sum"
|
"
select_tribute
"
;
| "select_tribute"
| "update_counter";
} = {
0: "none",
1: "start",
...
...
@@ -6675,13 +6747,14 @@ export namespace ygopro {
24: "reload_field",
25: "select_sum",
26: "select_tribute",
27: "update_counter",
};
return cases[
pb_1.Message.computeOneofCase(
this,
[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
20, 21, 22, 23, 24, 25, 26,
27,
]
)
];
...
...
@@ -6753,6 +6826,9 @@ export namespace ygopro {
select_tribute?: ReturnType<
typeof StocGameMessage.MsgSelectTribute.prototype.toObject
>;
update_counter?: ReturnType<
typeof StocGameMessage.MsgUpdateCounter.prototype.toObject
>;
}): StocGameMessage {
const message = new StocGameMessage({});
if (data.start != null) {
...
...
@@ -6871,6 +6947,11 @@ export namespace ygopro {
data.select_tribute
);
}
if (data.update_counter != null) {
message.update_counter = StocGameMessage.MsgUpdateCounter.fromObject(
data.update_counter
);
}
return message;
}
toObject() {
...
...
@@ -6941,6 +7022,9 @@ export namespace ygopro {
select_tribute?: ReturnType<
typeof StocGameMessage.MsgSelectTribute.prototype.toObject
>;
update_counter?: ReturnType<
typeof StocGameMessage.MsgUpdateCounter.prototype.toObject
>;
} = {};
if (this.start != null) {
data.start = this.start.toObject();
...
...
@@ -7020,6 +7104,9 @@ export namespace ygopro {
if (this.select_tribute != null) {
data.select_tribute = this.select_tribute.toObject();
}
if (this.update_counter != null) {
data.update_counter = this.update_counter.toObject();
}
return data;
}
serialize(): Uint8Array;
...
...
@@ -7118,6 +7205,10 @@ export namespace ygopro {
writer.writeMessage(26, this.select_tribute, () =>
this.select_tribute.serialize(writer)
);
if (this.has_update_counter)
writer.writeMessage(27, this.update_counter, () =>
this.update_counter.serialize(writer)
);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StocGameMessage {
...
...
@@ -7326,6 +7417,14 @@ export namespace ygopro {
StocGameMessage.MsgSelectTribute.deserialize(reader))
);
break;
case 27:
reader.readMessage(
message.update_counter,
() =>
(message.update_counter =
StocGameMessage.MsgUpdateCounter.deserialize(reader))
);
break;
default:
reader.skipField();
}
...
...
@@ -13612,6 +13711,182 @@ export namespace ygopro {
}
}
}
export class MsgUpdateCounter extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
counter_type?: number;
location?: CardLocation;
action_type?: StocGameMessage.MsgUpdateCounter.ActionType;
count?: 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 ("counter_type" in data && data.counter_type != undefined) {
this.counter_type = data.counter_type;
}
if ("location" in data && data.location != undefined) {
this.location = data.location;
}
if ("action_type" in data && data.action_type != undefined) {
this.action_type = data.action_type;
}
if ("count" in data && data.count != undefined) {
this.count = data.count;
}
}
}
get counter_type() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set counter_type(value: number) {
pb_1.Message.setField(this, 1, value);
}
get location() {
return pb_1.Message.getWrapperField(
this,
CardLocation,
2
) as CardLocation;
}
set location(value: CardLocation) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_location() {
return pb_1.Message.getField(this, 2) != null;
}
get action_type() {
return pb_1.Message.getFieldWithDefault(
this,
3,
StocGameMessage.MsgUpdateCounter.ActionType.UNKNOWN
) as StocGameMessage.MsgUpdateCounter.ActionType;
}
set action_type(value: StocGameMessage.MsgUpdateCounter.ActionType) {
pb_1.Message.setField(this, 3, value);
}
get count() {
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
}
set count(value: number) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: {
counter_type?: number;
location?: ReturnType<typeof CardLocation.prototype.toObject>;
action_type?: StocGameMessage.MsgUpdateCounter.ActionType;
count?: number;
}): MsgUpdateCounter {
const message = new MsgUpdateCounter({});
if (data.counter_type != null) {
message.counter_type = data.counter_type;
}
if (data.location != null) {
message.location = CardLocation.fromObject(data.location);
}
if (data.action_type != null) {
message.action_type = data.action_type;
}
if (data.count != null) {
message.count = data.count;
}
return message;
}
toObject() {
const data: {
counter_type?: number;
location?: ReturnType<typeof CardLocation.prototype.toObject>;
action_type?: StocGameMessage.MsgUpdateCounter.ActionType;
count?: number;
} = {};
if (this.counter_type != null) {
data.counter_type = this.counter_type;
}
if (this.location != null) {
data.location = this.location.toObject();
}
if (this.action_type != null) {
data.action_type = this.action_type;
}
if (this.count != null) {
data.count = this.count;
}
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.counter_type != 0) writer.writeInt32(1, this.counter_type);
if (this.has_location)
writer.writeMessage(2, this.location, () =>
this.location.serialize(writer)
);
if (
this.action_type !=
StocGameMessage.MsgUpdateCounter.ActionType.UNKNOWN
)
writer.writeEnum(3, this.action_type);
if (this.count != 0) writer.writeInt32(4, this.count);
if (!w) return writer.getResultBuffer();
}
static deserialize(
bytes: Uint8Array | pb_1.BinaryReader
): MsgUpdateCounter {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new MsgUpdateCounter();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.counter_type = reader.readInt32();
break;
case 2:
reader.readMessage(
message.location,
() => (message.location = CardLocation.deserialize(reader))
);
break;
case 3:
message.action_type = reader.readEnum();
break;
case 4:
message.count = reader.readInt32();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgUpdateCounter {
return MsgUpdateCounter.deserialize(bytes);
}
}
export namespace MsgUpdateCounter {
export enum ActionType {
UNKNOWN = 0,
ADD = 1,
REMOVE = 2,
}
}
export class MsgReloadField extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
...
...
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
e831f456
...
...
@@ -52,3 +52,5 @@ export const MSG_WAITING = 3;
export
const
MSG_UPDATE_DATA
=
6
;
export
const
MSG_RELOAD_FIELD
=
162
;
export
const
MSG_SELECT_SUM
=
23
;
export
const
MSG_ADD_COUNTER
=
101
;
export
const
MSG_REMOVE_COUNTER
=
102
;
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/addCounter.ts
0 → 100644
View file @
e831f456
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReaderExt
}
from
"
../../bufferIO
"
;
import
MsgUpdateCounter
=
ygopro
.
StocGameMessage
.
MsgUpdateCounter
;
/*
* Msg Add Counter
* @param - TODO
*
* @usage - TODO
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReaderExt
(
data
);
const
counterType
=
reader
.
inner
.
readUint16
();
const
location
=
reader
.
readCardShortLocation
();
const
count
=
reader
.
inner
.
readUint16
();
return
new
MsgUpdateCounter
({
counter_type
:
counterType
,
location
,
action_type
:
MsgUpdateCounter
.
ActionType
.
ADD
,
count
,
});
};
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
e831f456
...
...
@@ -28,6 +28,8 @@ import MsgWin from "./win";
import
MsgUpdateDataAdapter
from
"
./updateData
"
;
import
MsgReloadFieldAdapter
from
"
./reloadField
"
;
import
MsgSelectSum
from
"
./selectSum
"
;
import
MsgAddCounter
from
"
./addCounter
"
;
import
MsgRemoveCounter
from
"
./removeCounter
"
;
import
PENETRATE
from
"
./penetrate
"
;
/*
...
...
@@ -166,6 +168,16 @@ export default class GameMsgAdapter implements StocAdapter {
break
;
}
case
GAME_MSG
.
MSG_ADD_COUNTER
:
{
gameMsg
.
update_counter
=
MsgAddCounter
(
gameData
);
break
;
}
case
GAME_MSG
.
MSG_REMOVE_COUNTER
:
{
gameMsg
.
update_counter
=
MsgRemoveCounter
(
gameData
);
break
;
}
default
:
{
gameMsg
.
unimplemented
=
new
ygopro
.
StocGameMessage
.
MsgUnimplemented
({
command
:
func
,
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/removeCounter.ts
0 → 100644
View file @
e831f456
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReaderExt
}
from
"
../../bufferIO
"
;
import
MsgUpdateCounter
=
ygopro
.
StocGameMessage
.
MsgUpdateCounter
;
/*
* Msg Remove Counter
* @param - TODO
*
* @usage - TODO
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReaderExt
(
data
);
const
counterType
=
reader
.
inner
.
readUint16
();
const
location
=
reader
.
readCardShortLocation
();
const
count
=
reader
.
inner
.
readUint16
();
return
new
MsgUpdateCounter
({
counter_type
:
counterType
,
location
,
action_type
:
MsgUpdateCounter
.
ActionType
.
REMOVE
,
count
,
});
};
src/api/strings.ts
View file @
e831f456
...
...
@@ -16,7 +16,7 @@ export async function initStrings() {
}
}
export
function
fetchStrings
(
region
:
string
,
id
:
number
):
string
{
export
function
fetchStrings
(
region
:
string
,
id
:
string
|
number
):
string
{
return
localStorage
.
getItem
(
`
${
region
}
_
${
id
}
`
)
||
""
;
}
...
...
src/reducers/duel/cemeretySlice.ts
View file @
e831f456
...
...
@@ -51,6 +51,7 @@ export const cemeteryCase = (builder: ActionReducerMapBuilder<DuelState>) => {
sequence
,
},
idleInteractivities
:
[],
counters
:
{},
};
if
(
judgeSelf
(
controler
,
state
))
{
extendState
(
state
.
meCemetery
,
newCemetery
);
...
...
src/reducers/duel/deckSlice.ts
View file @
e831f456
...
...
@@ -24,6 +24,7 @@ export const initDeckImpl: CaseReducer<
location
:
ygopro
.
CardZone
.
DECK
,
},
idleInteractivities
:
[],
counters
:
{},
});
}
...
...
src/reducers/duel/exclusionSlice.ts
View file @
e831f456
...
...
@@ -53,6 +53,7 @@ export const exclusionCase = (builder: ActionReducerMapBuilder<DuelState>) => {
sequence
,
},
idleInteractivities
:
[],
counters
:
{},
};
if
(
judgeSelf
(
controler
,
state
))
{
extendState
(
state
.
meExclusion
,
newExclusion
);
...
...
src/reducers/duel/extraDeckSlice.ts
View file @
e831f456
...
...
@@ -40,6 +40,7 @@ export const extraDeckCase = (builder: ActionReducerMapBuilder<DuelState>) => {
location
:
ygopro
.
CardZone
.
EXTRA
,
},
idleInteractivities
:
[],
counters
:
{},
};
});
state
.
meExtraDeck
=
{
inner
:
cards
};
...
...
@@ -64,6 +65,7 @@ export const extraDeckCase = (builder: ActionReducerMapBuilder<DuelState>) => {
sequence
,
},
idleInteractivities
:
[],
counters
:
{},
};
const
extraDeck
=
judgeSelf
(
controler
,
state
)
?
state
.
meExtraDeck
...
...
src/reducers/duel/generic.ts
View file @
e831f456
...
...
@@ -34,6 +34,7 @@ export interface CardState {
sequence
:
number
;
}
>
;
// 选择位置状态下的互动信息
overlay_materials
?:
CardMeta
[];
// 超量素材
counters
:
{
[
type
:
number
]:
number
};
// 指示器
reload
?:
boolean
;
// 这个字段会在收到MSG_RELOAD_FIELD的时候设置成true,在收到MSG_UPDATE_DATE的时候设置成false
}
...
...
@@ -328,6 +329,7 @@ export function updateCardData<T extends DuelFieldState>(
if
(
payload
.
defense
!==
undefined
&&
payload
.
defense
>=
0
)
{
occupant
.
data
.
def
=
payload
.
defense
;
}
// TODO: counters
}
if
(
target
?.
reload
)
{
target
.
reload
=
false
;
...
...
@@ -351,6 +353,7 @@ export function reloadFieldMeta<T extends DuelFieldState>(
position
:
action
.
position
,
},
idleInteractivities
:
[],
counters
:
{},
reload
:
true
,
};
});
...
...
src/reducers/duel/handsSlice.ts
View file @
e831f456
...
...
@@ -93,6 +93,7 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
controler
:
player
,
location
:
ygopro
.
CardZone
.
HAND
,
},
counters
:
{},
idleInteractivities
:
[],
};
});
...
...
@@ -130,6 +131,7 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
occupant
:
{
id
:
code
,
data
:
{},
text
:
{}
},
location
:
{
controler
},
idleInteractivities
:
[],
counters
:
{},
});
});
builder
.
addCase
(
insertHandMeta
.
fulfilled
,
(
state
,
action
)
=>
{
...
...
@@ -154,6 +156,7 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
location
:
ygopro
.
CardZone
.
HAND
,
},
idleInteractivities
:
[],
counters
:
{},
};
});
...
...
src/reducers/duel/magicSlice.ts
View file @
e831f456
...
...
@@ -37,6 +37,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
0
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -45,6 +46,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
1
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -53,6 +55,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
2
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -61,6 +64,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
3
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -69,6 +73,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
4
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
// 场地区
...
...
@@ -78,6 +83,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
5
,
},
idleInteractivities
:
[],
counters
:
{},
},
],
};
...
...
src/reducers/duel/mod.ts
View file @
e831f456
...
...
@@ -61,6 +61,7 @@ import {
resetCheckCardModalV3Impl
,
setCheckCardModalV3SelectedImpl
,
checkCardModalV3Case
,
setCardModalCountersImpl
,
}
from
"
./modal/mod
"
;
import
{
MonsterState
,
...
...
@@ -72,6 +73,7 @@ import {
removeMonsterImpl
,
setMonsterPositionImpl
,
removeOverlayImpl
,
updateMonsterCountersImpl
,
monsterCase
,
}
from
"
./monstersSlice
"
;
import
{
...
...
@@ -162,7 +164,7 @@ export interface DuelState {
const
initialState
:
DuelState
=
{
modalState
:
{
cardModal
:
{
isOpen
:
false
,
interactivies
:
[]
},
cardModal
:
{
isOpen
:
false
,
interactivies
:
[]
,
counters
:
{}
},
cardListModal
:
{
isOpen
:
false
,
list
:
[]
},
checkCardModal
:
{
isOpen
:
false
,
cancelAble
:
false
,
tags
:
[]
},
yesNoModal
:
{
isOpen
:
false
},
...
...
@@ -213,6 +215,7 @@ const duelSlice = createSlice({
setMonsterPosition
:
setMonsterPositionImpl
,
removeMonster
:
removeMonsterImpl
,
removeOverlay
:
removeOverlayImpl
,
updateMonsterCounters
:
updateMonsterCountersImpl
,
// 魔法陷阱区相关`Reducer`
initMagics
:
initMagicsImpl
,
...
...
@@ -277,6 +280,7 @@ const duelSlice = createSlice({
setCheckCardModalV3ResponseAble
:
setCheckCardModalV3ResponseAbleImpl
,
resetCheckCardModalV3
:
resetCheckCardModalV3Impl
,
setCheckCardModalV3Selected
:
setCheckCardModalV3SelectedImpl
,
setCardModalCounters
:
setCardModalCountersImpl
,
// 通用的`Reducer`
clearAllIdleInteractivities
:
clearAllIdleInteractivitiesImpl
,
...
...
@@ -337,6 +341,7 @@ export const {
clearMonsterIdleInteractivities
,
setMonsterPosition
,
removeMonster
,
updateMonsterCounters
,
removeOverlay
,
initMagics
,
addMagicPlaceInteractivities
,
...
...
@@ -389,6 +394,7 @@ export const {
setCheckCardModalV3ResponseAble
,
resetCheckCardModalV3
,
setCheckCardModalV3Selected
,
setCardModalCounters
,
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
return
state
.
duel
.
meInitInfo
!=
null
;
...
...
src/reducers/duel/modal/cardModalSlice.ts
View file @
e831f456
...
...
@@ -27,9 +27,19 @@ export const setCardModalInteractiviesImpl: CaseReducer<
state
.
modalState
.
cardModal
.
interactivies
=
action
.
payload
;
};
// 更新卡牌弹窗指示器
export
const
setCardModalCountersImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
[
type
:
number
]:
number
}
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
counters
=
action
.
payload
;
};
export
const
selectCardModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
isOpen
;
export
const
selectCardModalMeta
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
meta
;
export
const
selectCardModalInteractivies
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
interactivies
;
export
const
selectCardModalCounters
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
counters
;
src/reducers/duel/modal/mod.ts
View file @
e831f456
...
...
@@ -7,6 +7,7 @@ export interface ModalState {
isOpen
:
boolean
;
meta
?:
CardMeta
;
interactivies
:
{
desc
:
string
;
response
:
number
}[];
counters
:
{
[
type
:
number
]:
number
};
};
// 卡牌列表弹窗
cardListModal
:
{
...
...
src/reducers/duel/monstersSlice.ts
View file @
e831f456
...
...
@@ -22,6 +22,9 @@ import {
removeOverlay
,
}
from
"
./generic
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
type
MsgUpdateCounter
=
ReturnType
<
typeof
ygopro
.
StocGameMessage
.
MsgUpdateCounter
.
prototype
.
toObject
>
;
export
interface
MonsterState
extends
DuelFieldState
{}
...
...
@@ -40,6 +43,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
0
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -48,6 +52,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
1
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -56,6 +61,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
2
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -64,6 +70,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
3
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -72,6 +79,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
4
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -80,6 +88,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
5
,
},
idleInteractivities
:
[],
counters
:
{},
},
{
location
:
{
...
...
@@ -88,6 +97,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
sequence
:
6
,
},
idleInteractivities
:
[],
counters
:
{},
},
],
};
...
...
@@ -148,6 +158,44 @@ export const addMonsterIdleInteractivitiesImpl: CaseReducer<
);
};
export
const
updateMonsterCountersImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
MsgUpdateCounter
>
>
=
(
state
,
action
)
=>
{
const
monsters
=
judgeSelf
(
action
.
payload
.
location
?.
controler
!
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
if
(
monsters
)
{
const
target
=
monsters
.
inner
.
find
(
(
_
,
idx
)
=>
idx
==
action
.
payload
.
location
?.
sequence
!
);
if
(
target
)
{
const
count
=
action
.
payload
.
count
!
;
const
counterType
=
action
.
payload
.
action_type
!
;
switch
(
action
.
payload
.
action_type
!
)
{
case
ygopro
.
StocGameMessage
.
MsgUpdateCounter
.
ActionType
.
ADD
:
{
if
(
counterType
in
target
.
counters
)
{
target
.
counters
[
counterType
]
+=
count
;
}
else
{
target
.
counters
[
counterType
]
=
count
;
}
break
;
}
case
ygopro
.
StocGameMessage
.
MsgUpdateCounter
.
ActionType
.
REMOVE
:
{
if
(
counterType
in
target
.
counters
)
{
target
.
counters
[
counterType
]
-=
count
;
}
break
;
}
default
:
{
break
;
}
}
}
}
};
export
const
clearMonsterIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
...
...
src/service/duel/gameMsg.ts
View file @
e831f456
...
...
@@ -26,6 +26,7 @@ import onMsgUpdateData from "./updateData";
import
onMsgReloadField
from
"
./reloadField
"
;
import
onMsgSelectSum
from
"
./selectSum
"
;
import
onMsgSelectTribute
from
"
./selectTribute
"
;
import
onMsgUpdateCounter
from
"
./updateCounter
"
;
import
{
setWaiting
}
from
"
../../reducers/duel/mod
"
;
const
ActiveList
=
[
...
...
@@ -175,6 +176,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
}
case
"
update_counter
"
:
{
onMsgUpdateCounter
(
msg
.
update_counter
,
dispatch
);
break
;
}
case
"
unimplemented
"
:
{
onUnimplemented
(
msg
.
unimplemented
,
dispatch
);
...
...
src/service/duel/updateCounter.ts
0 → 100644
View file @
e831f456
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
updateMonsterCounters
}
from
"
../../reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgUpdateCounter
=
ygopro
.
StocGameMessage
.
MsgUpdateCounter
;
export
default
(
updateCounter
:
MsgUpdateCounter
,
dispatch
:
AppDispatch
)
=>
{
dispatch
(
updateMonsterCounters
(
updateCounter
.
toObject
()));
};
src/ui/Duel/cardModal.tsx
View file @
e831f456
...
...
@@ -5,6 +5,7 @@ import {
selectCardModalIsOpen
,
selectCardModalInteractivies
,
selectCardModalMeta
,
selectCardModalCounters
,
}
from
"
../../reducers/duel/modal/mod
"
;
import
{
setCardModalIsOpen
,
...
...
@@ -39,6 +40,7 @@ const CardModal = () => {
const
desc
=
meta
?.
text
.
desc
;
const
atk
=
meta
?.
data
.
atk
;
const
def
=
meta
?.
data
.
def
;
const
counters
=
useAppSelector
(
selectCardModalCounters
);
const
imgUrl
=
meta
?.
id
?
`
${
NeosConfig
.
cardImgUrl
}
/
${
meta
.
id
}
.jpg`
:
undefined
;
...
...
@@ -66,6 +68,9 @@ const CardModal = () => {
<
p
>
<
AtkLine
level=
{
level
}
atk=
{
atk
}
def=
{
def
}
/>
</
p
>
<
p
>
<
CounterLine
counters=
{
counters
}
/>
</
p
>
<
p
>
{
desc
}
</
p
>
</
Card
>
{
interactivies
.
map
((
interactive
,
idx
)
=>
{
...
...
@@ -141,4 +146,25 @@ const AttLine = (props: {
);
};
const
CounterLine
=
(
props
:
{
counters
:
{
[
type
:
number
]:
number
}
})
=>
{
const
counters
=
[];
for
(
const
counterType
in
props
.
counters
)
{
const
count
=
props
.
counters
[
counterType
];
if
(
count
>
0
)
{
const
counterStr
=
fetchStrings
(
"
!counter
"
,
`0x
${
counterType
}
`
);
counters
.
push
(
`
${
counterStr
}
:
${
count
}
`
);
}
}
return
counters
.
length
>
0
?
(
<
Row
gutter=
{
8
}
>
{
counters
.
map
((
counter
)
=>
(
<
Col
>
{
counter
}
</
Col
>
))
}
</
Row
>
)
:
(
<></>
);
};
export
default
CardModal
;
src/ui/Duel/fixedSlot.tsx
View file @
e831f456
...
...
@@ -8,6 +8,7 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import
{
setCardListModalInfo
,
setCardListModalIsOpen
,
setCardModalCounters
,
setCardModalInteractivies
,
setCardModalIsOpen
,
setCardModalMeta
,
...
...
@@ -68,6 +69,7 @@ const FixedSlot = (props: {
})
)
);
dispatch
(
setCardModalCounters
(
props
.
state
.
counters
));
dispatch
(
setCardModalIsOpen
(
true
));
// 侧边栏展示超量素材信息
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment