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
558f5612
Commit
558f5612
authored
Dec 17, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add TimeLimit reducer
parent
df8c68bf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
1 deletion
+38
-1
src/reducers/duel/mod.ts
src/reducers/duel/mod.ts
+5
-0
src/reducers/duel/timeLimit.ts
src/reducers/duel/timeLimit.ts
+22
-0
src/service/duel/timeLimit.ts
src/service/duel/timeLimit.ts
+9
-0
src/service/onSocketMessage.ts
src/service/onSocketMessage.ts
+2
-1
No files found.
src/reducers/duel/mod.ts
View file @
558f5612
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +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
{
TimeLimit
,
updateTimeLimitImpl
}
from
"
./timeLimit
"
;
import
{
import
{
Hands
,
Hands
,
handsCase
,
handsCase
,
...
@@ -21,6 +22,8 @@ export interface DuelState {
...
@@ -21,6 +22,8 @@ export interface DuelState {
opInitInfo
?:
InitInfo
;
// 对手的初始状态
opInitInfo
?:
InitInfo
;
// 对手的初始状态
meHands
?:
Hands
;
// 自己的手牌
meHands
?:
Hands
;
// 自己的手牌
opHands
?:
Hands
;
// 对手的手牌
opHands
?:
Hands
;
// 对手的手牌
meTimeLimit
?:
TimeLimit
;
// 自己的计时
opTimeLimit
?:
TimeLimit
;
// 对手的计时
currentPlayer
?:
number
;
// 当前的操作方
currentPlayer
?:
number
;
// 当前的操作方
currentPhase
?:
string
;
// 当前的阶段
currentPhase
?:
string
;
// 当前的阶段
}
}
...
@@ -37,6 +40,7 @@ const duelSlice = createSlice({
...
@@ -37,6 +40,7 @@ const duelSlice = createSlice({
infoInit
:
infoInitImpl
,
infoInit
:
infoInitImpl
,
updateTurn
:
newTurnImpl
,
updateTurn
:
newTurnImpl
,
updatePhase
:
newPhaseImpl
,
updatePhase
:
newPhaseImpl
,
updateTimeLimit
:
updateTimeLimitImpl
,
// 手牌相关`Reducer`
// 手牌相关`Reducer`
clearHandsInteractivity
:
clearHandsInteractivityImpl
,
clearHandsInteractivity
:
clearHandsInteractivityImpl
,
...
@@ -54,6 +58,7 @@ export const {
...
@@ -54,6 +58,7 @@ export const {
updatePhase
,
updatePhase
,
clearHandsInteractivity
,
clearHandsInteractivity
,
addHandsInteractivity
,
addHandsInteractivity
,
updateTimeLimit
,
}
=
duelSlice
.
actions
;
}
=
duelSlice
.
actions
;
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
export
const
selectDuelHsStart
=
(
state
:
RootState
)
=>
{
return
state
.
duel
.
meInitInfo
!=
null
;
return
state
.
duel
.
meInitInfo
!=
null
;
...
...
src/reducers/duel/timeLimit.ts
0 → 100644
View file @
558f5612
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
judgeSelf
}
from
"
./util
"
;
export
interface
TimeLimit
{
leftTime
:
number
;
}
// 更新计时
export
const
updateTimeLimitImpl
:
CaseReducer
<
DuelState
,
PayloadAction
<
[
number
,
number
]
>
>
=
(
state
,
action
)
=>
{
const
player
=
action
.
payload
[
0
];
const
leftTime
=
action
.
payload
[
1
];
if
(
judgeSelf
(
player
,
state
))
{
state
.
meTimeLimit
=
{
leftTime
};
}
else
{
state
.
opTimeLimit
=
{
leftTime
};
}
};
src/service/duel/timeLimit.ts
0 → 100644
View file @
558f5612
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
store
}
from
"
../../store
"
;
import
{
updateTimeLimit
}
from
"
../../reducers/duel/mod
"
;
export
default
function
handleTimeLimit
(
timeLimit
:
ygopro
.
StocTimeLimit
)
{
const
dispatch
=
store
.
dispatch
;
dispatch
(
updateTimeLimit
([
timeLimit
.
player
,
timeLimit
.
left_time
]));
}
src/service/onSocketMessage.ts
View file @
558f5612
...
@@ -14,6 +14,7 @@ import handleSelectHand from "./mora/selectHand";
...
@@ -14,6 +14,7 @@ import handleSelectHand from "./mora/selectHand";
import
handleSelectTp
from
"
./mora/selectTp
"
;
import
handleSelectTp
from
"
./mora/selectTp
"
;
import
handleDeckCount
from
"
./mora/deckCount
"
;
import
handleDeckCount
from
"
./mora/deckCount
"
;
import
handleGameMsg
from
"
./duel/gameMsg
"
;
import
handleGameMsg
from
"
./duel/gameMsg
"
;
import
handleTimeLimit
from
"
./duel/timeLimit
"
;
/*
/*
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
* 先将从长连接中读取到的二进制数据通过Adapter转成protobuf结构体,
...
@@ -88,7 +89,7 @@ export default function handleSocketMessage(e: MessageEvent) {
...
@@ -88,7 +89,7 @@ export default function handleSocketMessage(e: MessageEvent) {
break
;
break
;
}
}
case
"
stoc_time_limit
"
:
{
case
"
stoc_time_limit
"
:
{
// TODO
handleTimeLimit
(
pb
.
stoc_time_limit
);
break
;
break
;
}
}
...
...
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