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
deft
Neos
Commits
7ef855ab
Commit
7ef855ab
authored
Jan 11, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generic CardState
parent
c1c8620d
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
251 additions
and
210 deletions
+251
-210
src/reducers/duel/cemeretySlice.ts
src/reducers/duel/cemeretySlice.ts
+21
-11
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+1
-1
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+32
-24
src/reducers/duel/magicSlice.ts
src/reducers/duel/magicSlice.ts
+44
-18
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+21
-21
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+44
-18
src/reducers/duel/util.ts
src/reducers/duel/util.ts
+0
-52
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+8
-8
src/service/duel/selectPlace.ts
src/service/duel/selectPlace.ts
+8
-4
src/ui/Duel/cardModal.tsx
src/ui/Duel/cardModal.tsx
+2
-2
src/ui/Duel/cemetery.tsx
src/ui/Duel/cemetery.tsx
+5
-5
src/ui/Duel/hands.tsx
src/ui/Duel/hands.tsx
+18
-10
src/ui/Duel/magics.tsx
src/ui/Duel/magics.tsx
+23
-17
src/ui/Duel/monsters.tsx
src/ui/Duel/monsters.tsx
+23
-18
src/ui/Duel/util.ts
src/ui/Duel/util.ts
+1
-1
No files found.
src/reducers/duel/cemeretySlice.ts
View file @
7ef855ab
import
{
judgeSelf
,
Cemetery
}
from
"
./util
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
import
{
PayloadAction
,
PayloadAction
,
CaseReducer
,
CaseReducer
,
...
@@ -8,9 +8,11 @@ import {
...
@@ -8,9 +8,11 @@ import {
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
CardState
}
from
"
./generic
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
export
interface
CemeteryState
{
export
interface
CemeteryState
{
cemetery
:
C
emetery
[];
cemetery
:
C
ardState
[];
}
}
// 初始化墓地状态
// 初始化墓地状态
...
@@ -50,18 +52,26 @@ export const cemeteryCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -50,18 +52,26 @@ export const cemeteryCase = (builder: ActionReducerMapBuilder<DuelState>) => {
const
sequence
=
action
.
meta
.
arg
.
sequence
;
const
sequence
=
action
.
meta
.
arg
.
sequence
;
const
code
=
action
.
meta
.
arg
.
code
;
const
code
=
action
.
meta
.
arg
.
code
;
const
meta
=
{
id
:
code
,
data
:
{},
text
:
{}
};
const
newCemetery
=
{
occupant
:
{
id
:
code
,
data
:
{},
text
:
{}
},
location
:
new
ygopro
.
CardLocation
({
controler
,
location
:
ygopro
.
CardZone
.
GRAVE
,
sequence
,
}),
idleInteractivities
:
[],
};
if
(
judgeSelf
(
controler
,
state
))
{
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meCemetery
)
{
if
(
state
.
meCemetery
)
{
state
.
meCemetery
.
cemetery
.
push
(
{
sequence
,
meta
}
);
state
.
meCemetery
.
cemetery
.
push
(
newCemetery
);
}
else
{
}
else
{
state
.
meCemetery
=
{
cemetery
:
[
{
sequence
,
meta
}
]
};
state
.
meCemetery
=
{
cemetery
:
[
newCemetery
]
};
}
}
}
else
{
}
else
{
if
(
state
.
opCemetery
)
{
if
(
state
.
opCemetery
)
{
state
.
opCemetery
.
cemetery
.
push
(
{
sequence
,
meta
}
);
state
.
opCemetery
.
cemetery
.
push
(
newCemetery
);
}
else
{
}
else
{
state
.
opCemetery
=
{
cemetery
:
[
{
sequence
,
meta
}
]
};
state
.
opCemetery
=
{
cemetery
:
[
newCemetery
]
};
}
}
}
}
});
});
...
@@ -73,16 +83,16 @@ export const cemeteryCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -73,16 +83,16 @@ export const cemeteryCase = (builder: ActionReducerMapBuilder<DuelState>) => {
if
(
judgeSelf
(
controler
,
state
))
{
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meCemetery
)
{
if
(
state
.
meCemetery
)
{
for
(
const
cemetery
of
state
.
meCemetery
.
cemetery
)
{
for
(
const
cemetery
of
state
.
meCemetery
.
cemetery
)
{
if
(
cemetery
.
sequence
==
sequence
)
{
if
(
cemetery
.
location
.
sequence
==
sequence
)
{
cemetery
.
meta
=
meta
;
cemetery
.
occupant
=
meta
;
}
}
}
}
}
}
}
else
{
}
else
{
if
(
state
.
opCemetery
)
{
if
(
state
.
opCemetery
)
{
for
(
const
cemetery
of
state
.
opCemetery
.
cemetery
)
{
for
(
const
cemetery
of
state
.
opCemetery
.
cemetery
)
{
if
(
cemetery
.
sequence
==
sequence
)
{
if
(
cemetery
.
location
.
sequence
==
sequence
)
{
cemetery
.
meta
=
meta
;
cemetery
.
occupant
=
meta
;
}
}
}
}
}
}
...
...
src/reducers/duel/generic.ts
View file @
7ef855ab
...
@@ -4,7 +4,7 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
...
@@ -4,7 +4,7 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
export
interface
CardState
{
export
interface
CardState
{
occupant
?:
CardMeta
;
// 占据此位置的卡牌元信息
occupant
?:
CardMeta
;
// 占据此位置的卡牌元信息
location
:
ygopro
.
CardLocation
;
// 位置信息
location
:
ygopro
.
CardLocation
;
// 位置信息
idleInteractivities
?
:
Interactivity
<
number
>
[];
// IDLE状态下的互动信息
idleInteractivities
:
Interactivity
<
number
>
[];
// IDLE状态下的互动信息
placeInteractivities
?:
Interactivity
<
{
placeInteractivities
?:
Interactivity
<
{
controler
:
number
;
controler
:
number
;
zone
:
ygopro
.
CardZone
;
zone
:
ygopro
.
CardZone
;
...
...
src/reducers/duel/handsSlice.ts
View file @
7ef855ab
...
@@ -7,11 +7,13 @@ import {
...
@@ -7,11 +7,13 @@ import {
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
,
CardMeta
}
from
"
../../api/cards
"
;
import
{
fetchCard
,
CardMeta
}
from
"
../../api/cards
"
;
import
{
judgeSelf
,
Hand
,
Interactivity
}
from
"
./util
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
CardState
,
Interactivity
}
from
"
./generic
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
export
interface
Hand
s
{
export
interface
Hand
State
{
// 注意:手牌的位置顺序是有约束的
// 注意:手牌的位置顺序是有约束的
cards
:
Hand
[];
hands
:
CardState
[];
}
}
// 增加手牌
// 增加手牌
...
@@ -42,24 +44,28 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -42,24 +44,28 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
const
player
=
action
.
meta
.
arg
[
0
];
const
player
=
action
.
meta
.
arg
[
0
];
const
ids
=
action
.
meta
.
arg
[
1
];
const
ids
=
action
.
meta
.
arg
[
1
];
const
cards
=
ids
.
map
((
id
)
=>
{
const
cards
=
ids
.
map
((
id
,
idx
)
=>
{
return
{
return
{
meta
:
{
id
,
data
:
{},
text
:
{}
},
occupant
:
{
id
,
data
:
{},
text
:
{}
},
transform
:
{},
location
:
new
ygopro
.
CardLocation
({
interactivities
:
[],
controler
:
player
,
location
:
ygopro
.
CardZone
.
HAND
,
sequence
:
idx
,
}),
idleInteractivities
:
[],
};
};
});
});
if
(
judgeSelf
(
player
,
state
))
{
if
(
judgeSelf
(
player
,
state
))
{
if
(
state
.
meHands
)
{
if
(
state
.
meHands
)
{
state
.
meHands
.
cards
=
state
.
meHands
.
car
ds
.
concat
(
cards
);
state
.
meHands
.
hands
=
state
.
meHands
.
han
ds
.
concat
(
cards
);
}
else
{
}
else
{
state
.
meHands
=
{
cards
};
state
.
meHands
=
{
hands
:
cards
};
}
}
}
else
{
}
else
{
if
(
state
.
opHands
)
{
if
(
state
.
opHands
)
{
state
.
opHands
.
cards
=
state
.
opHands
.
car
ds
.
concat
(
cards
);
state
.
opHands
.
hands
=
state
.
opHands
.
han
ds
.
concat
(
cards
);
}
else
{
}
else
{
state
.
opHands
=
{
cards
};
state
.
opHands
=
{
hands
:
cards
};
}
}
}
}
});
});
...
@@ -70,10 +76,10 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -70,10 +76,10 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
if
(
hands
)
{
for
(
let
hand
of
hands
.
car
ds
)
{
for
(
let
hand
of
hands
.
han
ds
)
{
for
(
let
meta
of
metas
)
{
for
(
let
meta
of
metas
)
{
if
(
hand
.
meta
.
id
===
meta
.
id
)
{
if
(
hand
.
occupant
?
.
id
===
meta
.
id
)
{
hand
.
meta
=
meta
;
hand
.
occupant
=
meta
;
}
}
}
}
}
}
...
@@ -82,7 +88,7 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -82,7 +88,7 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
};
};
// 清空手牌互动性
// 清空手牌互动性
export
const
clearHandsInteractivityImpl
:
CaseReducer
<
export
const
clearHandsI
dleI
nteractivityImpl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
number
>
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
...
@@ -91,18 +97,18 @@ export const clearHandsInteractivityImpl: CaseReducer<
...
@@ -91,18 +97,18 @@ export const clearHandsInteractivityImpl: CaseReducer<
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
if
(
hands
)
{
for
(
let
hand
of
hands
.
car
ds
)
{
for
(
let
hand
of
hands
.
han
ds
)
{
hand
.
interactivities
=
[];
hand
.
i
dleI
nteractivities
=
[];
}
}
}
}
};
};
// 添加手牌互动性
// 添加手牌互动性
export
const
addHandsInteractivityImpl
:
CaseReducer
<
export
const
addHandsI
dleI
nteractivityImpl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
{
PayloadAction
<
{
player
:
number
;
player
:
number
;
index
:
number
;
sequence
:
number
;
interactivity
:
Interactivity
<
number
>
;
interactivity
:
Interactivity
<
number
>
;
}
>
}
>
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
...
@@ -110,10 +116,10 @@ export const addHandsInteractivityImpl: CaseReducer<
...
@@ -110,10 +116,10 @@ export const addHandsInteractivityImpl: CaseReducer<
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
if
(
hands
)
{
const
index
=
action
.
payload
.
index
;
const
sequence
=
action
.
payload
.
sequence
;
const
interactivity
=
action
.
payload
.
interactivity
;
const
interactivity
=
action
.
payload
.
interactivity
;
hands
.
cards
[
index
].
i
nteractivities
.
push
(
interactivity
);
hands
.
hands
[
sequence
].
idleI
nteractivities
.
push
(
interactivity
);
}
}
};
};
...
@@ -127,11 +133,13 @@ export const removeHandImpl: CaseReducer<
...
@@ -127,11 +133,13 @@ export const removeHandImpl: CaseReducer<
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
const
hands
=
judgeSelf
(
controler
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
if
(
hands
)
{
hands
.
cards
=
hands
.
cards
.
filter
((
_
,
idx
)
=>
idx
!=
sequence
);
hands
.
hands
=
hands
.
hands
.
filter
(
(
card
)
=>
card
.
location
.
sequence
!=
sequence
);
}
}
};
};
export
const
selectMeHands
=
(
state
:
RootState
)
=>
export
const
selectMeHands
=
(
state
:
RootState
)
=>
state
.
duel
.
meHands
||
{
car
ds
:
[]
};
state
.
duel
.
meHands
||
{
han
ds
:
[]
};
export
const
selectOpHands
=
(
state
:
RootState
)
=>
export
const
selectOpHands
=
(
state
:
RootState
)
=>
state
.
duel
.
opHands
||
{
car
ds
:
[]
};
state
.
duel
.
opHands
||
{
han
ds
:
[]
};
src/reducers/duel/magicSlice.ts
View file @
7ef855ab
import
{
judgeSelf
,
Magic
,
InteractType
}
from
"
./util
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
import
{
PayloadAction
,
PayloadAction
,
CaseReducer
,
CaseReducer
,
...
@@ -9,9 +9,10 @@ import { DuelState } from "./mod";
...
@@ -9,9 +9,10 @@ import { DuelState } from "./mod";
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
CardState
,
InteractType
}
from
"
./generic
"
;
export
interface
MagicState
{
export
interface
MagicState
{
magics
:
Magic
[];
magics
:
CardState
[];
}
}
// 初始化自己的魔法陷阱区状态
// 初始化自己的魔法陷阱区状态
...
@@ -23,19 +24,44 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
...
@@ -23,19 +24,44 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
const
magics
=
{
const
magics
=
{
magics
:
[
magics
:
[
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
0
,
sequence
:
0
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
1
,
sequence
:
1
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
2
,
sequence
:
2
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
3
,
sequence
:
3
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
4
,
sequence
:
4
,
}),
idleInteractivities
:
[],
},
},
],
],
};
};
...
@@ -47,7 +73,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
...
@@ -47,7 +73,7 @@ export const initMagicsImpl: CaseReducer<DuelState, PayloadAction<number>> = (
}
}
};
};
export
const
addMagicPlace
SelectAble
Impl
:
CaseReducer
<
export
const
addMagicPlace
Interactivities
Impl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
[
number
,
number
]
>
PayloadAction
<
[
number
,
number
]
>
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
...
@@ -57,8 +83,8 @@ export const addMagicPlaceSelectAbleImpl: CaseReducer<
...
@@ -57,8 +83,8 @@ export const addMagicPlaceSelectAbleImpl: CaseReducer<
const
magics
=
judgeSelf
(
controler
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
const
magics
=
judgeSelf
(
controler
,
state
)
?
state
.
meMagics
:
state
.
opMagics
;
if
(
magics
)
{
if
(
magics
)
{
for
(
const
magic
of
magics
.
magics
)
{
for
(
const
magic
of
magics
.
magics
)
{
if
(
magic
.
sequence
==
sequence
)
{
if
(
magic
.
location
.
sequence
==
sequence
)
{
magic
.
selectInfo
=
{
magic
.
placeInteractivities
=
{
interactType
:
InteractType
.
PLACE_SELECTABLE
,
interactType
:
InteractType
.
PLACE_SELECTABLE
,
response
:
{
response
:
{
controler
,
controler
,
...
@@ -71,7 +97,7 @@ export const addMagicPlaceSelectAbleImpl: CaseReducer<
...
@@ -71,7 +97,7 @@ export const addMagicPlaceSelectAbleImpl: CaseReducer<
}
}
};
};
export
const
clearMagic
SelectInfo
Impl
:
CaseReducer
<
export
const
clearMagic
PlaceInteractivities
Impl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
number
>
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
...
@@ -81,7 +107,7 @@ export const clearMagicSelectInfoImpl: CaseReducer<
...
@@ -81,7 +107,7 @@ export const clearMagicSelectInfoImpl: CaseReducer<
if
(
magics
)
{
if
(
magics
)
{
for
(
const
magic
of
magics
.
magics
)
{
for
(
const
magic
of
magics
.
magics
)
{
magic
.
selectInfo
=
undefined
;
magic
.
placeInteractivities
=
undefined
;
}
}
}
}
};
};
...
@@ -120,18 +146,18 @@ export const magicCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -120,18 +146,18 @@ export const magicCase = (builder: ActionReducerMapBuilder<DuelState>) => {
if
(
judgeSelf
(
controler
,
state
))
{
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meMagics
)
{
if
(
state
.
meMagics
)
{
for
(
const
magic
of
state
.
meMagics
.
magics
)
{
for
(
const
magic
of
state
.
meMagics
.
magics
)
{
if
(
magic
.
sequence
==
sequence
)
{
if
(
magic
.
location
.
sequence
==
sequence
)
{
magic
.
occupant
=
meta
;
magic
.
occupant
=
meta
;
magic
.
position
=
position
;
magic
.
location
.
position
=
position
;
}
}
}
}
}
}
}
else
{
}
else
{
if
(
state
.
opMagics
)
{
if
(
state
.
opMagics
)
{
for
(
const
magic
of
state
.
opMagics
.
magics
)
{
for
(
const
magic
of
state
.
opMagics
.
magics
)
{
if
(
magic
.
sequence
==
sequence
)
{
if
(
magic
.
location
.
sequence
==
sequence
)
{
magic
.
occupant
=
meta
;
magic
.
occupant
=
meta
;
magic
.
position
=
position
;
magic
.
location
.
position
=
position
;
}
}
}
}
}
}
...
@@ -145,7 +171,7 @@ export const magicCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -145,7 +171,7 @@ export const magicCase = (builder: ActionReducerMapBuilder<DuelState>) => {
if
(
judgeSelf
(
controler
,
state
))
{
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meMagics
)
{
if
(
state
.
meMagics
)
{
for
(
const
magic
of
state
.
meMagics
.
magics
)
{
for
(
const
magic
of
state
.
meMagics
.
magics
)
{
if
(
magic
.
sequence
==
sequence
)
{
if
(
magic
.
location
.
sequence
==
sequence
)
{
magic
.
occupant
=
meta
;
magic
.
occupant
=
meta
;
}
}
}
}
...
@@ -153,7 +179,7 @@ export const magicCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -153,7 +179,7 @@ export const magicCase = (builder: ActionReducerMapBuilder<DuelState>) => {
}
else
{
}
else
{
if
(
state
.
opMagics
)
{
if
(
state
.
opMagics
)
{
for
(
const
magic
of
state
.
opMagics
.
magics
)
{
for
(
const
magic
of
state
.
opMagics
.
magics
)
{
if
(
magic
.
sequence
==
sequence
)
{
if
(
magic
.
location
.
sequence
==
sequence
)
{
magic
.
occupant
=
meta
;
magic
.
occupant
=
meta
;
}
}
}
}
...
...
src/reducers/duel/mod.ts
View file @
7ef855ab
...
@@ -7,10 +7,10 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
...
@@ -7,10 +7,10 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
TimeLimit
,
updateTimeLimitImpl
}
from
"
./timeLimit
"
;
import
{
TimeLimit
,
updateTimeLimitImpl
}
from
"
./timeLimit
"
;
import
{
import
{
Hand
s
,
Hand
State
,
handsCase
,
handsCase
,
clearHandsInteractivityImpl
,
clearHandsI
dleI
nteractivityImpl
,
addHandsInteractivityImpl
,
addHandsI
dleI
nteractivityImpl
,
removeHandImpl
,
removeHandImpl
,
}
from
"
./handsSlice
"
;
}
from
"
./handsSlice
"
;
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
...
@@ -44,15 +44,15 @@ import {
...
@@ -44,15 +44,15 @@ import {
import
{
import
{
MonsterState
,
MonsterState
,
initMonstersImpl
,
initMonstersImpl
,
addMonsterPlace
SelectAble
Impl
,
addMonsterPlace
Interactivities
Impl
,
clearMonster
SelectInfo
Impl
,
clearMonster
PlaceInteractivities
Impl
,
monsterCase
,
monsterCase
,
}
from
"
./monstersSlice
"
;
}
from
"
./monstersSlice
"
;
import
{
import
{
MagicState
,
MagicState
,
initMagicsImpl
,
initMagicsImpl
,
addMagicPlace
SelectAble
Impl
,
addMagicPlace
Interactivities
Impl
,
clearMagic
SelectInfo
Impl
,
clearMagic
PlaceInteractivities
Impl
,
magicCase
,
magicCase
,
}
from
"
./magicSlice
"
;
}
from
"
./magicSlice
"
;
import
{
CemeteryState
,
initCemeteryImpl
,
cemeteryCase
}
from
"
./cemeretySlice
"
;
import
{
CemeteryState
,
initCemeteryImpl
,
cemeteryCase
}
from
"
./cemeretySlice
"
;
...
@@ -62,8 +62,8 @@ export interface DuelState {
...
@@ -62,8 +62,8 @@ export interface DuelState {
meInitInfo
?:
InitInfo
;
// 自己的初始状态
meInitInfo
?:
InitInfo
;
// 自己的初始状态
opInitInfo
?:
InitInfo
;
// 对手的初始状态
opInitInfo
?:
InitInfo
;
// 对手的初始状态
meHands
?:
Hand
s
;
// 自己的手牌
meHands
?:
Hand
State
;
// 自己的手牌
opHands
?:
Hand
s
;
// 对手的手牌
opHands
?:
Hand
State
;
// 对手的手牌
meMonsters
?:
MonsterState
;
// 自己的怪兽区状态
meMonsters
?:
MonsterState
;
// 自己的怪兽区状态
opMonsters
?:
MonsterState
;
// 对手的怪兽区状态
opMonsters
?:
MonsterState
;
// 对手的怪兽区状态
...
@@ -111,19 +111,19 @@ const duelSlice = createSlice({
...
@@ -111,19 +111,19 @@ const duelSlice = createSlice({
updateTimeLimit
:
updateTimeLimitImpl
,
updateTimeLimit
:
updateTimeLimitImpl
,
// 手牌相关`Reducer`
// 手牌相关`Reducer`
clearHandsI
nteractivity
:
clearHands
InteractivityImpl
,
clearHandsI
dleInteractivity
:
clearHandsIdle
InteractivityImpl
,
addHandsI
nteractivity
:
addHands
InteractivityImpl
,
addHandsI
dleInteractivity
:
addHandsIdle
InteractivityImpl
,
removeHand
:
removeHandImpl
,
removeHand
:
removeHandImpl
,
// 怪兽区相关`Reducer`
// 怪兽区相关`Reducer`
initMonsters
:
initMonstersImpl
,
initMonsters
:
initMonstersImpl
,
addMonsterPlace
SelectAble
:
addMonsterPlaceSelectAble
Impl
,
addMonsterPlace
Interactivities
:
addMonsterPlaceInteractivities
Impl
,
clearMonster
SelectInfo
:
clearMonsterSelectInfo
Impl
,
clearMonster
PlaceInteractivities
:
clearMonsterPlaceInteractivities
Impl
,
// 魔法陷阱区相关`Reducer`
// 魔法陷阱区相关`Reducer`
initMagics
:
initMagicsImpl
,
initMagics
:
initMagicsImpl
,
addMagicPlace
SelectAble
:
addMagicPlaceSelectAble
Impl
,
addMagicPlace
Interactivities
:
addMagicPlaceInteractivities
Impl
,
clearMagic
SelectInfo
:
clearMagicSelectInfo
Impl
,
clearMagic
PlaceInteractivities
:
clearMagicPlaceInteractivities
Impl
,
// 墓地相关`Reducer`
// 墓地相关`Reducer`
initCemetery
:
initCemeteryImpl
,
initCemetery
:
initCemeteryImpl
,
...
@@ -165,19 +165,19 @@ export const {
...
@@ -165,19 +165,19 @@ export const {
infoInit
,
infoInit
,
updateTurn
,
updateTurn
,
updatePhase
,
updatePhase
,
clearHandsInteractivity
,
clearHandsI
dleI
nteractivity
,
addHandsInteractivity
,
addHandsI
dleI
nteractivity
,
updateTimeLimit
,
updateTimeLimit
,
setCardModalIsOpen
,
setCardModalIsOpen
,
setCardModalText
,
setCardModalText
,
setCardModalImgUrl
,
setCardModalImgUrl
,
setCardModalInteractivies
,
setCardModalInteractivies
,
initMonsters
,
initMonsters
,
addMonsterPlace
SelectAble
,
addMonsterPlace
Interactivities
,
clearMonster
SelectInfo
,
clearMonster
PlaceInteractivities
,
initMagics
,
initMagics
,
addMagicPlace
SelectAble
,
addMagicPlace
Interactivities
,
clearMagic
SelectInfo
,
clearMagic
PlaceInteractivities
,
removeHand
,
removeHand
,
initCemetery
,
initCemetery
,
setCardListModalIsOpen
,
setCardListModalIsOpen
,
...
...
src/reducers/duel/monstersSlice.ts
View file @
7ef855ab
import
{
judgeSelf
,
Monster
,
InteractType
}
from
"
./util
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
import
{
PayloadAction
,
PayloadAction
,
CaseReducer
,
CaseReducer
,
...
@@ -9,9 +9,10 @@ import { DuelState } from "./mod";
...
@@ -9,9 +9,10 @@ import { DuelState } from "./mod";
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
fetchCard
}
from
"
../../api/cards
"
;
import
{
CardState
,
InteractType
}
from
"
./generic
"
;
export
interface
MonsterState
{
export
interface
MonsterState
{
monsters
:
Monster
[];
monsters
:
CardState
[];
}
}
// 初始化怪兽区状态
// 初始化怪兽区状态
...
@@ -23,19 +24,44 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
...
@@ -23,19 +24,44 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
const
monsters
=
{
const
monsters
=
{
monsters
:
[
monsters
:
[
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
0
,
sequence
:
0
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
1
,
sequence
:
1
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
2
,
sequence
:
2
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
3
,
sequence
:
3
,
}),
idleInteractivities
:
[],
},
},
{
{
location
:
new
ygopro
.
CardLocation
({
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
4
,
sequence
:
4
,
}),
idleInteractivities
:
[],
},
},
],
],
};
};
...
@@ -47,7 +73,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
...
@@ -47,7 +73,7 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
}
}
};
};
export
const
addMonsterPlace
SelectAble
Impl
:
CaseReducer
<
export
const
addMonsterPlace
Interactivities
Impl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
[
number
,
number
]
>
PayloadAction
<
[
number
,
number
]
>
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
...
@@ -59,8 +85,8 @@ export const addMonsterPlaceSelectAbleImpl: CaseReducer<
...
@@ -59,8 +85,8 @@ export const addMonsterPlaceSelectAbleImpl: CaseReducer<
:
state
.
opMonsters
;
:
state
.
opMonsters
;
if
(
monsters
)
{
if
(
monsters
)
{
for
(
const
monster
of
monsters
.
monsters
)
{
for
(
const
monster
of
monsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
if
(
monster
.
location
.
sequence
==
sequence
)
{
monster
.
selectInfo
=
{
monster
.
placeInteractivities
=
{
interactType
:
InteractType
.
PLACE_SELECTABLE
,
interactType
:
InteractType
.
PLACE_SELECTABLE
,
response
:
{
response
:
{
controler
,
controler
,
...
@@ -73,7 +99,7 @@ export const addMonsterPlaceSelectAbleImpl: CaseReducer<
...
@@ -73,7 +99,7 @@ export const addMonsterPlaceSelectAbleImpl: CaseReducer<
}
}
};
};
export
const
clearMonster
SelectInfo
Impl
:
CaseReducer
<
export
const
clearMonster
PlaceInteractivities
Impl
:
CaseReducer
<
DuelState
,
DuelState
,
PayloadAction
<
number
>
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
...
@@ -85,7 +111,7 @@ export const clearMonsterSelectInfoImpl: CaseReducer<
...
@@ -85,7 +111,7 @@ export const clearMonsterSelectInfoImpl: CaseReducer<
if
(
monsters
)
{
if
(
monsters
)
{
for
(
const
monster
of
monsters
.
monsters
)
{
for
(
const
monster
of
monsters
.
monsters
)
{
monster
.
selectInfo
=
undefined
;
monster
.
placeInteractivities
=
undefined
;
}
}
}
}
};
};
...
@@ -124,18 +150,18 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -124,18 +150,18 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
if
(
judgeSelf
(
controler
,
state
))
{
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meMonsters
)
{
if
(
state
.
meMonsters
)
{
for
(
const
monster
of
state
.
meMonsters
.
monsters
)
{
for
(
const
monster
of
state
.
meMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
if
(
monster
.
location
.
sequence
==
sequence
)
{
monster
.
occupant
=
meta
;
monster
.
occupant
=
meta
;
monster
.
position
=
position
;
monster
.
location
.
position
=
position
;
}
}
}
}
}
}
}
else
{
}
else
{
if
(
state
.
opMonsters
)
{
if
(
state
.
opMonsters
)
{
for
(
const
monster
of
state
.
opMonsters
.
monsters
)
{
for
(
const
monster
of
state
.
opMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
if
(
monster
.
location
.
sequence
==
sequence
)
{
monster
.
occupant
=
meta
;
monster
.
occupant
=
meta
;
monster
.
position
=
position
;
monster
.
location
.
position
=
position
;
}
}
}
}
}
}
...
@@ -149,7 +175,7 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -149,7 +175,7 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
if
(
judgeSelf
(
controler
,
state
))
{
if
(
judgeSelf
(
controler
,
state
))
{
if
(
state
.
meMonsters
)
{
if
(
state
.
meMonsters
)
{
for
(
const
monster
of
state
.
meMonsters
.
monsters
)
{
for
(
const
monster
of
state
.
meMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
if
(
monster
.
location
.
sequence
==
sequence
)
{
monster
.
occupant
=
meta
;
monster
.
occupant
=
meta
;
}
}
}
}
...
@@ -157,7 +183,7 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -157,7 +183,7 @@ export const monsterCase = (builder: ActionReducerMapBuilder<DuelState>) => {
}
else
{
}
else
{
if
(
state
.
opMonsters
)
{
if
(
state
.
opMonsters
)
{
for
(
const
monster
of
state
.
opMonsters
.
monsters
)
{
for
(
const
monster
of
state
.
opMonsters
.
monsters
)
{
if
(
monster
.
sequence
==
sequence
)
{
if
(
monster
.
location
.
sequence
==
sequence
)
{
monster
.
occupant
=
meta
;
monster
.
occupant
=
meta
;
}
}
}
}
...
...
src/reducers/duel/util.ts
View file @
7ef855ab
...
@@ -3,10 +3,8 @@
...
@@ -3,10 +3,8 @@
*
*
* */
* */
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
Draft
}
from
"
@reduxjs/toolkit
"
;
import
{
Draft
}
from
"
@reduxjs/toolkit
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
/*
/*
* 通过`player`和`selfType`判断是应该处理自己还是对手
* 通过`player`和`selfType`判断是应该处理自己还是对手
...
@@ -24,53 +22,3 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
...
@@ -24,53 +22,3 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
return
false
;
return
false
;
}
}
}
}
export
interface
Hand
{
meta
:
CardMeta
;
interactivities
:
Interactivity
<
number
>
[];
}
export
enum
InteractType
{
// 可普通召唤
SUMMON
=
1
,
// 可特殊召唤
SP_SUMMON
=
2
,
// 可改变表示形式
POS_CHANGE
=
3
,
// 可前场放置
MSET
=
4
,
// 可后场放置
SSET
=
5
,
// 可发动效果
ACTIVATE
=
6
,
// 可作为位置选择
PLACE_SELECTABLE
=
7
,
}
export
interface
Interactivity
<
T
>
{
interactType
:
InteractType
;
// 如果`interactType`是`ACTIVATE`,这个字段是对应的效果编号
activateIndex
?:
number
;
// 用户点击后,需要回传给服务端的`response`
response
:
T
;
}
export
interface
SlotState
{
sequence
:
number
;
occupant
?:
CardMeta
;
position
?:
ygopro
.
CardPosition
;
selectInfo
?:
Interactivity
<
{
controler
:
number
;
zone
:
ygopro
.
CardZone
;
sequence
:
number
;
}
>
;
}
export
type
Monster
=
SlotState
;
export
type
Magic
=
SlotState
;
export
interface
Cemetery
{
sequence
:
number
;
meta
:
CardMeta
;
}
src/service/duel/selectIdleCmd.ts
View file @
7ef855ab
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/
util
"
;
import
{
InteractType
}
from
"
../../reducers/duel/
generic
"
;
import
{
import
{
clearHandsInteractivity
,
clearHandsI
dleI
nteractivity
,
addHandsInteractivity
,
addHandsI
dleI
nteractivity
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
import
MsgSelectIdleCmd
=
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
;
...
@@ -12,7 +12,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
...
@@ -12,7 +12,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
const
cmds
=
selectIdleCmd
.
idle_cmds
;
const
cmds
=
selectIdleCmd
.
idle_cmds
;
// 先清掉之前的手牌互动性
// 先清掉之前的手牌互动性
dispatch
(
clearHandsInteractivity
(
player
));
dispatch
(
clearHandsI
dleI
nteractivity
(
player
));
for
(
let
cmd
of
cmds
)
{
for
(
let
cmd
of
cmds
)
{
let
interactType
;
let
interactType
;
...
@@ -50,9 +50,9 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
...
@@ -50,9 +50,9 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
if
(
interactType
===
InteractType
.
ACTIVATE
)
{
if
(
interactType
===
InteractType
.
ACTIVATE
)
{
// 发动效果会多一个字段
// 发动效果会多一个字段
dispatch
(
dispatch
(
addHandsInteractivity
({
addHandsI
dleI
nteractivity
({
player
,
player
,
index
:
card_info
.
sequence
,
sequence
:
card_info
.
sequence
,
interactivity
:
{
interactivity
:
{
interactType
,
interactType
,
activateIndex
:
data
.
effect_description
,
activateIndex
:
data
.
effect_description
,
...
@@ -62,9 +62,9 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
...
@@ -62,9 +62,9 @@ export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
);
);
}
else
if
(
interactType
)
{
}
else
if
(
interactType
)
{
dispatch
(
dispatch
(
addHandsInteractivity
({
addHandsI
dleI
nteractivity
({
player
,
player
,
index
:
card_info
.
sequence
,
sequence
:
card_info
.
sequence
,
interactivity
:
{
interactType
,
response
:
data
.
response
},
interactivity
:
{
interactType
,
response
:
data
.
response
},
})
})
);
);
...
...
src/service/duel/selectPlace.ts
View file @
7ef855ab
...
@@ -2,8 +2,8 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
...
@@ -2,8 +2,8 @@ import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
import
MsgSelectPlace
=
ygopro
.
StocGameMessage
.
MsgSelectPlace
;
import
{
import
{
addMonsterPlace
SelectAble
,
addMonsterPlace
Interactivities
,
addMagicPlace
SelectAble
,
addMagicPlace
Interactivities
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
export
default
(
selectPlace
:
MsgSelectPlace
,
dispatch
:
AppDispatch
)
=>
{
export
default
(
selectPlace
:
MsgSelectPlace
,
dispatch
:
AppDispatch
)
=>
{
...
@@ -16,12 +16,16 @@ export default (selectPlace: MsgSelectPlace, dispatch: AppDispatch) => {
...
@@ -16,12 +16,16 @@ export default (selectPlace: MsgSelectPlace, dispatch: AppDispatch) => {
for
(
const
place
of
selectPlace
.
places
)
{
for
(
const
place
of
selectPlace
.
places
)
{
switch
(
place
.
zone
)
{
switch
(
place
.
zone
)
{
case
ygopro
.
CardZone
.
MZONE
:
{
case
ygopro
.
CardZone
.
MZONE
:
{
dispatch
(
addMonsterPlaceSelectAble
([
place
.
controler
,
place
.
sequence
]));
dispatch
(
addMonsterPlaceInteractivities
([
place
.
controler
,
place
.
sequence
])
);
break
;
break
;
}
}
case
ygopro
.
CardZone
.
SZONE
:
{
case
ygopro
.
CardZone
.
SZONE
:
{
dispatch
(
addMagicPlaceSelectAble
([
place
.
controler
,
place
.
sequence
]));
dispatch
(
addMagicPlaceInteractivities
([
place
.
controler
,
place
.
sequence
])
);
break
;
break
;
}
}
...
...
src/ui/Duel/cardModal.tsx
View file @
7ef855ab
...
@@ -10,7 +10,7 @@ import {
...
@@ -10,7 +10,7 @@ import {
}
from
"
../../reducers/duel/modalSlice
"
;
}
from
"
../../reducers/duel/modalSlice
"
;
import
{
import
{
setCardModalIsOpen
,
setCardModalIsOpen
,
clearHandsInteractivity
,
clearHandsI
dleI
nteractivity
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
import
{
Modal
,
Card
,
Button
}
from
"
antd
"
;
import
{
Modal
,
Card
,
Button
}
from
"
antd
"
;
import
{
sendSelectIdleCmdResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
sendSelectIdleCmdResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
...
@@ -47,7 +47,7 @@ const CardModal = () => {
...
@@ -47,7 +47,7 @@ const CardModal = () => {
onClick=
{
()
=>
{
onClick=
{
()
=>
{
sendSelectIdleCmdResponse
(
interactive
.
response
);
sendSelectIdleCmdResponse
(
interactive
.
response
);
dispatch
(
setCardModalIsOpen
(
false
));
dispatch
(
setCardModalIsOpen
(
false
));
dispatch
(
clearHandsInteractivity
(
0
));
dispatch
(
clearHandsI
dleI
nteractivity
(
0
));
}
}
}
}
>
>
{
interactive
.
desc
}
{
interactive
.
desc
}
...
...
src/ui/Duel/cemetery.tsx
View file @
7ef855ab
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
C
emetery
}
from
"
../../reducers/duel/util
"
;
import
{
C
ardState
}
from
"
../../reducers/duel/generic
"
;
import
{
import
{
selectMeCemetery
,
selectMeCemetery
,
selectOpCemetery
,
selectOpCemetery
,
...
@@ -38,7 +38,7 @@ const Cemeteries = () => {
...
@@ -38,7 +38,7 @@ const Cemeteries = () => {
};
};
const
CCemetery
=
(
props
:
{
const
CCemetery
=
(
props
:
{
state
:
C
emetery
[];
state
:
C
ardState
[];
position
:
BABYLON
.
Vector3
;
position
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
})
=>
{
})
=>
{
...
@@ -52,9 +52,9 @@ const CCemetery = (props: {
...
@@ -52,9 +52,9 @@ const CCemetery = (props: {
setCardListModalInfo
(
setCardListModalInfo
(
props
.
state
.
map
((
cemetery
)
=>
{
props
.
state
.
map
((
cemetery
)
=>
{
return
{
return
{
name
:
cemetery
.
meta
.
text
.
name
,
name
:
cemetery
.
occupant
?
.
text
.
name
,
desc
:
cemetery
.
meta
.
text
.
desc
,
desc
:
cemetery
.
occupant
?
.
text
.
desc
,
imgUrl
:
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
cemetery
.
meta
.
id
}
.jpg`
,
imgUrl
:
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
cemetery
.
occupant
?
.
id
}.
jpg
`,
};
};
})
})
)
)
...
...
src/ui/Duel/hands.tsx
View file @
7ef855ab
...
@@ -2,7 +2,7 @@ import * as BABYLON from "@babylonjs/core";
...
@@ -2,7 +2,7 @@ import * as BABYLON from "@babylonjs/core";
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
selectMeHands
,
selectOpHands
}
from
"
../../reducers/duel/handsSlice
"
;
import
{
selectMeHands
,
selectOpHands
}
from
"
../../reducers/duel/handsSlice
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
Hand
}
from
"
../../reducers/duel/util
"
;
import
{
CardState
}
from
"
../../reducers/duel/generic
"
;
import
{
import
{
setCardModalImgUrl
,
setCardModalImgUrl
,
setCardModalIsOpen
,
setCardModalIsOpen
,
...
@@ -22,9 +22,9 @@ const handShape = CONFIG.HandShape();
...
@@ -22,9 +22,9 @@ const handShape = CONFIG.HandShape();
const
handRotation
=
CONFIG
.
HandRotation
();
const
handRotation
=
CONFIG
.
HandRotation
();
const
Hands
=
()
=>
{
const
Hands
=
()
=>
{
const
meHands
=
useAppSelector
(
selectMeHands
).
car
ds
;
const
meHands
=
useAppSelector
(
selectMeHands
).
han
ds
;
const
meHandPositions
=
handPositons
(
0
,
meHands
);
const
meHandPositions
=
handPositons
(
0
,
meHands
);
const
opHands
=
useAppSelector
(
selectOpHands
).
car
ds
;
const
opHands
=
useAppSelector
(
selectOpHands
).
han
ds
;
const
opHandPositions
=
handPositons
(
1
,
opHands
);
const
opHandPositions
=
handPositons
(
1
,
opHands
);
return
(
return
(
...
@@ -60,7 +60,7 @@ const Hands = () => {
...
@@ -60,7 +60,7 @@ const Hands = () => {
};
};
const
CHand
=
(
props
:
{
const
CHand
=
(
props
:
{
state
:
Hand
;
state
:
CardState
;
sequence
:
number
;
sequence
:
number
;
position
:
BABYLON
.
Vector3
;
position
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
...
@@ -108,15 +108,17 @@ const CHand = (props: {
...
@@ -108,15 +108,17 @@ const CHand = (props: {
useClick
(
useClick
(
()
=>
{
()
=>
{
dispatch
(
setCardModalText
([
state
.
meta
.
text
.
name
,
state
.
meta
.
text
.
desc
]));
dispatch
(
setCardModalText
([
state
.
occupant
?.
text
.
name
,
state
.
occupant
?.
text
.
desc
])
);
dispatch
(
dispatch
(
setCardModalImgUrl
(
setCardModalImgUrl
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
state
.
meta
.
id
}
.jpg`
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
state
.
occupant
?
.
id
}.
jpg
`
)
)
);
);
dispatch(
dispatch(
setCardModalInteractivies(
setCardModalInteractivies(
state
.
interactivities
.
map
((
interactive
)
=>
{
state.i
dleI
nteractivities.map((interactive) => {
return {
return {
desc: interactTypeToString(interactive.interactType),
desc: interactTypeToString(interactive.interactType),
response: interactive.response,
response: interactive.response,
...
@@ -141,19 +143,25 @@ const CHand = (props: {
...
@@ -141,19 +143,25 @@ const CHand = (props: {
position={spring.position}
position={spring.position}
rotation={props.rotation}
rotation={props.rotation}
enableEdgesRendering
enableEdgesRendering
edgesWidth=
{
state
.
interactivities
.
length
==
0
?
0
:
edgesWidth
}
edgesWidth={
state.idleInteractivities.length > 0 || state.placeInteractivities
? edgesWidth
: 0
}
edgesColor={edgesColor}
edgesColor={edgesColor}
>
>
<animated.standardMaterial
<animated.standardMaterial
name={`
hand
-
mat
-
$
{
props
.
sequence
}
`}
name={`
hand
-
mat
-
$
{
props
.
sequence
}
`}
diffuseTexture=
{
new
BABYLON
.
Texture
(
props
.
cover
(
state
.
meta
.
id
))
}
diffuseTexture={
new BABYLON.Texture(props.cover(state.occupant?.id || 0))
}
/>
/>
</animated.plane>
</animated.plane>
</animated.transformNode>
</animated.transformNode>
);
);
};
};
const
handPositons
=
(
player
:
number
,
hands
:
Hand
[])
=>
{
const handPositons = (player: number, hands:
CardState
[]) => {
const gap = groundShape.width / (hands.length - 1);
const gap = groundShape.width / (hands.length - 1);
const x = (idx: number) =>
const x = (idx: number) =>
player == 0 ? left + gap * idx : -left - gap * idx;
player == 0 ? left + gap * idx : -left - gap * idx;
...
...
src/ui/Duel/magics.tsx
View file @
7ef855ab
...
@@ -2,13 +2,13 @@ import * as BABYLON from "@babylonjs/core";
...
@@ -2,13 +2,13 @@ import * as BABYLON from "@babylonjs/core";
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
selectMeMagics
,
selectOpMagics
}
from
"
../../reducers/duel/magicSlice
"
;
import
{
selectMeMagics
,
selectOpMagics
}
from
"
../../reducers/duel/magicSlice
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
Magic
}
from
"
../../reducers/duel/util
"
;
import
{
CardState
}
from
"
../../reducers/duel/generic
"
;
import
{
store
}
from
"
../../store
"
;
import
{
store
}
from
"
../../store
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
useRef
}
from
"
react
"
;
import
{
useRef
}
from
"
react
"
;
import
{
sendSelectPlaceResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
sendSelectPlaceResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
import
{
clearMagic
SelectInfo
,
clearMagic
PlaceInteractivities
,
setCardModalImgUrl
,
setCardModalImgUrl
,
setCardModalIsOpen
,
setCardModalIsOpen
,
setCardModalText
,
setCardModalText
,
...
@@ -33,7 +33,7 @@ const Magics = () => {
...
@@ -33,7 +33,7 @@ const Magics = () => {
return
(
return
(
<
CMagic
<
CMagic
state=
{
magic
}
state=
{
magic
}
key=
{
magic
.
sequence
}
key=
{
magic
.
location
.
sequence
}
position=
{
position
}
position=
{
position
}
rotation=
{
CONFIG
.
CardSlotRotation
(
false
)
}
rotation=
{
CONFIG
.
CardSlotRotation
(
false
)
}
/>
/>
...
@@ -43,7 +43,7 @@ const Magics = () => {
...
@@ -43,7 +43,7 @@ const Magics = () => {
return
(
return
(
<
CMagic
<
CMagic
state=
{
magic
}
state=
{
magic
}
key=
{
magic
.
sequence
}
key=
{
magic
.
location
.
sequence
}
position=
{
position
}
position=
{
position
}
rotation=
{
CONFIG
.
CardSlotRotation
(
true
)
}
rotation=
{
CONFIG
.
CardSlotRotation
(
true
)
}
/>
/>
...
@@ -54,26 +54,26 @@ const Magics = () => {
...
@@ -54,26 +54,26 @@ const Magics = () => {
};
};
const
CMagic
=
(
props
:
{
const
CMagic
=
(
props
:
{
state
:
Magic
;
state
:
CardState
;
position
:
BABYLON
.
Vector3
;
position
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
})
=>
{
})
=>
{
const
state
=
props
.
state
;
const
state
=
props
.
state
;
const
planeRef
=
useRef
(
null
);
const
planeRef
=
useRef
(
null
);
const
faceDown
=
const
faceDown
=
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN
||
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN
||
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
||
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
||
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
;
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
;
const
edgesWidth
=
2.0
;
const
edgesWidth
=
2.0
;
const
edgesColor
=
BABYLON
.
Color4
.
FromColor3
(
BABYLON
.
Color3
.
Yellow
());
const
edgesColor
=
BABYLON
.
Color4
.
FromColor3
(
BABYLON
.
Color3
.
Yellow
());
const
dispatch
=
store
.
dispatch
;
const
dispatch
=
store
.
dispatch
;
useClick
(
useClick
(
(
_event
)
=>
{
(
_event
)
=>
{
if
(
state
.
selectInfo
)
{
if
(
state
.
placeInteractivities
)
{
sendSelectPlaceResponse
(
state
.
selectInfo
.
response
);
sendSelectPlaceResponse
(
state
.
placeInteractivities
.
response
);
dispatch
(
clearMagic
SelectInfo
(
0
));
dispatch
(
clearMagic
PlaceInteractivities
(
0
));
dispatch
(
clearMagic
SelectInfo
(
1
));
dispatch
(
clearMagic
PlaceInteractivities
(
1
));
}
else
if
(
state
.
occupant
)
{
}
else
if
(
state
.
occupant
)
{
dispatch
(
dispatch
(
setCardModalText
([
state
.
occupant
.
text
.
name
,
state
.
occupant
.
text
.
desc
])
setCardModalText
([
state
.
occupant
.
text
.
name
,
state
.
occupant
.
text
.
desc
])
...
@@ -92,18 +92,22 @@ const CMagic = (props: {
...
@@ -92,18 +92,22 @@ const CMagic = (props: {
return
(
return
(
<
plane
<
plane
name=
{
`magic-${state.sequence}`
}
name=
{
`magic-${state.
location.
sequence}`
}
ref=
{
planeRef
}
ref=
{
planeRef
}
width=
{
shape
.
width
}
width=
{
shape
.
width
}
height=
{
shape
.
height
}
height=
{
shape
.
height
}
position=
{
props
.
position
}
position=
{
props
.
position
}
rotation=
{
props
.
rotation
}
rotation=
{
props
.
rotation
}
enableEdgesRendering
enableEdgesRendering
edgesWidth=
{
state
.
selectInfo
?
edgesWidth
:
0
}
edgesWidth=
{
state
.
placeInteractivities
||
state
.
idleInteractivities
.
length
>
0
?
edgesWidth
:
0
}
edgesColor=
{
edgesColor
}
edgesColor=
{
edgesColor
}
>
>
<
standardMaterial
<
standardMaterial
name=
{
`magic-mat-${props.state.sequence}`
}
name=
{
`magic-mat-${props.state.
location.
sequence}`
}
diffuseTexture=
{
diffuseTexture=
{
state
.
occupant
state
.
occupant
?
faceDown
?
faceDown
...
@@ -121,13 +125,15 @@ const CMagic = (props: {
...
@@ -121,13 +125,15 @@ const CMagic = (props: {
);
);
};
};
const
magicPositions
=
(
player
:
number
,
magics
:
Magic
[])
=>
{
const
magicPositions
=
(
player
:
number
,
magics
:
CardState
[])
=>
{
const
x
=
(
sequence
:
number
)
=>
const
x
=
(
sequence
:
number
)
=>
player
==
0
?
left
+
gap
*
sequence
:
-
left
-
gap
*
sequence
;
player
==
0
?
left
+
gap
*
sequence
:
-
left
-
gap
*
sequence
;
const
y
=
shape
.
depth
/
2
+
CONFIG
.
Floating
;
const
y
=
shape
.
depth
/
2
+
CONFIG
.
Floating
;
const
z
=
player
==
0
?
-
2.6
:
2.6
;
const
z
=
player
==
0
?
-
2.6
:
2.6
;
return
magics
.
map
((
magic
)
=>
new
BABYLON
.
Vector3
(
x
(
magic
.
sequence
),
y
,
z
));
return
magics
.
map
(
(
magic
)
=>
new
BABYLON
.
Vector3
(
x
(
magic
.
location
.
sequence
),
y
,
z
)
);
};
};
export
default
Magics
;
export
default
Magics
;
src/ui/Duel/monsters.tsx
View file @
7ef855ab
...
@@ -2,12 +2,12 @@ import * as BABYLON from "@babylonjs/core";
...
@@ -2,12 +2,12 @@ import * as BABYLON from "@babylonjs/core";
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
store
}
from
"
../../store
"
;
import
{
store
}
from
"
../../store
"
;
import
{
Monster
}
from
"
../../reducers/duel/util
"
;
import
{
CardState
}
from
"
../../reducers/duel/generic
"
;
import
"
react-babylonjs
"
;
import
"
react-babylonjs
"
;
import
{
useRef
}
from
"
react
"
;
import
{
useRef
}
from
"
react
"
;
import
{
sendSelectPlaceResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
sendSelectPlaceResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
import
{
clearMonster
SelectInfo
,
clearMonster
PlaceInteractivities
,
setCardModalImgUrl
,
setCardModalImgUrl
,
setCardModalInteractivies
,
setCardModalInteractivies
,
setCardModalIsOpen
,
setCardModalIsOpen
,
...
@@ -62,7 +62,7 @@ const Monsters = () => {
...
@@ -62,7 +62,7 @@ const Monsters = () => {
};
};
const
CommonMonster
=
(
props
:
{
const
CommonMonster
=
(
props
:
{
state
:
Monster
;
state
:
CardState
;
position
:
BABYLON
.
Vector3
;
position
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
deffenseRotation
:
BABYLON
.
Vector3
;
deffenseRotation
:
BABYLON
.
Vector3
;
...
@@ -70,9 +70,9 @@ const CommonMonster = (props: {
...
@@ -70,9 +70,9 @@ const CommonMonster = (props: {
const
planeRef
=
useRef
(
null
);
const
planeRef
=
useRef
(
null
);
const
rotation
=
const
rotation
=
props
.
state
.
position
===
ygopro
.
CardPosition
.
DEFENSE
||
props
.
state
.
location
.
position
===
ygopro
.
CardPosition
.
DEFENSE
||
props
.
state
.
position
===
ygopro
.
CardPosition
.
FACEUP_DEFENSE
||
props
.
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEUP_DEFENSE
||
props
.
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
props
.
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
?
props
.
deffenseRotation
?
props
.
deffenseRotation
:
props
.
rotation
;
:
props
.
rotation
;
const
edgesWidth
=
2.0
;
const
edgesWidth
=
2.0
;
...
@@ -80,16 +80,16 @@ const CommonMonster = (props: {
...
@@ -80,16 +80,16 @@ const CommonMonster = (props: {
const
dispatch
=
store
.
dispatch
;
const
dispatch
=
store
.
dispatch
;
const
faceDown
=
const
faceDown
=
props
.
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
||
props
.
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
||
props
.
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
||
props
.
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
||
props
.
state
.
position
===
ygopro
.
CardPosition
.
FACEDOWN
;
props
.
state
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN
;
useClick
(
useClick
(
(
_event
)
=>
{
(
_event
)
=>
{
if
(
props
.
state
.
selectInfo
)
{
if
(
props
.
state
.
placeInteractivities
)
{
sendSelectPlaceResponse
(
props
.
state
.
selectInfo
.
response
);
sendSelectPlaceResponse
(
props
.
state
.
placeInteractivities
.
response
);
dispatch
(
clearMonster
SelectInfo
(
0
));
dispatch
(
clearMonster
PlaceInteractivities
(
0
));
dispatch
(
clearMonster
SelectInfo
(
1
));
dispatch
(
clearMonster
PlaceInteractivities
(
1
));
}
else
if
(
props
.
state
.
occupant
)
{
}
else
if
(
props
.
state
.
occupant
)
{
dispatch
(
dispatch
(
setCardModalText
([
setCardModalText
([
...
@@ -112,18 +112,23 @@ const CommonMonster = (props: {
...
@@ -112,18 +112,23 @@ const CommonMonster = (props: {
return
(
return
(
<
plane
<
plane
name=
{
`monster-${props.state.
selectInfo
}`
}
name=
{
`monster-${props.state.
location.sequence
}`
}
ref=
{
planeRef
}
ref=
{
planeRef
}
width=
{
shape
.
width
}
width=
{
shape
.
width
}
height=
{
shape
.
height
}
height=
{
shape
.
height
}
position=
{
props
.
position
}
position=
{
props
.
position
}
rotation=
{
rotation
}
rotation=
{
rotation
}
enableEdgesRendering
enableEdgesRendering
edgesWidth=
{
props
.
state
.
selectInfo
?
edgesWidth
:
0
}
edgesWidth=
{
props
.
state
.
placeInteractivities
||
props
.
state
.
idleInteractivities
.
length
>
0
?
edgesWidth
:
0
}
edgesColor=
{
edgesColor
}
edgesColor=
{
edgesColor
}
>
>
<
standardMaterial
<
standardMaterial
name=
{
`monster-mat-${props.state.sequence}`
}
name=
{
`monster-mat-${props.state.
location.
sequence}`
}
diffuseTexture=
{
diffuseTexture=
{
props
.
state
.
occupant
props
.
state
.
occupant
?
faceDown
?
faceDown
...
@@ -171,14 +176,14 @@ const ExtraMonsters = () => {
...
@@ -171,14 +176,14 @@ const ExtraMonsters = () => {
);
);
};
};
const
monsterPositions
=
(
player
:
number
,
monsters
:
Monster
[])
=>
{
const
monsterPositions
=
(
player
:
number
,
monsters
:
CardState
[])
=>
{
const
x
=
(
sequence
:
number
)
=>
const
x
=
(
sequence
:
number
)
=>
player
==
0
?
left
+
gap
*
sequence
:
-
left
-
gap
*
sequence
;
player
==
0
?
left
+
gap
*
sequence
:
-
left
-
gap
*
sequence
;
const
y
=
shape
.
depth
/
2
+
CONFIG
.
Floating
;
const
y
=
shape
.
depth
/
2
+
CONFIG
.
Floating
;
const
z
=
player
==
0
?
-
1.35
:
1.35
;
const
z
=
player
==
0
?
-
1.35
:
1.35
;
return
monsters
.
map
(
return
monsters
.
map
(
(
monster
)
=>
new
BABYLON
.
Vector3
(
x
(
monster
.
sequence
),
y
,
z
)
(
monster
)
=>
new
BABYLON
.
Vector3
(
x
(
monster
.
location
.
sequence
),
y
,
z
)
);
);
};
};
...
...
src/ui/Duel/util.ts
View file @
7ef855ab
import
{
InteractType
}
from
"
../../reducers/duel/
util
"
;
import
{
InteractType
}
from
"
../../reducers/duel/
generic
"
;
export
function
zip
<
S1
,
S2
>
(
export
function
zip
<
S1
,
S2
>
(
firstCollection
:
Array
<
S1
>
,
firstCollection
:
Array
<
S1
>
,
...
...
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