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
284661fb
Commit
284661fb
authored
Dec 02, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update handSlice
parent
680f4298
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
45 deletions
+31
-45
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+24
-26
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+4
-16
src/service/duel/draw.ts
src/service/duel/draw.ts
+3
-3
No files found.
src/reducers/duel/handsSlice.ts
View file @
284661fb
...
@@ -7,42 +7,38 @@ import {
...
@@ -7,42 +7,38 @@ import {
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
Card
,
fetchCard
}
from
"
../../api/cards
"
;
import
{
Card
,
fetchCard
}
from
"
../../api/cards
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
*
as
UICONFIG
from
"
../../config/ui
"
;
import
*
as
UICONFIG
from
"
../../config/ui
"
;
export
interface
Hands
{
export
interface
Hands
{
cards
:
Card
[];
cards
:
Card
[];
}
}
// 自己增加手牌
// 增加手牌
export
const
meAddHandsImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
[]
>>
=
(
export
const
addHandsImpl
:
CaseReducer
<
state
,
DuelState
,
action
PayloadAction
<
[
number
,
number
[]]
>
)
=>
{
>
=
(
state
,
action
)
=>
{
const
cards
=
action
.
payload
.
map
((
id
)
=>
{
const
player
=
action
.
payload
[
0
];
return
{
meta
:
{
id
,
data
:
{},
text
:
{}
},
transform
:
{}
};
const
hands
=
action
.
payload
[
1
];
});
const
selfType
=
state
.
selfType
;
if
(
state
.
meHands
)
{
state
.
meHands
.
cards
=
state
.
meHands
.
cards
.
concat
(
cards
);
}
else
{
state
.
meHands
=
{
cards
};
}
setHandsTransform
(
state
.
meHands
.
cards
);
};
// 对手增加手牌
const
cards
=
hands
.
map
((
id
)
=>
{
export
const
opAddHandsImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
number
[]
>>
=
(
state
,
action
)
=>
{
const
cards
=
action
.
payload
.
map
((
id
)
=>
{
return
{
meta
:
{
id
,
data
:
{},
text
:
{}
},
transform
:
{}
};
return
{
meta
:
{
id
,
data
:
{},
text
:
{}
},
transform
:
{}
};
});
});
if
(
state
.
opHands
)
{
if
(
judgeSelf
(
player
,
selfType
))
{
state
.
opHands
.
cards
=
state
.
opHands
.
cards
.
concat
(
cards
);
if
(
state
.
meHands
)
{
state
.
meHands
.
cards
=
state
.
meHands
.
cards
.
concat
(
cards
);
}
else
{
state
.
meHands
=
{
cards
};
}
setHandsTransform
(
state
.
meHands
.
cards
);
}
else
{
}
else
{
state
.
opHands
=
{
cards
};
if
(
state
.
opHands
)
{
state
.
opHands
.
cards
=
state
.
opHands
.
cards
.
concat
(
cards
);
}
else
{
state
.
opHands
=
{
cards
};
}
}
}
};
};
...
@@ -83,6 +79,8 @@ export const meHandsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -83,6 +79,8 @@ export const meHandsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
};
};
// 更新手牌的位置和旋转信息
// 更新手牌的位置和旋转信息
//
// TODO: 兼容对方手牌
function
setHandsTransform
(
hands
:
Card
[]):
void
{
function
setHandsTransform
(
hands
:
Card
[]):
void
{
const
groundShape
=
UICONFIG
.
GroundShape
();
const
groundShape
=
UICONFIG
.
GroundShape
();
const
handShape
=
UICONFIG
.
HandShape
();
const
handShape
=
UICONFIG
.
HandShape
();
...
...
src/reducers/duel/mod.ts
View file @
284661fb
...
@@ -5,12 +5,7 @@
...
@@ -5,12 +5,7 @@
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
import
{
Hands
,
addHandsImpl
,
meHandsCase
}
from
"
./handsSlice
"
;
Hands
,
meAddHandsImpl
,
opAddHandsImpl
,
meHandsCase
,
}
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
"
;
...
@@ -35,8 +30,7 @@ const duelSlice = createSlice({
...
@@ -35,8 +30,7 @@ const duelSlice = createSlice({
state
.
selfType
=
action
.
payload
;
state
.
selfType
=
action
.
payload
;
},
},
infoInit
:
infoInitImpl
,
infoInit
:
infoInitImpl
,
meAddHands
:
meAddHandsImpl
,
addHands
:
addHandsImpl
,
opAddHands
:
opAddHandsImpl
,
updateTurn
:
newTurnImpl
,
updateTurn
:
newTurnImpl
,
updatePhase
:
newPhaseImpl
,
updatePhase
:
newPhaseImpl
,
},
},
...
@@ -45,14 +39,8 @@ const duelSlice = createSlice({
...
@@ -45,14 +39,8 @@ const duelSlice = createSlice({
},
},
});
});
export
const
{
export
const
{
setSelfType
,
infoInit
,
addHands
,
updateTurn
,
updatePhase
}
=
setSelfType
,
duelSlice
.
actions
;
infoInit
,
meAddHands
,
opAddHands
,
updateTurn
,
updatePhase
,
}
=
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/draw.ts
View file @
284661fb
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
{
meAddHands
,
opA
ddHands
}
from
"
../../reducers/duel/mod
"
;
import
{
a
ddHands
}
from
"
../../reducers/duel/mod
"
;
import
{
fetchMeHandsMeta
}
from
"
../../reducers/duel/handsSlice
"
;
import
{
fetchMeHandsMeta
}
from
"
../../reducers/duel/handsSlice
"
;
export
default
(
export
default
(
...
@@ -9,10 +9,10 @@ export default (
...
@@ -9,10 +9,10 @@ export default (
)
=>
{
)
=>
{
// FIXME: draw.player 和先后攻有关系
// FIXME: draw.player 和先后攻有关系
if
(
draw
.
player
===
0
)
{
if
(
draw
.
player
===
0
)
{
dispatch
(
meAddHands
(
draw
.
cards
));
dispatch
(
addHands
([
0
,
draw
.
cards
]
));
dispatch
(
fetchMeHandsMeta
(
draw
.
cards
));
dispatch
(
fetchMeHandsMeta
(
draw
.
cards
));
}
else
if
(
draw
.
player
===
1
)
{
}
else
if
(
draw
.
player
===
1
)
{
dispatch
(
opAddHands
(
draw
.
cards
));
dispatch
(
addHands
([
1
,
draw
.
cards
]
));
}
else
{
}
else
{
console
.
log
(
"
Currently only support 2v2 mode.
"
);
console
.
log
(
"
Currently only support 2v2 mode.
"
);
}
}
...
...
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