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
fe02e6f3
Commit
fe02e6f3
authored
Oct 18, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add playerSlice
parent
6d6df46d
Pipeline
#17245
passed with stage
in 1 minute and 6 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
0 deletions
+75
-0
src/reducers/playerSlice.ts
src/reducers/playerSlice.ts
+65
-0
src/store.ts
src/store.ts
+2
-0
src/ui/WaitRoom.tsx
src/ui/WaitRoom.tsx
+8
-0
No files found.
src/reducers/playerSlice.ts
0 → 100644
View file @
fe02e6f3
import
{
createSlice
,
PayloadAction
}
from
"
@reduxjs/toolkit
"
;
import
{
RootState
}
from
"
../store
"
;
export
type
Player
=
{
name
?:
string
;
state
?:
string
;
isHost
?:
boolean
;
};
export
interface
playerState
{
player0
:
Player
;
player1
:
Player
;
observerCount
:
number
;
}
const
initialState
:
playerState
=
{
player0
:
{},
player1
:
{},
observerCount
:
0
,
};
const
playerSlice
=
createSlice
({
name
:
"
player
"
,
initialState
,
reducers
:
{
player0Enter
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
.
player0
.
name
=
action
.
payload
;
},
player1Enter
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
.
player1
.
name
=
action
.
payload
;
},
player0Update
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
.
player0
.
state
=
action
.
payload
;
},
player1Update
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
.
player1
.
state
=
action
.
payload
;
},
hostChange
:
(
state
,
action
:
PayloadAction
<
number
>
)
=>
{
const
i
=
action
.
payload
;
if
(
i
===
0
)
{
state
.
player0
.
isHost
=
true
;
state
.
player1
.
isHost
=
false
;
}
else
{
state
.
player1
.
isHost
=
true
;
state
.
player0
.
isHost
=
false
;
}
},
observerChange
:
(
state
,
action
:
PayloadAction
<
number
>
)
=>
{
state
.
observerCount
+=
action
.
payload
;
},
},
});
export
const
{
player0Enter
,
player1Enter
,
player0Update
,
player1Update
,
hostChange
,
observerChange
,
}
=
playerSlice
.
actions
;
export
const
selectPlayer0
=
(
state
:
RootState
)
=>
state
.
player
.
player0
;
export
const
selectPlayer1
=
(
state
:
RootState
)
=>
state
.
player
.
player1
;
export
default
playerSlice
.
reducer
;
src/store.ts
View file @
fe02e6f3
import
{
configureStore
}
from
"
@reduxjs/toolkit
"
;
import
joinedReducer
from
"
./reducers/joinSlice
"
;
import
chatReducer
from
"
./reducers/chatSlice
"
;
import
playerReducer
from
"
./reducers/playerSlice
"
;
export
const
store
=
configureStore
({
reducer
:
{
join
:
joinedReducer
,
chat
:
chatReducer
,
player
:
playerReducer
,
},
});
...
...
src/ui/WaitRoom.tsx
View file @
fe02e6f3
...
...
@@ -6,6 +6,14 @@ import "../css/WaitRoom.css";
import
{
useAppDispatch
,
useAppSelector
}
from
"
../hook
"
;
import
{
setJoined
,
selectJoined
}
from
"
../reducers/joinSlice
"
;
import
{
postChat
,
selectChat
}
from
"
../reducers/chatSlice
"
;
import
{
player0Enter
,
player1Enter
,
player0Update
,
player1Update
,
hostChange
,
observerChange
,
}
from
"
../reducers/playerSlice
"
;
type
Player
=
{
name
?:
string
;
...
...
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