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
love_飞影
Neos
Commits
0536f9ab
Commit
0536f9ab
authored
Jan 15, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/idle_cmd' into 'main'
Optimize/idle cmd See merge request
mycard/Neos!79
parents
c59e11f2
2767c807
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
285 additions
and
79 deletions
+285
-79
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+22
-14
src/api/ocgcore/ocgAdapter/bufferIO.ts
src/api/ocgcore/ocgAdapter/bufferIO.ts
+10
-7
src/reducers/duel/fieldSlice.ts
src/reducers/duel/fieldSlice.ts
+31
-1
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+23
-0
src/reducers/duel/magicSlice.ts
src/reducers/duel/magicSlice.ts
+32
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+18
-0
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+32
-0
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+105
-55
src/ui/Duel/fixedSlot.tsx
src/ui/Duel/fixedSlot.tsx
+11
-1
No files found.
neos-protobuf
@
a5908aff
Subproject commit
9b1e1b0fdb8982b80c535178f44981cb17206866
Subproject commit
a5908affcf8a663bd2d5e0bf8acf9f77162f7d64
src/api/ocgcore/idl/ocgcore.ts
View file @
0536f9ab
...
@@ -42,7 +42,7 @@ export namespace ygopro {
...
@@ -42,7 +42,7 @@ export namespace ygopro {
|
{
|
{
code
?:
number
;
code
?:
number
;
controler
?:
number
;
controler
?:
number
;
location
?:
number
;
location
?:
CardZone
;
sequence
?:
number
;
sequence
?:
number
;
}
}
)
{
)
{
...
@@ -83,9 +83,13 @@ export namespace ygopro {
...
@@ -83,9 +83,13 @@ export namespace ygopro {
pb_1
.
Message
.
setField
(
this
,
2
,
value
);
pb_1
.
Message
.
setField
(
this
,
2
,
value
);
}
}
get
location
()
{
get
location
()
{
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
3
,
0
)
as
number
;
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
3
,
CardZone
.
DECK
)
as
CardZone
;
}
}
set
location
(
value
:
number
)
{
set
location
(
value
:
CardZone
)
{
pb_1
.
Message
.
setField
(
this
,
3
,
value
);
pb_1
.
Message
.
setField
(
this
,
3
,
value
);
}
}
get
sequence
()
{
get
sequence
()
{
...
@@ -97,7 +101,7 @@ export namespace ygopro {
...
@@ -97,7 +101,7 @@ export namespace ygopro {
static
fromObject
(
data
:
{
static
fromObject
(
data
:
{
code
?:
number
;
code
?:
number
;
controler
?:
number
;
controler
?:
number
;
location
?:
number
;
location
?:
CardZone
;
sequence
?:
number
;
sequence
?:
number
;
}):
CardInfo
{
}):
CardInfo
{
const
message
=
new
CardInfo
({});
const
message
=
new
CardInfo
({});
...
@@ -119,7 +123,7 @@ export namespace ygopro {
...
@@ -119,7 +123,7 @@ export namespace ygopro {
const
data
:
{
const
data
:
{
code
?:
number
;
code
?:
number
;
controler
?:
number
;
controler
?:
number
;
location
?:
number
;
location
?:
CardZone
;
sequence
?:
number
;
sequence
?:
number
;
}
=
{};
}
=
{};
if
(
this
.
code
!=
null
)
{
if
(
this
.
code
!=
null
)
{
...
@@ -142,7 +146,7 @@ export namespace ygopro {
...
@@ -142,7 +146,7 @@ export namespace ygopro {
const
writer
=
w
||
new
pb_1
.
BinaryWriter
();
const
writer
=
w
||
new
pb_1
.
BinaryWriter
();
if
(
this
.
code
!=
0
)
writer
.
writeInt32
(
1
,
this
.
code
);
if
(
this
.
code
!=
0
)
writer
.
writeInt32
(
1
,
this
.
code
);
if
(
this
.
controler
!=
0
)
writer
.
writeInt32
(
2
,
this
.
controler
);
if
(
this
.
controler
!=
0
)
writer
.
writeInt32
(
2
,
this
.
controler
);
if
(
this
.
location
!=
0
)
writer
.
writeInt32
(
3
,
this
.
location
);
if
(
this
.
location
!=
CardZone
.
DECK
)
writer
.
writeEnum
(
3
,
this
.
location
);
if
(
this
.
sequence
!=
0
)
writer
.
writeInt32
(
4
,
this
.
sequence
);
if
(
this
.
sequence
!=
0
)
writer
.
writeInt32
(
4
,
this
.
sequence
);
if
(
!
w
)
return
writer
.
getResultBuffer
();
if
(
!
w
)
return
writer
.
getResultBuffer
();
}
}
...
@@ -162,7 +166,7 @@ export namespace ygopro {
...
@@ -162,7 +166,7 @@ export namespace ygopro {
message
.
controler
=
reader
.
readInt32
();
message
.
controler
=
reader
.
readInt32
();
break
;
break
;
case
3
:
case
3
:
message
.
location
=
reader
.
read
Int32
();
message
.
location
=
reader
.
read
Enum
();
break
;
break
;
case
4
:
case
4
:
message
.
sequence
=
reader
.
readInt32
();
message
.
sequence
=
reader
.
readInt32
();
...
@@ -187,7 +191,7 @@ export namespace ygopro {
...
@@ -187,7 +191,7 @@ export namespace ygopro {
|
any
[]
|
any
[]
|
{
|
{
controler
?:
number
;
controler
?:
number
;
location
?:
number
;
location
?:
CardZone
;
sequence
?:
number
;
sequence
?:
number
;
position
?:
CardPosition
;
position
?:
CardPosition
;
overlay_sequence
?:
number
;
overlay_sequence
?:
number
;
...
@@ -227,9 +231,13 @@ export namespace ygopro {
...
@@ -227,9 +231,13 @@ export namespace ygopro {
pb_1
.
Message
.
setField
(
this
,
1
,
value
);
pb_1
.
Message
.
setField
(
this
,
1
,
value
);
}
}
get
location
()
{
get
location
()
{
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
2
,
0
)
as
number
;
return
pb_1
.
Message
.
getFieldWithDefault
(
this
,
2
,
CardZone
.
DECK
)
as
CardZone
;
}
}
set
location
(
value
:
number
)
{
set
location
(
value
:
CardZone
)
{
pb_1
.
Message
.
setField
(
this
,
2
,
value
);
pb_1
.
Message
.
setField
(
this
,
2
,
value
);
}
}
get
sequence
()
{
get
sequence
()
{
...
@@ -256,7 +264,7 @@ export namespace ygopro {
...
@@ -256,7 +264,7 @@ export namespace ygopro {
}
}
static
fromObject
(
data
:
{
static
fromObject
(
data
:
{
controler
?:
number
;
controler
?:
number
;
location
?:
number
;
location
?:
CardZone
;
sequence
?:
number
;
sequence
?:
number
;
position
?:
CardPosition
;
position
?:
CardPosition
;
overlay_sequence
?:
number
;
overlay_sequence
?:
number
;
...
@@ -282,7 +290,7 @@ export namespace ygopro {
...
@@ -282,7 +290,7 @@ export namespace ygopro {
toObject
()
{
toObject
()
{
const
data
:
{
const
data
:
{
controler
?:
number
;
controler
?:
number
;
location
?:
number
;
location
?:
CardZone
;
sequence
?:
number
;
sequence
?:
number
;
position
?:
CardPosition
;
position
?:
CardPosition
;
overlay_sequence
?:
number
;
overlay_sequence
?:
number
;
...
@@ -309,7 +317,7 @@ export namespace ygopro {
...
@@ -309,7 +317,7 @@ export namespace ygopro {
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
.
controler
!=
0
)
writer
.
writeInt32
(
1
,
this
.
controler
);
if
(
this
.
controler
!=
0
)
writer
.
writeInt32
(
1
,
this
.
controler
);
if
(
this
.
location
!=
0
)
writer
.
writeInt32
(
2
,
this
.
location
);
if
(
this
.
location
!=
CardZone
.
DECK
)
writer
.
writeEnum
(
2
,
this
.
location
);
if
(
this
.
sequence
!=
0
)
writer
.
writeInt32
(
3
,
this
.
sequence
);
if
(
this
.
sequence
!=
0
)
writer
.
writeInt32
(
3
,
this
.
sequence
);
if
(
this
.
position
!=
CardPosition
.
FACEUP_ATTACK
)
if
(
this
.
position
!=
CardPosition
.
FACEUP_ATTACK
)
writer
.
writeEnum
(
4
,
this
.
position
);
writer
.
writeEnum
(
4
,
this
.
position
);
...
@@ -330,7 +338,7 @@ export namespace ygopro {
...
@@ -330,7 +338,7 @@ export namespace ygopro {
message
.
controler
=
reader
.
readInt32
();
message
.
controler
=
reader
.
readInt32
();
break
;
break
;
case
2
:
case
2
:
message
.
location
=
reader
.
read
Int32
();
message
.
location
=
reader
.
read
Enum
();
break
;
break
;
case
3
:
case
3
:
message
.
sequence
=
reader
.
readInt32
();
message
.
sequence
=
reader
.
readInt32
();
...
...
src/api/ocgcore/ocgAdapter/bufferIO.ts
View file @
0536f9ab
...
@@ -54,14 +54,17 @@ export class BufferReader {
...
@@ -54,14 +54,17 @@ export class BufferReader {
}
}
readCardInfo
():
ygopro
.
CardInfo
{
readCardInfo
():
ygopro
.
CardInfo
{
const
cardInfo
=
new
ygopro
.
CardInfo
({});
const
code
=
this
.
readUint32
();
const
controler
=
this
.
readUint8
();
cardInfo
.
code
=
this
.
readUint32
();
const
location
=
numberToCardZone
(
this
.
readUint8
());
cardInfo
.
controler
=
this
.
readUint8
();
const
sequence
=
this
.
readUint8
();
cardInfo
.
location
=
this
.
readUint8
();
cardInfo
.
sequence
=
this
.
readUint8
();
return
cardInfo
;
return
new
ygopro
.
CardInfo
({
code
,
controler
,
location
,
sequence
,
});
}
}
readCardLocation
(
overlay
?:
boolean
):
ygopro
.
CardLocation
{
readCardLocation
(
overlay
?:
boolean
):
ygopro
.
CardLocation
{
...
...
src/reducers/duel/fieldSlice.ts
View file @
0536f9ab
...
@@ -3,7 +3,7 @@ import { DuelState } from "./mod";
...
@@ -3,7 +3,7 @@ import { DuelState } from "./mod";
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
CardState
,
InteractType
}
from
"
./generic
"
;
import
{
CardState
,
Interact
ivity
,
Interact
Type
}
from
"
./generic
"
;
export
interface
FieldState
{
export
interface
FieldState
{
inner
?:
CardState
;
inner
?:
CardState
;
...
@@ -69,5 +69,35 @@ export const clearFieldPlaceInteractivitiesImpl: CaseReducer<
...
@@ -69,5 +69,35 @@ export const clearFieldPlaceInteractivitiesImpl: CaseReducer<
}
}
};
};
export
const
addFieldIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
sequence
:
number
;
interactivity
:
Interactivity
<
number
>
;
}
>
>
=
(
state
,
action
)
=>
{
const
field
=
judgeSelf
(
action
.
payload
.
player
,
state
)
?
state
.
meField
:
state
.
opField
;
if
(
field
&&
field
.
inner
)
{
field
.
inner
.
idleInteractivities
.
push
(
action
.
payload
.
interactivity
);
}
};
export
const
clearFieldIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
const
field
=
judgeSelf
(
action
.
payload
,
state
)
?
state
.
meField
:
state
.
opField
;
if
(
field
&&
field
.
inner
)
{
field
.
inner
.
idleInteractivities
=
[];
}
};
export
const
selectMeField
=
(
state
:
RootState
)
=>
state
.
duel
.
meField
;
export
const
selectMeField
=
(
state
:
RootState
)
=>
state
.
duel
.
meField
;
export
const
selectOpField
=
(
state
:
RootState
)
=>
state
.
duel
.
opField
;
export
const
selectOpField
=
(
state
:
RootState
)
=>
state
.
duel
.
opField
;
src/reducers/duel/generic.ts
View file @
0536f9ab
...
@@ -224,3 +224,26 @@ export function updateCardMeta<T extends DuelFieldState>(
...
@@ -224,3 +224,26 @@ export function updateCardMeta<T extends DuelFieldState>(
});
});
}
}
}
}
export
function
extendIdleInteractivities
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
,
sequence
:
number
,
interactivity
:
Interactivity
<
number
>
)
{
if
(
state
)
{
const
target
=
state
.
inner
.
find
((
_
,
idx
)
=>
idx
==
sequence
);
if
(
target
)
{
target
.
idleInteractivities
.
push
(
interactivity
);
}
}
}
export
function
clearIdleInteractivities
<
T
extends
DuelFieldState
>
(
state
:
T
|
undefined
)
{
if
(
state
)
{
state
.
inner
.
forEach
((
item
)
=>
{
item
.
idleInteractivities
=
[];
});
}
}
src/reducers/duel/magicSlice.ts
View file @
0536f9ab
...
@@ -14,6 +14,9 @@ import {
...
@@ -14,6 +14,9 @@ import {
extendPlaceInteractivity
,
extendPlaceInteractivity
,
clearPlaceInteractivities
,
clearPlaceInteractivities
,
removeOccupant
,
removeOccupant
,
Interactivity
,
extendIdleInteractivities
,
clearIdleInteractivities
,
}
from
"
./generic
"
;
}
from
"
./generic
"
;
export
interface
MagicState
extends
DuelFieldState
{}
export
interface
MagicState
extends
DuelFieldState
{}
...
@@ -97,6 +100,35 @@ export const clearMagicPlaceInteractivitiesImpl: CaseReducer<
...
@@ -97,6 +100,35 @@ export const clearMagicPlaceInteractivitiesImpl: CaseReducer<
clearPlaceInteractivities
(
magics
);
clearPlaceInteractivities
(
magics
);
};
};
export
const
addMagicIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
sequence
:
number
;
interactivity
:
Interactivity
<
number
>
;
}
>
>
=
(
state
,
action
)
=>
{
const
magics
=
judgeSelf
(
action
.
payload
.
player
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
extendIdleInteractivities
(
magics
,
action
.
payload
.
sequence
,
action
.
payload
.
interactivity
);
};
export
const
clearMagicIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
const
magics
=
judgeSelf
(
action
.
payload
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
clearIdleInteractivities
(
magics
);
};
// 增加魔法陷阱
// 增加魔法陷阱
export
const
fetchMagicMeta
=
createAsyncMetaThunk
(
"
duel/fetchMagicMeta
"
);
export
const
fetchMagicMeta
=
createAsyncMetaThunk
(
"
duel/fetchMagicMeta
"
);
...
...
src/reducers/duel/mod.ts
View file @
0536f9ab
...
@@ -46,6 +46,8 @@ import {
...
@@ -46,6 +46,8 @@ import {
initMonstersImpl
,
initMonstersImpl
,
addMonsterPlaceInteractivitiesImpl
,
addMonsterPlaceInteractivitiesImpl
,
clearMonsterPlaceInteractivitiesImpl
,
clearMonsterPlaceInteractivitiesImpl
,
addMonsterIdleInteractivitiesImpl
,
clearMonsterIdleInteractivitiesImpl
,
removeMonsterImpl
,
removeMonsterImpl
,
monsterCase
,
monsterCase
,
}
from
"
./monstersSlice
"
;
}
from
"
./monstersSlice
"
;
...
@@ -54,6 +56,8 @@ import {
...
@@ -54,6 +56,8 @@ import {
initMagicsImpl
,
initMagicsImpl
,
addMagicPlaceInteractivitiesImpl
,
addMagicPlaceInteractivitiesImpl
,
clearMagicPlaceInteractivitiesImpl
,
clearMagicPlaceInteractivitiesImpl
,
addMagicIdleInteractivitiesImpl
,
clearMagicIdleInteractivitiesImpl
,
removeMagicImpl
,
removeMagicImpl
,
magicCase
,
magicCase
,
}
from
"
./magicSlice
"
;
}
from
"
./magicSlice
"
;
...
@@ -69,6 +73,8 @@ import {
...
@@ -69,6 +73,8 @@ import {
initFieldImpl
,
initFieldImpl
,
clearFieldPlaceInteractivitiesImpl
,
clearFieldPlaceInteractivitiesImpl
,
addFieldPlaceInteractivitiesImpl
,
addFieldPlaceInteractivitiesImpl
,
addFieldIdleInteractivitiesImpl
,
clearFieldIdleInteractivitiesImpl
,
}
from
"
./fieldSlice
"
;
}
from
"
./fieldSlice
"
;
export
interface
DuelState
{
export
interface
DuelState
{
...
@@ -142,12 +148,16 @@ const duelSlice = createSlice({
...
@@ -142,12 +148,16 @@ const duelSlice = createSlice({
initMonsters
:
initMonstersImpl
,
initMonsters
:
initMonstersImpl
,
addMonsterPlaceInteractivities
:
addMonsterPlaceInteractivitiesImpl
,
addMonsterPlaceInteractivities
:
addMonsterPlaceInteractivitiesImpl
,
clearMonsterPlaceInteractivities
:
clearMonsterPlaceInteractivitiesImpl
,
clearMonsterPlaceInteractivities
:
clearMonsterPlaceInteractivitiesImpl
,
addMonsterIdleInteractivities
:
addMonsterIdleInteractivitiesImpl
,
clearMonsterIdleInteractivities
:
clearMonsterIdleInteractivitiesImpl
,
removeMonster
:
removeMonsterImpl
,
removeMonster
:
removeMonsterImpl
,
// 魔法陷阱区相关`Reducer`
// 魔法陷阱区相关`Reducer`
initMagics
:
initMagicsImpl
,
initMagics
:
initMagicsImpl
,
addMagicPlaceInteractivities
:
addMagicPlaceInteractivitiesImpl
,
addMagicPlaceInteractivities
:
addMagicPlaceInteractivitiesImpl
,
clearMagicPlaceInteractivities
:
clearMagicPlaceInteractivitiesImpl
,
clearMagicPlaceInteractivities
:
clearMagicPlaceInteractivitiesImpl
,
addMagicIdleInteractivities
:
addMagicIdleInteractivitiesImpl
,
clearMagicIdleInteractivities
:
clearMagicIdleInteractivitiesImpl
,
removeMagic
:
removeMagicImpl
,
removeMagic
:
removeMagicImpl
,
// 墓地相关`Reducer`
// 墓地相关`Reducer`
...
@@ -163,6 +173,8 @@ const duelSlice = createSlice({
...
@@ -163,6 +173,8 @@ const duelSlice = createSlice({
initField
:
initFieldImpl
,
initField
:
initFieldImpl
,
clearFieldPlaceInteractivities
:
clearFieldPlaceInteractivitiesImpl
,
clearFieldPlaceInteractivities
:
clearFieldPlaceInteractivitiesImpl
,
addFieldPlaceInteractivities
:
addFieldPlaceInteractivitiesImpl
,
addFieldPlaceInteractivities
:
addFieldPlaceInteractivitiesImpl
,
addFieldIdleInteractivities
:
addFieldIdleInteractivitiesImpl
,
clearFieldIdleInteractivities
:
clearFieldIdleInteractivitiesImpl
,
// UI相关`Reducer`
// UI相关`Reducer`
setCardModalIsOpen
:
setCardModalIsOpenImpl
,
setCardModalIsOpen
:
setCardModalIsOpenImpl
,
...
@@ -212,10 +224,14 @@ export const {
...
@@ -212,10 +224,14 @@ export const {
initMonsters
,
initMonsters
,
addMonsterPlaceInteractivities
,
addMonsterPlaceInteractivities
,
clearMonsterPlaceInteractivities
,
clearMonsterPlaceInteractivities
,
addMonsterIdleInteractivities
,
clearMonsterIdleInteractivities
,
removeMonster
,
removeMonster
,
initMagics
,
initMagics
,
addMagicPlaceInteractivities
,
addMagicPlaceInteractivities
,
clearMagicPlaceInteractivities
,
clearMagicPlaceInteractivities
,
addMagicIdleInteractivities
,
clearMagicIdleInteractivities
,
removeMagic
,
removeMagic
,
removeHand
,
removeHand
,
initCemetery
,
initCemetery
,
...
@@ -238,6 +254,8 @@ export const {
...
@@ -238,6 +254,8 @@ export const {
initField
,
initField
,
clearFieldPlaceInteractivities
,
clearFieldPlaceInteractivities
,
addFieldPlaceInteractivities
,
addFieldPlaceInteractivities
,
addFieldIdleInteractivities
,
clearFieldIdleInteractivities
,
}
=
duelSlice
.
actions
;
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
return
state
.
duel
.
meInitInfo
!=
null
;
return
state
.
duel
.
meInitInfo
!=
null
;
...
...
src/reducers/duel/monstersSlice.ts
View file @
0536f9ab
...
@@ -9,11 +9,14 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
...
@@ -9,11 +9,14 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
import
{
DuelFieldState
,
DuelFieldState
,
Interactivity
,
createAsyncMetaThunk
,
createAsyncMetaThunk
,
extendOccupant
,
extendOccupant
,
extendPlaceInteractivity
,
extendPlaceInteractivity
,
clearPlaceInteractivities
,
clearPlaceInteractivities
,
removeOccupant
,
removeOccupant
,
extendIdleInteractivities
,
clearIdleInteractivities
,
}
from
"
./generic
"
;
}
from
"
./generic
"
;
export
interface
MonsterState
extends
DuelFieldState
{}
export
interface
MonsterState
extends
DuelFieldState
{}
...
@@ -107,6 +110,35 @@ export const clearMonsterPlaceInteractivitiesImpl: CaseReducer<
...
@@ -107,6 +110,35 @@ export const clearMonsterPlaceInteractivitiesImpl: CaseReducer<
clearPlaceInteractivities
(
monsters
);
clearPlaceInteractivities
(
monsters
);
};
};
export
const
addMonsterIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
sequence
:
number
;
interactivity
:
Interactivity
<
number
>
;
}
>
>
=
(
state
,
action
)
=>
{
const
monsters
=
judgeSelf
(
action
.
payload
.
player
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
extendIdleInteractivities
(
monsters
,
action
.
payload
.
sequence
,
action
.
payload
.
interactivity
);
};
export
const
clearMonsterIdleInteractivitiesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
const
monsters
=
judgeSelf
(
action
.
payload
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
clearIdleInteractivities
(
monsters
);
};
// 增加怪兽
// 增加怪兽
export
const
fetchMonsterMeta
=
createAsyncMetaThunk
(
"
duel/fetchMonsterMeta
"
);
export
const
fetchMonsterMeta
=
createAsyncMetaThunk
(
"
duel/fetchMonsterMeta
"
);
...
...
src/service/duel/selectIdleCmd.ts
View file @
0536f9ab
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
InteractType
}
from
"
../../reducers/duel/generic
"
;
import
{
Interact
ivity
,
Interact
Type
}
from
"
../../reducers/duel/generic
"
;
import
{
import
{
clearHandsIdleInteractivity
,
clearHandsIdleInteractivity
,
addHandsIdleInteractivity
,
addHandsIdleInteractivity
,
addMonsterIdleInteractivities
,
addMagicIdleInteractivities
,
clearMonsterIdleInteractivities
,
clearMagicIdleInteractivities
,
clearFieldIdleInteractivities
,
addFieldIdleInteractivities
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
import
{
ActionCreatorWithPayload
}
from
"
@reduxjs/toolkit
"
;
export
default
(
selectIdleCmd
:
MsgSelectIdleCmd
,
dispatch
:
AppDispatch
)
=>
{
export
default
(
selectIdleCmd
:
MsgSelectIdleCmd
,
dispatch
:
AppDispatch
)
=>
{
const
player
=
selectIdleCmd
.
player
;
const
player
=
selectIdleCmd
.
player
;
const
cmds
=
selectIdleCmd
.
idle_cmds
;
const
cmds
=
selectIdleCmd
.
idle_cmds
;
// 先清掉之前的
手牌
互动性
// 先清掉之前的互动性
dispatch
(
clearHandsIdleInteractivity
(
player
));
dispatch
(
clearHandsIdleInteractivity
(
player
));
dispatch
(
clearMonsterIdleInteractivities
(
player
));
dispatch
(
clearMagicIdleInteractivities
(
player
));
dispatch
(
clearFieldIdleInteractivities
(
player
));
for
(
let
cmd
of
cmds
)
{
const
dispatcher
=
(
let
interactType
;
idleData
:
MsgSelectIdleCmd
.
IdleCmd
.
IdleData
,
switch
(
cmd
.
idle_type
)
{
interactType
:
InteractType
|
undefined
,
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
SUMMON
:
{
actionCreator
:
ActionCreatorWithPayload
<
interactType
=
InteractType
.
SUMMON
;
{
break
;
player
:
number
;
}
sequence
:
number
;
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
SPSUMMON
:
{
interactivity
:
Interactivity
<
number
>
;
interactType
=
InteractType
.
SP_SUMMON
;
},
break
;
string
}
>
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
POS_CHANGE
:
{
)
=>
{
interactType
=
InteractType
.
POS_CHANGE
;
const
cardInfo
=
idleData
.
card_info
;
break
;
if
(
interactType
===
InteractType
.
ACTIVATE
)
{
}
// 发动效果会多一个字段
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
MSET
:
{
dispatch
(
interactType
=
InteractType
.
MSET
;
actionCreator
({
break
;
player
,
}
sequence
:
cardInfo
.
sequence
,
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
SSET
:
{
interactivity
:
{
interactType
=
InteractType
.
SSET
;
interactType
,
break
;
activateIndex
:
idleData
.
effect_description
,
}
response
:
idleData
.
response
,
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
ACTIVATE
:
{
},
interactType
=
InteractType
.
ACTIVATE
;
})
break
;
);
}
}
else
if
(
interactType
)
{
dispatch
(
actionCreator
({
player
,
sequence
:
cardInfo
.
sequence
,
interactivity
:
{
interactType
,
response
:
idleData
.
response
},
})
);
}
else
{
console
.
log
(
`InteractType undefined`
);
}
}
};
cmds
.
forEach
((
cmd
)
=>
{
const
interactType
=
idleTypeToInteractType
(
cmd
.
idle_type
);
cmd
.
idle_datas
.
forEach
((
data
)
=>
{
const
cardInfo
=
data
.
card_info
;
switch
(
cardInfo
.
location
)
{
case
ygopro
.
CardZone
.
HAND
:
{
dispatcher
(
data
,
interactType
,
addHandsIdleInteractivity
);
break
;
}
case
ygopro
.
CardZone
.
MZONE
:
{
dispatcher
(
data
,
interactType
,
addMonsterIdleInteractivities
);
break
;
}
case
ygopro
.
CardZone
.
SZONE
:
{
dispatcher
(
data
,
interactType
,
addMagicIdleInteractivities
);
for
(
let
data
of
cmd
.
idle_datas
)
{
break
;
const
card_info
=
data
.
card_info
;
}
if
(
card_info
.
location
===
2
)
{
case
ygopro
.
CardZone
.
ONFIELD
:
{
// 目前只处理手牌场景
dispatcher
(
data
,
interactType
,
addFieldIdleInteractivities
);
if
(
interactType
===
InteractType
.
ACTIVATE
)
{
// 发动效果会多一个字段
break
;
dispatch
(
}
addHandsIdleInteractivity
({
default
:
{
player
,
sequence
:
card_info
.
sequence
,
interactivity
:
{
interactType
,
activateIndex
:
data
.
effect_description
,
response
:
data
.
response
,
},
})
);
}
else
if
(
interactType
)
{
dispatch
(
addHandsIdleInteractivity
({
player
,
sequence
:
card_info
.
sequence
,
interactivity
:
{
interactType
,
response
:
data
.
response
},
})
);
}
}
}
}
});
});
};
function
idleTypeToInteractType
(
idleType
:
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
):
InteractType
|
undefined
{
switch
(
idleType
)
{
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
SUMMON
:
{
return
InteractType
.
SUMMON
;
}
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
SPSUMMON
:
{
return
InteractType
.
SP_SUMMON
;
}
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
POS_CHANGE
:
{
return
InteractType
.
POS_CHANGE
;
}
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
MSET
:
{
return
InteractType
.
MSET
;
}
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
SSET
:
{
return
InteractType
.
SSET
;
}
case
MsgSelectIdleCmd
.
IdleCmd
.
IdleType
.
ACTIVATE
:
{
return
InteractType
.
ACTIVATE
;
}
default
:
{
return
undefined
;
}
}
}
}
}
;
}
src/ui/Duel/fixedSlot.tsx
View file @
0536f9ab
...
@@ -13,6 +13,7 @@ import {
...
@@ -13,6 +13,7 @@ import {
setCardModalText
,
setCardModalText
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
import
{
ActionCreatorWithPayload
}
from
"
@reduxjs/toolkit
"
;
import
{
ActionCreatorWithPayload
}
from
"
@reduxjs/toolkit
"
;
import
{
interactTypeToString
}
from
"
./util
"
;
const
shape
=
CONFIG
.
CardSlotShape
();
const
shape
=
CONFIG
.
CardSlotShape
();
...
@@ -59,7 +60,16 @@ const FixedSlot = (props: {
...
@@ -59,7 +60,16 @@ const FixedSlot = (props: {
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
props
.
state
.
occupant
.
id
}
.jpg`
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
props
.
state
.
occupant
.
id
}
.jpg`
)
)
);
);
dispatch
(
setCardModalInteractivies
([]));
// TODO
dispatch
(
setCardModalInteractivies
(
props
.
state
.
idleInteractivities
.
map
((
interactivity
)
=>
{
return
{
desc
:
interactTypeToString
(
interactivity
.
interactType
),
response
:
interactivity
.
response
,
};
})
)
);
dispatch
(
setCardModalIsOpen
(
true
));
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