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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
6b2d3fe5
Commit
6b2d3fe5
authored
Jan 13, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/deck' into 'main'
Feat/deck See merge request
!72
parents
90419ce0
07f8fde7
Pipeline
#19467
passed with stages
in 4 minutes and 18 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
36 deletions
+93
-36
src/reducers/duel/deckSlice.ts
src/reducers/duel/deckSlice.ts
+41
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+8
-0
src/service/duel/start.ts
src/service/duel/start.ts
+3
-0
src/ui/Duel/cemetery.tsx
src/ui/Duel/cemetery.tsx
+2
-4
src/ui/Duel/deck.tsx
src/ui/Duel/deck.tsx
+24
-19
src/ui/Duel/exclusion.tsx
src/ui/Duel/exclusion.tsx
+2
-4
src/ui/Duel/singleSlot.tsx
src/ui/Duel/singleSlot.tsx
+13
-9
No files found.
src/reducers/duel/deckSlice.ts
0 → 100644
View file @
6b2d3fe5
import
{
judgeSelf
}
from
"
./util
"
;
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
DuelFieldState
,
CardState
}
from
"
./generic
"
;
export
interface
DeckState
extends
DuelFieldState
{}
// 初始化卡组状态
export
const
initDeckImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
deskSize
:
number
}
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
deckSize
=
action
.
payload
.
deskSize
;
let
deck
:
CardState
[]
=
new
Array
(
deckSize
);
for
(
let
i
=
0
;
i
<
deckSize
;
i
++
)
{
deck
.
push
({
occupant
:
{
id
:
0
,
data
:
{},
text
:
{}
},
location
:
{
controler
:
player
,
location
:
ygopro
.
CardZone
.
DECK
,
sequence
:
i
,
},
idleInteractivities
:
[],
});
}
if
(
judgeSelf
(
player
,
state
))
{
state
.
meDeck
=
{
inner
:
deck
};
}
else
{
state
.
opDeck
=
{
inner
:
deck
};
}
};
export
const
selectMeDeck
=
(
state
:
RootState
)
=>
state
.
duel
.
meDeck
||
{
inner
:
[]
};
export
const
selectOpDeck
=
(
state
:
RootState
)
=>
state
.
duel
.
opDeck
||
{
inner
:
[]
};
src/reducers/duel/mod.ts
View file @
6b2d3fe5
...
@@ -61,6 +61,7 @@ import {
...
@@ -61,6 +61,7 @@ import {
initExclusionImpl
,
initExclusionImpl
,
exclusionCase
,
exclusionCase
,
}
from
"
./exclusionSlice
"
;
}
from
"
./exclusionSlice
"
;
import
{
DeckState
,
initDeckImpl
}
from
"
./deckSlice
"
;
export
interface
DuelState
{
export
interface
DuelState
{
selfType
?:
number
;
selfType
?:
number
;
...
@@ -82,6 +83,9 @@ export interface DuelState {
...
@@ -82,6 +83,9 @@ export interface DuelState {
meExclusion
?:
ExclusionState
;
// 自己的除外区状态
meExclusion
?:
ExclusionState
;
// 自己的除外区状态
opExclusion
?:
ExclusionState
;
// 对手的除外区状态
opExclusion
?:
ExclusionState
;
// 对手的除外区状态
meDeck
?:
DeckState
;
// 自己的卡组状态
opDeck
?:
DeckState
;
// 对手的卡组状态
meTimeLimit
?:
TimeLimit
;
// 自己的计时
meTimeLimit
?:
TimeLimit
;
// 自己的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
...
@@ -139,6 +143,9 @@ const duelSlice = createSlice({
...
@@ -139,6 +143,9 @@ const duelSlice = createSlice({
// 除外区相关`Reducer`
// 除外区相关`Reducer`
initExclusion
:
initExclusionImpl
,
initExclusion
:
initExclusionImpl
,
// 卡组相关`Reducer`
initDeck
:
initDeckImpl
,
// UI相关`Reducer`
// UI相关`Reducer`
setCardModalIsOpen
:
setCardModalIsOpenImpl
,
setCardModalIsOpen
:
setCardModalIsOpenImpl
,
setCardModalText
:
setCardModalTextImpl
,
setCardModalText
:
setCardModalTextImpl
,
...
@@ -206,6 +213,7 @@ export const {
...
@@ -206,6 +213,7 @@ export const {
resetPositionModal
,
resetPositionModal
,
setOptionModalIsOpen
,
setOptionModalIsOpen
,
resetOptionModal
,
resetOptionModal
,
initDeck
,
}
=
duelSlice
.
actions
;
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
return
state
.
duel
.
meInitInfo
!=
null
;
return
state
.
duel
.
meInitInfo
!=
null
;
...
...
src/service/duel/start.ts
View file @
6b2d3fe5
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
initMonsters
,
initMonsters
,
initMagics
,
initMagics
,
initCemetery
,
initCemetery
,
initDeck
,
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
export
default
(
export
default
(
...
@@ -39,4 +40,6 @@ export default (
...
@@ -39,4 +40,6 @@ export default (
dispatch
(
initMagics
(
1
));
dispatch
(
initMagics
(
1
));
dispatch
(
initCemetery
(
0
));
dispatch
(
initCemetery
(
0
));
dispatch
(
initCemetery
(
1
));
dispatch
(
initCemetery
(
1
));
dispatch
(
initDeck
({
player
:
0
,
deskSize
:
start
.
deckSize1
}));
dispatch
(
initDeck
({
player
:
1
,
deskSize
:
start
.
deckSize2
}));
};
};
src/ui/Duel/cemetery.tsx
View file @
6b2d3fe5
...
@@ -5,9 +5,7 @@ import {
...
@@ -5,9 +5,7 @@ import {
selectOpCemetery
,
selectOpCemetery
,
}
from
"
../../reducers/duel/cemeretySlice
"
;
}
from
"
../../reducers/duel/cemeretySlice
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
SingleSlot
from
"
./singleSlot
"
;
import
SingleSlot
,
{
Depth
}
from
"
./singleSlot
"
;
const
depth
=
0.02
;
const
Cemeteries
=
()
=>
{
const
Cemeteries
=
()
=>
{
const
meCemetery
=
useAppSelector
(
selectMeCemetery
).
inner
;
const
meCemetery
=
useAppSelector
(
selectMeCemetery
).
inner
;
...
@@ -31,7 +29,7 @@ const Cemeteries = () => {
...
@@ -31,7 +29,7 @@ const Cemeteries = () => {
const
cemeteryPosition
=
(
player
:
number
,
cemeteryLength
:
number
)
=>
{
const
cemeteryPosition
=
(
player
:
number
,
cemeteryLength
:
number
)
=>
{
const
x
=
player
==
0
?
3.2
:
-
3.2
;
const
x
=
player
==
0
?
3.2
:
-
3.2
;
const
y
=
(
d
epth
*
cemeteryLength
)
/
2
+
CONFIG
.
Floating
;
const
y
=
(
D
epth
*
cemeteryLength
)
/
2
+
CONFIG
.
Floating
;
const
z
=
player
==
0
?
-
2.0
:
2.0
;
const
z
=
player
==
0
?
-
2.0
:
2.0
;
return
new
BABYLON
.
Vector3
(
x
,
y
,
z
);
return
new
BABYLON
.
Vector3
(
x
,
y
,
z
);
...
...
src/ui/Duel/deck.tsx
View file @
6b2d3fe5
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
{
useAppSelector
}
from
"
../../hook
"
;
import
{
selectMeDeck
,
selectOpDeck
}
from
"
../../reducers/duel/deckSlice
"
;
import
SingleSlot
,
{
Depth
}
from
"
./singleSlot
"
;
const
Deck
=
()
=>
(
const
Deck
=
()
=>
(
<>
<>
...
@@ -9,28 +12,22 @@ const Deck = () => (
...
@@ -9,28 +12,22 @@ const Deck = () => (
);
);
const
CommonDeck
=
()
=>
{
const
CommonDeck
=
()
=>
{
const
shape
=
CONFIG
.
DeckSlotShape
();
const
meDeck
=
useAppSelector
(
selectMeDeck
).
inner
;
const
position
=
new
BABYLON
.
Vector3
(
const
opDeck
=
useAppSelector
(
selectOpDeck
).
inner
;
3.2
,
shape
.
depth
/
2
+
CONFIG
.
Floating
,
-
3.3
);
const
rotation
=
CONFIG
.
DeckSlotRotation
();
return
(
return
(
<
box
<>
name=
"common-deck"
<
SingleSlot
width=
{
shape
.
width
}
state=
{
meDeck
}
height=
{
shape
.
height
}
position=
{
deckPosition
(
0
,
meDeck
.
length
)
}
depth=
{
shape
.
depth
}
rotation=
{
CONFIG
.
CardSlotRotation
(
false
)
}
position=
{
position
}
rotation=
{
rotation
}
>
<
standardMaterial
name=
"common-deck-mat"
diffuseColor=
{
CONFIG
.
DeckColor
()
}
/>
/>
</
box
>
<
SingleSlot
state=
{
opDeck
}
position=
{
deckPosition
(
1
,
opDeck
.
length
)
}
rotation=
{
CONFIG
.
CardSlotRotation
(
true
)
}
/>
</>
);
);
};
};
...
@@ -60,4 +57,12 @@ const ExtraDeck = () => {
...
@@ -60,4 +57,12 @@ const ExtraDeck = () => {
);
);
};
};
const
deckPosition
=
(
player
:
number
,
deckLength
:
number
)
=>
{
const
x
=
player
==
0
?
3.2
:
-
3.2
;
const
y
=
(
Depth
*
deckLength
)
/
2
+
CONFIG
.
Floating
;
const
z
=
player
==
0
?
-
3.3
:
3.3
;
return
new
BABYLON
.
Vector3
(
x
,
y
,
z
);
};
export
default
Deck
;
export
default
Deck
;
src/ui/Duel/exclusion.tsx
View file @
6b2d3fe5
...
@@ -5,9 +5,7 @@ import {
...
@@ -5,9 +5,7 @@ import {
selectMeExclusion
,
selectMeExclusion
,
selectopExclusion
,
selectopExclusion
,
}
from
"
../../reducers/duel/exclusionSlice
"
;
}
from
"
../../reducers/duel/exclusionSlice
"
;
import
SingleSlot
from
"
./singleSlot
"
;
import
SingleSlot
,
{
Depth
}
from
"
./singleSlot
"
;
const
depth
=
0.02
;
const
Exclusion
=
()
=>
{
const
Exclusion
=
()
=>
{
const
meExclusion
=
useAppSelector
(
selectMeExclusion
).
inner
;
const
meExclusion
=
useAppSelector
(
selectMeExclusion
).
inner
;
...
@@ -31,7 +29,7 @@ const Exclusion = () => {
...
@@ -31,7 +29,7 @@ const Exclusion = () => {
const
exclusionPosition
=
(
player
:
number
,
exclusionLength
:
number
)
=>
{
const
exclusionPosition
=
(
player
:
number
,
exclusionLength
:
number
)
=>
{
const
x
=
player
==
0
?
3.2
:
-
3.2
;
const
x
=
player
==
0
?
3.2
:
-
3.2
;
const
y
=
(
d
epth
*
exclusionLength
)
/
2
+
CONFIG
.
Floating
;
const
y
=
(
D
epth
*
exclusionLength
)
/
2
+
CONFIG
.
Floating
;
const
z
=
player
==
0
?
-
0.7
:
0.7
;
const
z
=
player
==
0
?
-
0.7
:
0.7
;
return
new
BABYLON
.
Vector3
(
x
,
y
,
z
);
return
new
BABYLON
.
Vector3
(
x
,
y
,
z
);
...
...
src/ui/Duel/singleSlot.tsx
View file @
6b2d3fe5
...
@@ -10,7 +10,7 @@ import {
...
@@ -10,7 +10,7 @@ import {
}
from
"
../../reducers/duel/mod
"
;
}
from
"
../../reducers/duel/mod
"
;
const
shape
=
CONFIG
.
SingleSlotShape
;
const
shape
=
CONFIG
.
SingleSlotShape
;
const
depth
=
0.02
;
export
const
Depth
=
0.005
;
const
SingleSlot
=
(
props
:
{
const
SingleSlot
=
(
props
:
{
state
:
CardState
[];
state
:
CardState
[];
...
@@ -25,13 +25,17 @@ const SingleSlot = (props: {
...
@@ -25,13 +25,17 @@ const SingleSlot = (props: {
if
(
props
.
state
.
length
!=
0
)
{
if
(
props
.
state
.
length
!=
0
)
{
dispatch
(
dispatch
(
setCardListModalInfo
(
setCardListModalInfo
(
props
.
state
.
map
((
item
)
=>
{
props
.
state
return
{
.
filter
(
name
:
item
.
occupant
?.
text
.
name
,
(
item
)
=>
item
.
occupant
!==
undefined
&&
item
.
occupant
.
id
!==
0
desc
:
item
.
occupant
?.
text
.
desc
,
)
imgUrl
:
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
item
.
occupant
?.
id
}.
jpg
`,
.
map
((
item
)
=>
{
};
return
{
})
name
:
item
.
occupant
?.
text
.
name
,
desc
:
item
.
occupant
?.
text
.
desc
,
imgUrl
:
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
item
.
occupant
?.
id
}.
jpg
`,
};
})
)
)
);
);
dispatch(setCardListModalIsOpen(true));
dispatch(setCardListModalIsOpen(true));
...
@@ -49,7 +53,7 @@ const SingleSlot = (props: {
...
@@ -49,7 +53,7 @@ const SingleSlot = (props: {
new BABYLON.Vector3(
new BABYLON.Vector3(
shape.width,
shape.width,
shape.height,
shape.height,
d
epth * props.state.length
D
epth * props.state.length
)
)
}
}
position={props.position}
position={props.position}
...
...
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