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
b8cdf42f
Commit
b8cdf42f
authored
Mar 09, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/hp' into 'main'
Feat/hp See merge request
!123
parents
f473b3e1
2eb352ac
Pipeline
#20541
passed with stages
in 6 minutes and 50 seconds
Changes
10
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
327 additions
and
5 deletions
+327
-5
neos-protobuf
neos-protobuf
+1
-1
src/api/ocgcore/idl/ocgcore.ts
src/api/ocgcore/idl/ocgcore.ts
+222
-3
src/api/ocgcore/ocgAdapter/protoDecl.ts
src/api/ocgcore/ocgAdapter/protoDecl.ts
+3
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
+21
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
+13
-0
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/recover.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/recover.ts
+21
-0
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.
neos-protobuf
@
43cd7f19
Subproject commit
308767ca7ca67e28f99a45687a1cc8209e91453d
Subproject commit
43cd7f197670493f58f648e52fb49f918e12803a
src/api/ocgcore/idl/ocgcore.ts
View file @
b8cdf42f
This diff is collapsed.
Click to expand it.
src/api/ocgcore/ocgAdapter/protoDecl.ts
View file @
b8cdf42f
...
...
@@ -42,3 +42,6 @@ export const MSG_SELECT_POSITION = 19;
export
const
MSG_SELECT_OPTION
=
14
;
export
const
MSG_SELECT_BATTLE_CMD
=
10
;
export
const
MSG_SELECT_UNSELECT_CARD
=
26
;
export
const
MSG_DAMAGE
=
91
;
export
const
MSG_RECOVER
=
92
;
export
const
MSG_PAY_LP_COST
=
100
;
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
0 → 100644
View file @
b8cdf42f
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
/*
* Msg Damage
*
* @param player - 玩家编号
* @param value - 减少的Hp数值
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReader
(
data
,
true
);
const
player
=
reader
.
readUint8
();
const
value
=
reader
.
readInt32
();
return
new
ygopro
.
StocGameMessage
.
MsgUpdateHp
({
player
,
type_
:
ygopro
.
StocGameMessage
.
MsgUpdateHp
.
ActionType
.
DAMAGE
,
value
,
});
};
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
b8cdf42f
...
...
@@ -20,6 +20,8 @@ import MsgSelectPositionAdapter from "./selectPosition";
import
MsgSelectOptionAdapter
from
"
./selectOption
"
;
import
MsgSelectBattleCmdAdapter
from
"
./selectBattleCmd
"
;
import
MsgSelectUnselectCardAdapter
from
"
./selectUnselectCard
"
;
import
MsgDamage
from
"
./damage
"
;
import
MsgRecover
from
"
./recover
"
;
import
PENETRATE
from
"
./penetrate
"
;
/*
...
...
@@ -117,6 +119,17 @@ export default class GameMsgAdapter implements StocAdapter {
break
;
}
case
GAME_MSG
.
MSG_PAY_LP_COST
:
case
GAME_MSG
.
MSG_DAMAGE
:
{
gameMsg
.
update_hp
=
MsgDamage
(
gameData
);
break
;
}
case
GAME_MSG
.
MSG_RECOVER
:
{
gameMsg
.
update_hp
=
MsgRecover
(
gameData
);
break
;
}
default
:
{
console
.
log
(
"
Unhandled GameMessage function=
"
,
func
);
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/recover.ts
0 → 100644
View file @
b8cdf42f
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
/*
* Msg Recover
*
* @param player - 玩家编号
* @param value - 回复的Hp数值
* */
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReader
(
data
,
true
);
const
player
=
reader
.
readUint8
();
const
value
=
reader
.
readInt32
();
return
new
ygopro
.
StocGameMessage
.
MsgUpdateHp
({
player
,
type_
:
ygopro
.
StocGameMessage
.
MsgUpdateHp
.
ActionType
.
RECOVER
,
value
,
});
};
src/reducers/duel/initInfoSlice.ts
View file @
b8cdf42f
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
judgeSelf
}
from
"
./util
"
;
import
MsgUpdateHp
=
ygopro
.
StocGameMessage
.
MsgUpdateHp
;
export
interface
InitInfo
{
masterRule
?:
string
;
...
...
@@ -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
selectOpInitInfo
=
(
state
:
RootState
)
=>
state
.
duel
.
opInitInfo
;
src/reducers/duel/mod.ts
View file @
b8cdf42f
...
...
@@ -4,7 +4,7 @@
* */
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
InitInfo
,
infoInitImpl
}
from
"
./initInfoSlice
"
;
import
{
InitInfo
,
infoInitImpl
,
updateHpImpl
}
from
"
./initInfoSlice
"
;
import
{
TimeLimit
,
updateTimeLimitImpl
}
from
"
./timeLimit
"
;
import
{
HandState
,
...
...
@@ -170,6 +170,7 @@ const duelSlice = createSlice({
state
.
selfType
=
action
.
payload
;
},
infoInit
:
infoInitImpl
,
updateHp
:
updateHpImpl
,
updateTurn
:
newTurnImpl
,
updateTimeLimit
:
updateTimeLimitImpl
,
...
...
@@ -268,6 +269,7 @@ const duelSlice = createSlice({
export
const
{
setSelfType
,
infoInit
,
updateHp
,
updateTurn
,
updatePhase
,
setEnableBp
,
...
...
src/service/duel/gameMsg.ts
View file @
b8cdf42f
...
...
@@ -18,6 +18,7 @@ import onMsgSelectBattleCmd from "./selectBattleCmd";
import
onMsgPosChange
from
"
./posChange
"
;
import
onMsgSelectUnselectCard
from
"
./selectUnselectCard
"
;
import
onMsgSelectYesNo
from
"
./selectYesNo
"
;
import
onMsgUpdateHp
from
"
./updateHp
"
;
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
dispatch
=
store
.
dispatch
;
...
...
@@ -114,6 +115,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
}
case
"
update_hp
"
:
{
onMsgUpdateHp
(
msg
.
update_hp
,
dispatch
);
break
;
}
default
:
{
break
;
}
...
...
src/service/duel/updateHp.ts
0 → 100644
View file @
b8cdf42f
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