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
8e8baec0
Commit
8e8baec0
authored
Mar 09, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add updateHp service
parent
723f6bfa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
src/reducers/duel/initInfoSlice.ts
src/reducers/duel/initInfoSlice.ts
+29
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+3
-1
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+6
-0
src/service/duel/updateHp.ts
src/service/duel/updateHp.ts
+8
-0
No files found.
src/reducers/duel/initInfoSlice.ts
View file @
8e8baec0
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
MsgUpdateHp
=
ygopro
.
StocGameMessage
.
MsgUpdateHp
;
export
interface
InitInfo
{
export
interface
InitInfo
{
masterRule
?:
string
;
masterRule
?:
string
;
...
@@ -25,5 +27,32 @@ export const infoInitImpl: CaseReducer<
...
@@ -25,5 +27,32 @@ export const infoInitImpl: CaseReducer<
}
}
};
};
export
const
updateHpImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
ygopro
.
StocGameMessage
.
MsgUpdateHp
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
.
player
;
const
actionType
=
action
.
payload
.
type_
;
const
value
=
action
.
payload
.
value
;
const
info
=
judgeSelf
(
player
,
state
)
?
state
.
meInitInfo
:
state
.
opInitInfo
;
if
(
info
)
{
switch
(
actionType
)
{
case
MsgUpdateHp
.
ActionType
.
DAMAGE
:
{
info
.
life
=
info
.
life
-
value
;
break
;
}
case
MsgUpdateHp
.
ActionType
.
RECOVER
:
{
info
.
life
=
info
.
life
+
value
;
break
;
}
default
:
{
break
;
}
}
}
};
export
const
selectMeInitInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
meInitInfo
;
export
const
selectMeInitInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
meInitInfo
;
export
const
selectOpInitInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
opInitInfo
;
export
const
selectOpInitInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
opInitInfo
;
src/reducers/duel/mod.ts
View file @
8e8baec0
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* */
* */
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
InitInfo
,
infoInitImpl
,
updateHpImpl
}
from
"
./initInfoSlice
"
;
import
{
TimeLimit
,
updateTimeLimitImpl
}
from
"
./timeLimit
"
;
import
{
TimeLimit
,
updateTimeLimitImpl
}
from
"
./timeLimit
"
;
import
{
import
{
HandState
,
HandState
,
...
@@ -170,6 +170,7 @@ const duelSlice = createSlice({
...
@@ -170,6 +170,7 @@ const duelSlice = createSlice({
state
.
selfType
=
action
.
payload
;
state
.
selfType
=
action
.
payload
;
},
},
infoInit
:
infoInitImpl
,
infoInit
:
infoInitImpl
,
updateHp
:
updateHpImpl
,
updateTurn
:
newTurnImpl
,
updateTurn
:
newTurnImpl
,
updateTimeLimit
:
updateTimeLimitImpl
,
updateTimeLimit
:
updateTimeLimitImpl
,
...
@@ -268,6 +269,7 @@ const duelSlice = createSlice({
...
@@ -268,6 +269,7 @@ const duelSlice = createSlice({
export
const
{
export
const
{
setSelfType
,
setSelfType
,
infoInit
,
infoInit
,
updateHp
,
updateTurn
,
updateTurn
,
updatePhase
,
updatePhase
,
setEnableBp
,
setEnableBp
,
...
...
src/service/duel/gameMsg.ts
View file @
8e8baec0
...
@@ -18,6 +18,7 @@ import onMsgSelectBattleCmd from "./selectBattleCmd";
...
@@ -18,6 +18,7 @@ import onMsgSelectBattleCmd from "./selectBattleCmd";
import
onMsgPosChange
from
"
./posChange
"
;
import
onMsgPosChange
from
"
./posChange
"
;
import
onMsgSelectUnselectCard
from
"
./selectUnselectCard
"
;
import
onMsgSelectUnselectCard
from
"
./selectUnselectCard
"
;
import
onMsgSelectYesNo
from
"
./selectYesNo
"
;
import
onMsgSelectYesNo
from
"
./selectYesNo
"
;
import
onMsgUpdateHp
from
"
./updateHp
"
;
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
dispatch
=
store
.
dispatch
;
const
dispatch
=
store
.
dispatch
;
...
@@ -114,6 +115,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
...
@@ -114,6 +115,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
break
;
}
}
case
"
update_hp
"
:
{
onMsgUpdateHp
(
msg
.
update_hp
,
dispatch
);
break
;
}
default
:
{
default
:
{
break
;
break
;
}
}
...
...
src/service/duel/updateHp.ts
0 → 100644
View file @
8e8baec0
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
updateHp
}
from
"
../../reducers/duel/mod
"
;
import
{
AppDispatch
}
from
"
../../store
"
;
import
MsgUpdateHp
=
ygopro
.
StocGameMessage
.
MsgUpdateHp
;
export
default
(
msgUpdateHp
:
MsgUpdateHp
,
dispatch
:
AppDispatch
)
=>
{
dispatch
(
updateHp
(
msgUpdateHp
));
};
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