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
9c3989e3
Commit
9c3989e3
authored
Jan 11, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/generic' into 'main'
Optimize/generic See merge request
!70
parents
20c8ba1a
cc4f29ba
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
720 additions
and
220 deletions
+720
-220
src/reducers/duel/cemeretySlice.ts
src/reducers/duel/cemeretySlice.ts
+21
-11
src/reducers/duel/generic.ts
src/reducers/duel/generic.ts
+44
-0
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
+22
-22
src/reducers/duel/modal/cardListModalSlice.ts
src/reducers/duel/modal/cardListModalSlice.ts
+26
-0
src/reducers/duel/modal/cardModalSlice.ts
src/reducers/duel/modal/cardModalSlice.ts
+50
-0
src/reducers/duel/modal/checkCardModalSlice.ts
src/reducers/duel/modal/checkCardModalSlice.ts
+152
-0
src/reducers/duel/modal/mod.ts
src/reducers/duel/modal/mod.ts
+62
-0
src/reducers/duel/modal/optionModalSlice.ts
src/reducers/duel/modal/optionModalSlice.ts
+46
-0
src/reducers/duel/modal/positionModalSlice.ts
src/reducers/duel/modal/positionModalSlice.ts
+28
-0
src/reducers/duel/modal/yesNoModalSlice.ts
src/reducers/duel/modal/yesNoModalSlice.ts
+51
-0
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/selectCard.ts
src/service/duel/selectCard.ts
+1
-1
src/service/duel/selectChain.ts
src/service/duel/selectChain.ts
+1
-1
src/service/duel/selectEffectYn.ts
src/service/duel/selectEffectYn.ts
+1
-1
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+8
-8
src/service/duel/selectOption.ts
src/service/duel/selectOption.ts
+1
-1
src/service/duel/selectPlace.ts
src/service/duel/selectPlace.ts
+8
-4
src/ui/Duel/cardListModal.tsx
src/ui/Duel/cardListModal.tsx
+1
-1
src/ui/Duel/cardModal.tsx
src/ui/Duel/cardModal.tsx
+3
-3
src/ui/Duel/cemetery.tsx
src/ui/Duel/cemetery.tsx
+5
-5
src/ui/Duel/checkCardModal.tsx
src/ui/Duel/checkCardModal.tsx
+1
-1
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/optionModal.tsx
src/ui/Duel/optionModal.tsx
+1
-1
src/ui/Duel/positionModal.tsx
src/ui/Duel/positionModal.tsx
+1
-1
src/ui/Duel/util.ts
src/ui/Duel/util.ts
+1
-1
src/ui/Duel/yesNoModal.tsx
src/ui/Duel/yesNoModal.tsx
+1
-1
No files found.
src/reducers/duel/cemeretySlice.ts
View file @
9c3989e3
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
:
{
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
0 → 100644
View file @
9c3989e3
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
export
interface
CardState
{
occupant
?:
CardMeta
;
// 占据此位置的卡牌元信息
location
:
{
controler
:
number
;
location
?:
number
;
sequence
:
number
;
position
?:
ygopro
.
CardPosition
;
overlay_sequence
?:
number
;
};
// 位置信息
idleInteractivities
:
Interactivity
<
number
>
[];
// IDLE状态下的互动信息
placeInteractivities
?:
Interactivity
<
{
controler
:
number
;
zone
:
ygopro
.
CardZone
;
sequence
:
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
;
}
src/reducers/duel/handsSlice.ts
View file @
9c3989e3
...
@@ -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
:
{
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 @
9c3989e3
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
:
[
{
{
sequence
:
0
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
0
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
1
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
1
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
2
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
2
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
3
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
sequence
:
3
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
4
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
SZONE
,
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 @
9c3989e3
...
@@ -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
"
;
...
@@ -40,19 +40,19 @@ import {
...
@@ -40,19 +40,19 @@ import {
setOptionModalIsOpenImpl
,
setOptionModalIsOpenImpl
,
resetOptionModalImpl
,
resetOptionModalImpl
,
optionModalCase
,
optionModalCase
,
}
from
"
./modal
Slice
"
;
}
from
"
./modal
/mod
"
;
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/modal/cardListModalSlice.ts
0 → 100644
View file @
9c3989e3
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
RootState
}
from
"
../../../store
"
;
// 更新卡牌列表弹窗打开状态
export
const
setCardListModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardListModal
.
isOpen
=
action
.
payload
;
};
// 更新卡牌列表数据
export
const
setCardListModalInfoImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
}[]
>
>
=
(
state
,
action
)
=>
{
const
list
=
action
.
payload
;
state
.
modalState
.
cardListModal
.
list
=
list
;
};
export
const
selectCardListModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardListModal
.
isOpen
;
export
const
selectCardListModalInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardListModal
.
list
;
src/reducers/duel/modal/cardModalSlice.ts
0 → 100644
View file @
9c3989e3
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
RootState
}
from
"
../../../store
"
;
// 更新卡牌弹窗打开状态
export
const
setCardModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
isOpen
=
action
.
payload
;
};
// 更新卡牌弹窗文本
export
const
setCardModalTextImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
[
string
?,
string
?]
>
>
=
(
state
,
action
)
=>
{
const
name
=
action
.
payload
[
0
];
const
desc
=
action
.
payload
[
1
];
state
.
modalState
.
cardModal
.
name
=
name
;
state
.
modalState
.
cardModal
.
desc
=
desc
;
};
// 更新卡牌弹窗图片Url
export
const
setCardModalImgUrlImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
string
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
imgUrl
=
action
.
payload
;
};
// 更新卡牌弹窗互动选项
export
const
setCardModalInteractiviesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
desc
:
string
;
response
:
number
}[]
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
interactivies
=
action
.
payload
;
};
export
const
selectCardModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
isOpen
;
export
const
selectCardModalName
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
name
;
export
const
selectCardModalDesc
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
desc
;
export
const
selectCardModalImgUrl
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
imgUrl
;
export
const
selectCardModalInteractivies
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
interactivies
;
src/reducers/duel/modalSlice.ts
→
src/reducers/duel/modal
/checkCardModal
Slice.ts
View file @
9c3989e3
...
@@ -4,120 +4,10 @@ import {
...
@@ -4,120 +4,10 @@ import {
createAsyncThunk
,
createAsyncThunk
,
ActionReducerMapBuilder
,
ActionReducerMapBuilder
,
}
from
"
@reduxjs/toolkit
"
;
}
from
"
@reduxjs/toolkit
"
;
import
{
CardMeta
,
fetchCard
,
getCardStr
}
from
"
../../api/cards
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
fetchStrings
}
from
"
../../api/strings
"
;
import
{
judgeSelf
}
from
"
../util
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
,
getCardStr
}
from
"
../../../api/cards
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
judgeSelf
}
from
"
./util
"
;
export
interface
ModalState
{
// 卡牌弹窗
cardModal
:
{
isOpen
:
boolean
;
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
;
interactivies
:
{
desc
:
string
;
response
:
number
}[];
};
// 卡牌列表弹窗
cardListModal
:
{
isOpen
:
boolean
;
list
:
{
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
;
}[];
};
// 卡牌选择弹窗
checkCardModal
:
{
isOpen
:
boolean
;
onSubmit
?:
string
;
selectMin
?:
number
;
selectMax
?:
number
;
cancelAble
:
boolean
;
cancelResponse
?:
number
;
tags
:
{
tagName
:
string
;
options
:
{
code
:
number
;
name
?:
string
;
desc
?:
string
;
effectDesc
?:
string
;
response
:
number
;
}[];
}[];
};
// Yes or No弹窗
yesNoModal
:
{
isOpen
:
boolean
;
msg
?:
string
;
};
// 表示形式选择弹窗
positionModal
:
{
isOpen
:
boolean
;
positions
:
ygopro
.
CardPosition
[];
};
// 选项选择弹窗
optionModal
:
{
isOpen
:
boolean
;
options
:
{
msg
:
string
;
response
:
number
}[];
};
}
// 更新卡牌弹窗打开状态
export
const
setCardModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
isOpen
=
action
.
payload
;
};
// 更新卡牌弹窗文本
export
const
setCardModalTextImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
[
string
?,
string
?]
>
>
=
(
state
,
action
)
=>
{
const
name
=
action
.
payload
[
0
];
const
desc
=
action
.
payload
[
1
];
state
.
modalState
.
cardModal
.
name
=
name
;
state
.
modalState
.
cardModal
.
desc
=
desc
;
};
// 更新卡牌弹窗图片Url
export
const
setCardModalImgUrlImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
string
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
imgUrl
=
action
.
payload
;
};
// 更新卡牌弹窗互动选项
export
const
setCardModalInteractiviesImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
desc
:
string
;
response
:
number
}[]
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardModal
.
interactivies
=
action
.
payload
;
};
// 更新卡牌列表弹窗打开状态
export
const
setCardListModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
cardListModal
.
isOpen
=
action
.
payload
;
};
// 更新卡牌列表数据
export
const
setCardListModalInfoImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
}[]
>
>
=
(
state
,
action
)
=>
{
const
list
=
action
.
payload
;
state
.
modalState
.
cardListModal
.
list
=
list
;
};
// 更新卡牌选择弹窗打开状态
// 更新卡牌选择弹窗打开状态
export
const
setCheckCardModalIsOpenImpl
:
CaseReducer
<
export
const
setCheckCardModalIsOpenImpl
:
CaseReducer
<
...
@@ -244,106 +134,6 @@ export const resetCheckCardModalImpl: CaseReducer<DuelState> = (state) => {
...
@@ -244,106 +134,6 @@ export const resetCheckCardModalImpl: CaseReducer<DuelState> = (state) => {
state
.
modalState
.
checkCardModal
.
tags
=
[];
state
.
modalState
.
checkCardModal
.
tags
=
[];
};
};
// 更新YesNo弹窗是否打开状态
export
const
setYesNoModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
yesNoModal
.
isOpen
=
action
.
payload
;
};
// 设置YesNo弹窗展示内容
export
const
fetchYesNoMeta
=
createAsyncThunk
(
"
duel/fetchYesNoMeta
"
,
async
(
param
:
{
code
:
number
;
location
:
ygopro
.
CardLocation
;
descCode
:
number
;
textGenerator
:
(
desc
:
string
,
cardMeta
:
CardMeta
,
cardLocation
:
ygopro
.
CardLocation
)
=>
string
;
})
=>
{
const
desc
=
await
fetchStrings
(
"
!system
"
,
param
.
descCode
);
const
meta
=
await
fetchCard
(
param
.
code
);
// TODO: 国际化文案
return
param
.
textGenerator
(
desc
,
meta
,
param
.
location
);
}
);
export
const
YesNoModalCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchYesNoMeta
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
modalState
.
yesNoModal
.
msg
=
action
.
payload
;
});
};
export
const
setPositionModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
positionModal
.
isOpen
=
action
.
payload
;
};
export
const
setPositionModalPositionsImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
ygopro
.
CardPosition
[]
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
positionModal
.
positions
=
action
.
payload
;
};
export
const
setOptionModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
optionModal
.
isOpen
=
action
.
payload
;
};
export
const
resetOptionModalImpl
:
CaseReducer
<
DuelState
>
=
(
state
)
=>
{
state
.
modalState
.
optionModal
.
options
=
[];
};
export
const
resetPositionModalImpl
:
CaseReducer
<
DuelState
>
=
(
state
)
=>
{
state
.
modalState
.
positionModal
.
isOpen
=
false
;
state
.
modalState
.
positionModal
.
positions
=
[];
};
// 增加选项
export
const
fetchOptionMeta
=
createAsyncThunk
(
"
duel/fetchOptionMeta
"
,
async
(
param
:
{
code
:
number
;
response
:
number
})
=>
{
const
meta
=
await
fetchCard
(
param
.
code
>>
4
);
const
msg
=
getCardStr
(
meta
,
param
.
code
&
0xf
)
||
"
[?]
"
;
const
response
=
{
msg
,
response
:
param
.
response
};
return
response
;
}
);
export
const
optionModalCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchOptionMeta
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
modalState
.
optionModal
.
options
.
push
(
action
.
payload
);
});
};
export
const
selectCardModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
isOpen
;
export
const
selectCardModalName
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
name
;
export
const
selectCardModalDesc
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
desc
;
export
const
selectCardModalImgUrl
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
imgUrl
;
export
const
selectCardModalInteractivies
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardModal
.
interactivies
;
export
const
selectCardListModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardListModal
.
isOpen
;
export
const
selectCardListModalInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
cardListModal
.
list
;
export
const
selectCheckCardModalIsOpen
=
(
state
:
RootState
)
=>
export
const
selectCheckCardModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
checkCardModal
.
isOpen
;
state
.
duel
.
modalState
.
checkCardModal
.
isOpen
;
export
const
selectCheckCardModalMinMax
=
(
state
:
RootState
)
=>
{
export
const
selectCheckCardModalMinMax
=
(
state
:
RootState
)
=>
{
...
@@ -360,15 +150,3 @@ export const selectCheckCardModalCancelAble = (state: RootState) =>
...
@@ -360,15 +150,3 @@ export const selectCheckCardModalCancelAble = (state: RootState) =>
state
.
duel
.
modalState
.
checkCardModal
.
cancelAble
;
state
.
duel
.
modalState
.
checkCardModal
.
cancelAble
;
export
const
selectCheckCardModalCacnelResponse
=
(
state
:
RootState
)
=>
export
const
selectCheckCardModalCacnelResponse
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
checkCardModal
.
cancelResponse
;
state
.
duel
.
modalState
.
checkCardModal
.
cancelResponse
;
export
const
selectYesNoModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
yesNoModal
.
isOpen
;
export
const
selectYesNOModalMsg
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
yesNoModal
.
msg
;
export
const
selectPositionModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
positionModal
.
isOpen
;
export
const
selectPositionModalPositions
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
positionModal
.
positions
;
export
const
selectOptionModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
optionModal
.
isOpen
;
export
const
selectOptionModalOptions
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
optionModal
.
options
;
src/reducers/duel/modal/mod.ts
0 → 100644
View file @
9c3989e3
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
export
interface
ModalState
{
// 卡牌弹窗
cardModal
:
{
isOpen
:
boolean
;
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
;
interactivies
:
{
desc
:
string
;
response
:
number
}[];
};
// 卡牌列表弹窗
cardListModal
:
{
isOpen
:
boolean
;
list
:
{
name
?:
string
;
desc
?:
string
;
imgUrl
?:
string
;
}[];
};
// 卡牌选择弹窗
checkCardModal
:
{
isOpen
:
boolean
;
onSubmit
?:
string
;
selectMin
?:
number
;
selectMax
?:
number
;
cancelAble
:
boolean
;
cancelResponse
?:
number
;
tags
:
{
tagName
:
string
;
options
:
{
code
:
number
;
name
?:
string
;
desc
?:
string
;
effectDesc
?:
string
;
response
:
number
;
}[];
}[];
};
// Yes or No弹窗
yesNoModal
:
{
isOpen
:
boolean
;
msg
?:
string
;
};
// 表示形式选择弹窗
positionModal
:
{
isOpen
:
boolean
;
positions
:
ygopro
.
CardPosition
[];
};
// 选项选择弹窗
optionModal
:
{
isOpen
:
boolean
;
options
:
{
msg
:
string
;
response
:
number
}[];
};
}
export
*
from
"
./cardModalSlice
"
;
export
*
from
"
./cardListModalSlice
"
;
export
*
from
"
./checkCardModalSlice
"
;
export
*
from
"
./yesNoModalSlice
"
;
export
*
from
"
./positionModalSlice
"
;
export
*
from
"
./optionModalSlice
"
;
src/reducers/duel/modal/optionModalSlice.ts
0 → 100644
View file @
9c3989e3
import
{
PayloadAction
,
CaseReducer
,
createAsyncThunk
,
ActionReducerMapBuilder
,
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
fetchCard
,
getCardStr
}
from
"
../../../api/cards
"
;
import
{
RootState
}
from
"
../../../store
"
;
export
const
setOptionModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
optionModal
.
isOpen
=
action
.
payload
;
};
export
const
resetOptionModalImpl
:
CaseReducer
<
DuelState
>
=
(
state
)
=>
{
state
.
modalState
.
optionModal
.
options
=
[];
};
// 增加选项
export
const
fetchOptionMeta
=
createAsyncThunk
(
"
duel/fetchOptionMeta
"
,
async
(
param
:
{
code
:
number
;
response
:
number
})
=>
{
const
meta
=
await
fetchCard
(
param
.
code
>>
4
);
const
msg
=
getCardStr
(
meta
,
param
.
code
&
0xf
)
||
"
[?]
"
;
const
response
=
{
msg
,
response
:
param
.
response
};
return
response
;
}
);
export
const
optionModalCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchOptionMeta
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
modalState
.
optionModal
.
options
.
push
(
action
.
payload
);
});
};
export
const
selectOptionModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
optionModal
.
isOpen
;
export
const
selectOptionModalOptions
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
optionModal
.
options
;
src/reducers/duel/modal/positionModalSlice.ts
0 → 100644
View file @
9c3989e3
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
DuelState
}
from
"
../mod
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
export
const
setPositionModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
positionModal
.
isOpen
=
action
.
payload
;
};
export
const
setPositionModalPositionsImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
ygopro
.
CardPosition
[]
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
positionModal
.
positions
=
action
.
payload
;
};
export
const
resetPositionModalImpl
:
CaseReducer
<
DuelState
>
=
(
state
)
=>
{
state
.
modalState
.
positionModal
.
isOpen
=
false
;
state
.
modalState
.
positionModal
.
positions
=
[];
};
export
const
selectPositionModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
positionModal
.
isOpen
;
export
const
selectPositionModalPositions
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
positionModal
.
positions
;
src/reducers/duel/modal/yesNoModalSlice.ts
0 → 100644
View file @
9c3989e3
import
{
PayloadAction
,
CaseReducer
,
createAsyncThunk
,
ActionReducerMapBuilder
,
}
from
"
@reduxjs/toolkit
"
;
import
{
CardMeta
,
fetchCard
}
from
"
../../../api/cards
"
;
import
{
ygopro
}
from
"
../../../api/ocgcore/idl/ocgcore
"
;
import
{
fetchStrings
}
from
"
../../../api/strings
"
;
import
{
RootState
}
from
"
../../../store
"
;
import
{
DuelState
}
from
"
../mod
"
;
// 更新YesNo弹窗是否打开状态
export
const
setYesNoModalIsOpenImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
boolean
>
>
=
(
state
,
action
)
=>
{
state
.
modalState
.
yesNoModal
.
isOpen
=
action
.
payload
;
};
// 设置YesNo弹窗展示内容
export
const
fetchYesNoMeta
=
createAsyncThunk
(
"
duel/fetchYesNoMeta
"
,
async
(
param
:
{
code
:
number
;
location
:
ygopro
.
CardLocation
;
descCode
:
number
;
textGenerator
:
(
desc
:
string
,
cardMeta
:
CardMeta
,
cardLocation
:
ygopro
.
CardLocation
)
=>
string
;
})
=>
{
const
desc
=
await
fetchStrings
(
"
!system
"
,
param
.
descCode
);
const
meta
=
await
fetchCard
(
param
.
code
);
// TODO: 国际化文案
return
param
.
textGenerator
(
desc
,
meta
,
param
.
location
);
}
);
export
const
YesNoModalCase
=
(
builder
:
ActionReducerMapBuilder
<
DuelState
>
)
=>
{
builder
.
addCase
(
fetchYesNoMeta
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
modalState
.
yesNoModal
.
msg
=
action
.
payload
;
});
};
export
const
selectYesNoModalIsOpen
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
yesNoModal
.
isOpen
;
export
const
selectYesNOModalMsg
=
(
state
:
RootState
)
=>
state
.
duel
.
modalState
.
yesNoModal
.
msg
;
src/reducers/duel/monstersSlice.ts
View file @
9c3989e3
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
:
[
{
{
sequence
:
0
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
0
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
1
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
1
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
2
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
2
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
3
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
sequence
:
3
,
},
idleInteractivities
:
[],
},
},
{
{
sequence
:
4
,
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
MZONE
,
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 @
9c3989e3
...
@@ -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/selectCard.ts
View file @
9c3989e3
...
@@ -5,7 +5,7 @@ import {
...
@@ -5,7 +5,7 @@ import {
setCheckCardModalMinMax
,
setCheckCardModalMinMax
,
setCheckCardModalOnSubmit
,
setCheckCardModalOnSubmit
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchCheckCardMeta
}
from
"
../../reducers/duel/modal
Slice
"
;
import
{
fetchCheckCardMeta
}
from
"
../../reducers/duel/modal
/mod
"
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
MsgSelectCard
=
ygopro
.
StocGameMessage
.
MsgSelectCard
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
...
...
src/service/duel/selectChain.ts
View file @
9c3989e3
...
@@ -7,7 +7,7 @@ import {
...
@@ -7,7 +7,7 @@ import {
setCheckCardModalMinMax
,
setCheckCardModalMinMax
,
setCheckCardModalOnSubmit
,
setCheckCardModalOnSubmit
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchCheckCardMeta
}
from
"
../../reducers/duel/modal
Slice
"
;
import
{
fetchCheckCardMeta
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
import
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
import
MsgSelectChain
=
ygopro
.
StocGameMessage
.
MsgSelectChain
;
...
...
src/service/duel/selectEffectYn.ts
View file @
9c3989e3
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
setYesNoModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
setYesNoModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchYesNoMeta
}
from
"
../../reducers/duel/modal
Slice
"
;
import
{
fetchYesNoMeta
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
import
{
CardZoneToChinese
}
from
"
./util
"
;
import
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
import
MsgSelectEffectYn
=
ygopro
.
StocGameMessage
.
MsgSelectEffectYn
;
...
...
src/service/duel/selectIdleCmd.ts
View file @
9c3989e3
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/selectOption.ts
View file @
9c3989e3
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
setOptionModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
setOptionModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchOptionMeta
}
from
"
../../reducers/duel/modal
Slice
"
;
import
{
fetchOptionMeta
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgSelectOption
=
ygopro
.
StocGameMessage
.
MsgSelectOption
;
import
MsgSelectOption
=
ygopro
.
StocGameMessage
.
MsgSelectOption
;
...
...
src/service/duel/selectPlace.ts
View file @
9c3989e3
...
@@ -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/cardListModal.tsx
View file @
9c3989e3
...
@@ -4,7 +4,7 @@ import { store } from "../../store";
...
@@ -4,7 +4,7 @@ import { store } from "../../store";
import
{
import
{
selectCardListModalIsOpen
,
selectCardListModalIsOpen
,
selectCardListModalInfo
,
selectCardListModalInfo
,
}
from
"
../../reducers/duel/modal
Slice
"
;
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
setCardListModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
setCardListModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
Modal
,
List
,
Popover
,
Card
}
from
"
antd
"
;
import
{
Modal
,
List
,
Popover
,
Card
}
from
"
antd
"
;
...
...
src/ui/Duel/cardModal.tsx
View file @
9c3989e3
...
@@ -7,10 +7,10 @@ import {
...
@@ -7,10 +7,10 @@ import {
selectCardModalDesc
,
selectCardModalDesc
,
selectCardModalImgUrl
,
selectCardModalImgUrl
,
selectCardModalInteractivies
,
selectCardModalInteractivies
,
}
from
"
../../reducers/duel/modal
Slice
"
;
}
from
"
../../reducers/duel/modal
/mod
"
;
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 @
9c3989e3
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/checkCardModal.tsx
View file @
9c3989e3
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
selectCheckCardModalMinMax
,
selectCheckCardModalMinMax
,
selectCheckCardModalOnSubmit
,
selectCheckCardModalOnSubmit
,
selectCheckCardModalTags
,
selectCheckCardModalTags
,
}
from
"
../../reducers/duel/modal
Slice
"
;
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
import
{
resetCheckCardModal
,
resetCheckCardModal
,
setCheckCardModalIsOpen
,
setCheckCardModalIsOpen
,
...
...
src/ui/Duel/hands.tsx
View file @
9c3989e3
...
@@ -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 @
9c3989e3
...
@@ -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 @
9c3989e3
...
@@ -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/optionModal.tsx
View file @
9c3989e3
...
@@ -6,7 +6,7 @@ import { CheckCard } from "@ant-design/pro-components";
...
@@ -6,7 +6,7 @@ import { CheckCard } from "@ant-design/pro-components";
import
{
import
{
selectOptionModalIsOpen
,
selectOptionModalIsOpen
,
selectOptionModalOptions
,
selectOptionModalOptions
,
}
from
"
../../reducers/duel/modal
Slice
"
;
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
sendSelectOptionResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
sendSelectOptionResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
import
{
resetOptionModal
,
resetOptionModal
,
...
...
src/ui/Duel/positionModal.tsx
View file @
9c3989e3
...
@@ -6,7 +6,7 @@ import { sendSelectPositionResponse } from "../../api/ocgcore/ocgHelper";
...
@@ -6,7 +6,7 @@ import { sendSelectPositionResponse } from "../../api/ocgcore/ocgHelper";
import
{
import
{
selectPositionModalIsOpen
,
selectPositionModalIsOpen
,
selectPositionModalPositions
,
selectPositionModalPositions
,
}
from
"
../../reducers/duel/modal
Slice
"
;
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
import
{
resetPositionModal
,
resetPositionModal
,
...
...
src/ui/Duel/util.ts
View file @
9c3989e3
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
>
,
...
...
src/ui/Duel/yesNoModal.tsx
View file @
9c3989e3
...
@@ -6,7 +6,7 @@ import { sendSelectEffectYnResponse } from "../../api/ocgcore/ocgHelper";
...
@@ -6,7 +6,7 @@ import { sendSelectEffectYnResponse } from "../../api/ocgcore/ocgHelper";
import
{
import
{
selectYesNoModalIsOpen
,
selectYesNoModalIsOpen
,
selectYesNOModalMsg
,
selectYesNOModalMsg
,
}
from
"
../../reducers/duel/modal
Slice
"
;
}
from
"
../../reducers/duel/modal
/mod
"
;
import
{
setYesNoModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
setYesNoModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
const
YesNoModal
=
()
=>
{
const
YesNoModal
=
()
=>
{
...
...
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