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
deft
Neos
Commits
972ed5f0
Commit
972ed5f0
authored
Nov 19, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add duelSlice and impl initInfo slice
parent
37f73cd3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
3 deletions
+61
-3
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/start.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/start.ts
+1
-1
src/reducers/duel/initInfoSlice.ts
src/reducers/duel/initInfoSlice.ts
+7
-0
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+30
-0
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+21
-2
src/store.ts
src/store.ts
+2
-0
No files found.
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/start.ts
View file @
972ed5f0
...
...
@@ -14,7 +14,7 @@ const INT32_BYTE_OFFSET = 4;
export
default
(
data
:
Uint8Array
)
=>
{
const
dataView
=
new
DataView
(
data
.
buffer
);
// TODO:
对DataView包装下实现一个BufferIO类,便于解析二进制数据
// TODO:
use `BufferIO`
const
pT
=
dataView
.
getUint8
(
0
);
const
playerType
=
(
pT
&
0xf
)
<=
0
...
...
src/reducers/duel/initInfoSlice.ts
0 → 100644
View file @
972ed5f0
export
interface
InitInfo
{
playerType
?:
string
;
masterRule
?:
string
;
life
:
number
;
deckSize
:
number
;
extraSize
:
number
;
}
src/reducers/duel/mod.ts
0 → 100644
View file @
972ed5f0
/*
* 对局内的状态更新逻辑
*
* */
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
InitInfo
}
from
"
./initInfoSlice
"
;
export
interface
DuelState
{
meInitInfo
?:
InitInfo
;
// 自己的初始状态
opInitInfo
?:
InitInfo
;
// 对手的初始状态
}
const
initialState
:
DuelState
=
{};
const
duelSlice
=
createSlice
({
name
:
"
duel
"
,
initialState
,
reducers
:
{
meInfoInit
:
(
state
,
action
:
PayloadAction
<
InitInfo
>
)
=>
{
state
.
meInitInfo
=
action
.
payload
;
},
opInfoInit
:
(
state
,
action
:
PayloadAction
<
InitInfo
>
)
=>
{
state
.
opInitInfo
=
action
.
payload
;
},
},
});
export
const
{
meInfoInit
,
opInfoInit
}
=
duelSlice
.
actions
;
export
default
duelSlice
.
reducer
;
src/service/duel/gameMsg.ts
View file @
972ed5f0
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
store
}
from
"
../../store
"
;
import
{
meInfoInit
,
opInfoInit
}
from
"
../../reducers/duel/mod
"
;
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
dispatch
=
store
.
dispatch
;
const
msg
=
pb
.
stoc_game_msg
;
switch
(
msg
.
gameMsg
)
{
case
"
start
"
:
{
// TODO
console
.
log
(
msg
.
start
);
const
start
=
msg
.
start
;
dispatch
(
meInfoInit
({
playerType
:
start
.
playerType
.
toString
(),
life
:
start
.
life1
,
deckSize
:
start
.
deckSize1
,
extraSize
:
start
.
extraSize1
,
})
);
dispatch
(
opInfoInit
({
life
:
start
.
life2
,
deckSize
:
start
.
deckSize2
,
extraSize
:
start
.
extraSize2
,
})
);
break
;
}
...
...
src/store.ts
View file @
972ed5f0
...
...
@@ -6,6 +6,7 @@ import joinedReducer from "./reducers/joinSlice";
import
chatReducer
from
"
./reducers/chatSlice
"
;
import
playerReducer
from
"
./reducers/playerSlice
"
;
import
moraReducer
from
"
./reducers/moraSlice
"
;
import
duelReducer
from
"
./reducers/duel/mod
"
;
export
const
store
=
configureStore
({
reducer
:
{
...
...
@@ -13,6 +14,7 @@ export const store = configureStore({
chat
:
chatReducer
,
player
:
playerReducer
,
mora
:
moraReducer
,
duel
:
duelReducer
,
},
});
...
...
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