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
f600e0f6
Commit
f600e0f6
authored
Dec 05, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update hands slice
parent
7a36b504
Pipeline
#18480
passed with stages
in 4 minutes and 17 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
18 deletions
+63
-18
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+45
-5
src/reducers/duel/initInfoSlice.ts
src/reducers/duel/initInfoSlice.ts
+1
-2
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+10
-1
src/reducers/duel/util.ts
src/reducers/duel/util.ts
+6
-6
src/service/duel/selectIdleCmd.ts
src/service/duel/selectIdleCmd.ts
+1
-4
No files found.
src/reducers/duel/handsSlice.ts
View file @
f600e0f6
import
{
createAsyncThunk
,
ActionReducerMapBuilder
}
from
"
@reduxjs/toolkit
"
;
import
{
createAsyncThunk
,
ActionReducerMapBuilder
,
CaseReducer
,
PayloadAction
,
}
from
"
@reduxjs/toolkit
"
;
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
}
from
"
./util
"
;
import
{
judgeSelf
,
Card
,
InteractType
,
Interactivity
}
from
"
./util
"
;
import
*
as
UICONFIG
from
"
../../config/ui
"
;
import
*
as
UICONFIG
from
"
../../config/ui
"
;
import
{
Card
}
from
"
./util
"
;
export
interface
Hands
{
export
interface
Hands
{
// 注意:手牌的位置顺序是有约束的
cards
:
Card
[];
cards
:
Card
[];
}
}
...
@@ -36,12 +41,11 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -36,12 +41,11 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
builder
.
addCase
(
fetchHandsMeta
.
fulfilled
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchHandsMeta
.
fulfilled
,
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
player
=
action
.
payload
[
0
];
const
hands
=
action
.
payload
[
1
];
const
hands
=
action
.
payload
[
1
];
const
selfType
=
state
.
selfType
;
const
cards
=
hands
.
map
((
meta
)
=>
{
const
cards
=
hands
.
map
((
meta
)
=>
{
return
{
meta
,
transform
:
{},
interactivities
:
[]
};
return
{
meta
,
transform
:
{},
interactivities
:
[]
};
});
});
if
(
judgeSelf
(
player
,
s
elfTyp
e
))
{
if
(
judgeSelf
(
player
,
s
tat
e
))
{
if
(
state
.
meHands
)
{
if
(
state
.
meHands
)
{
state
.
meHands
.
cards
=
state
.
meHands
.
cards
.
concat
(
cards
);
state
.
meHands
.
cards
=
state
.
meHands
.
cards
.
concat
(
cards
);
}
else
{
}
else
{
...
@@ -79,6 +83,42 @@ function setHandsTransform(hands: Card[]): void {
...
@@ -79,6 +83,42 @@ function setHandsTransform(hands: Card[]): void {
});
});
}
}
// 清空手牌互动性
export
const
clearHandsInteractivityImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
for
(
let
hand
of
hands
.
cards
)
{
hand
.
interactivities
=
[];
}
}
};
// 添加手牌互动性
export
const
addHandsInteractivityImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
{
player
:
number
;
index
:
number
;
interactivity
:
Interactivity
;
}
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
hands
=
judgeSelf
(
player
,
state
)
?
state
.
meHands
:
state
.
opHands
;
if
(
hands
)
{
const
index
=
action
.
payload
.
index
;
const
interactivity
=
action
.
payload
.
interactivity
;
hands
.
cards
[
index
].
interactivities
.
push
(
interactivity
);
}
};
export
const
selectMeHands
=
(
state
:
RootState
)
=>
export
const
selectMeHands
=
(
state
:
RootState
)
=>
state
.
duel
.
meHands
||
{
cards
:
[]
};
state
.
duel
.
meHands
||
{
cards
:
[]
};
export
const
selectOpHands
=
(
state
:
RootState
)
=>
export
const
selectOpHands
=
(
state
:
RootState
)
=>
...
...
src/reducers/duel/initInfoSlice.ts
View file @
f600e0f6
...
@@ -16,9 +16,8 @@ export const infoInitImpl: CaseReducer<
...
@@ -16,9 +16,8 @@ export const infoInitImpl: CaseReducer<
>
=
(
state
,
action
)
=>
{
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
player
=
action
.
payload
[
0
];
const
initInfo
=
action
.
payload
[
1
];
const
initInfo
=
action
.
payload
[
1
];
const
selfType
=
state
.
selfType
;
if
(
judgeSelf
(
player
,
s
elfTyp
e
))
{
if
(
judgeSelf
(
player
,
s
tat
e
))
{
state
.
meInitInfo
=
initInfo
;
state
.
meInitInfo
=
initInfo
;
}
else
{
}
else
{
state
.
opInitInfo
=
initInfo
;
state
.
opInitInfo
=
initInfo
;
...
...
src/reducers/duel/mod.ts
View file @
f600e0f6
...
@@ -5,7 +5,12 @@
...
@@ -5,7 +5,12 @@
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
Hands
,
handsCase
}
from
"
./handsSlice
"
;
import
{
Hands
,
handsCase
,
clearHandsInteractivityImpl
,
addHandsInteractivityImpl
,
}
from
"
./handsSlice
"
;
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
import
{
newTurnImpl
}
from
"
./turnSlice
"
;
import
{
newPhaseImpl
}
from
"
./phaseSlice
"
;
import
{
newPhaseImpl
}
from
"
./phaseSlice
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
...
@@ -32,6 +37,10 @@ const duelSlice = createSlice({
...
@@ -32,6 +37,10 @@ const duelSlice = createSlice({
infoInit
:
infoInitImpl
,
infoInit
:
infoInitImpl
,
updateTurn
:
newTurnImpl
,
updateTurn
:
newTurnImpl
,
updatePhase
:
newPhaseImpl
,
updatePhase
:
newPhaseImpl
,
// 手牌相关`Reducer`
clearHandsInteractivity
:
clearHandsInteractivityImpl
,
addHandsInteractivity
:
addHandsInteractivityImpl
,
},
},
extraReducers
(
builder
)
{
extraReducers
(
builder
)
{
handsCase
(
builder
);
handsCase
(
builder
);
...
...
src/reducers/duel/util.ts
View file @
f600e0f6
...
@@ -4,14 +4,14 @@
...
@@ -4,14 +4,14 @@
* */
* */
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
Draft
}
from
"
@reduxjs/toolkit
"
;
/*
/*
* 通过`player`和`selfType`判断是应该处理自己还是对手
* 通过`player`和`selfType`判断是应该处理自己还是对手
* */
* */
export
function
judgeSelf
(
export
function
judgeSelf
(
player
:
number
,
state
:
Draft
<
DuelState
>
):
boolean
{
player
:
number
,
const
selfType
=
state
.
selfType
;
selfType
:
number
|
undefined
):
boolean
{
if
(
selfType
===
1
)
{
if
(
selfType
===
1
)
{
// 自己是先攻
// 自己是先攻
return
player
===
0
;
return
player
===
0
;
...
@@ -61,8 +61,8 @@ export enum InteractType {
...
@@ -61,8 +61,8 @@ export enum InteractType {
ACTIVATE
,
ACTIVATE
,
}
}
interface
Interactivity
{
export
interface
Interactivity
{
interactType
:
InteractType
;
interactType
:
InteractType
;
// 如果`interactType`是`ACTIVATE`,这个字段是对应的效果编号
// 如果`interactType`是`ACTIVATE`,这个字段是对应的效果编号
activateIndex
:
number
;
activateIndex
?
:
number
;
}
}
src/service/duel/selectIdleCmd.ts
View file @
f600e0f6
...
@@ -4,7 +4,4 @@ import { AppDispatch } from "../../store";
...
@@ -4,7 +4,4 @@ import { AppDispatch } from "../../store";
export
default
(
export
default
(
selectIdleCmd
:
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
,
selectIdleCmd
:
ygopro
.
StocGameMessage
.
MsgSelectIdleCmd
,
dispatch
:
AppDispatch
dispatch
:
AppDispatch
)
=>
{
)
=>
{};
// TODO
console
.
log
(
selectIdleCmd
);
};
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