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
6c48f7ee
Commit
6c48f7ee
authored
Oct 06, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update WaitRoom.tsx and add WaitRoom.css
parent
7afc3b00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
54 deletions
+128
-54
src/JoinRoom.tsx
src/JoinRoom.tsx
+1
-1
src/WaitRoom.tsx
src/WaitRoom.tsx
+102
-45
src/css/JoinRoom.css
src/css/JoinRoom.css
+13
-0
src/css/WaitRoom.css
src/css/WaitRoom.css
+12
-8
No files found.
src/JoinRoom.tsx
View file @
6c48f7ee
import
React
,
{
useState
,
ChangeEvent
}
from
"
react
"
;
import
React
,
{
useState
,
ChangeEvent
}
from
"
react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
"
./css/
Wait
Room.css
"
;
import
"
./css/
Join
Room.css
"
;
export
default
function
JoinRoom
()
{
export
default
function
JoinRoom
()
{
const
[
player
,
setPlayer
]
=
useState
(
""
);
const
[
player
,
setPlayer
]
=
useState
(
""
);
...
...
src/WaitRoom.tsx
View file @
6c48f7ee
...
@@ -2,6 +2,12 @@ import React, { useRef, useEffect, useState } from "react";
...
@@ -2,6 +2,12 @@ import React, { useRef, useEffect, useState } from "react";
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
ygopro
}
from
"
./api/idl/ocgcore
"
;
import
{
ygopro
}
from
"
./api/idl/ocgcore
"
;
import
{
fetchDeck
,
IDeck
}
from
"
./Card
"
;
import
{
fetchDeck
,
IDeck
}
from
"
./Card
"
;
import
"
./css/WaitRoom.css
"
;
type
Player
=
{
name
?:
string
;
state
?:
string
;
};
export
default
function
WaitRoom
()
{
export
default
function
WaitRoom
()
{
const
params
=
useParams
<
{
const
params
=
useParams
<
{
...
@@ -13,6 +19,9 @@ export default function WaitRoom() {
...
@@ -13,6 +19,9 @@ export default function WaitRoom() {
const
[
joined
,
setJoined
]
=
useState
<
boolean
>
(
false
);
const
[
joined
,
setJoined
]
=
useState
<
boolean
>
(
false
);
const
[
chat
,
setChat
]
=
useState
<
string
>
(
""
);
const
[
chat
,
setChat
]
=
useState
<
string
>
(
""
);
const
[
choseDeck
,
setChoseDeck
]
=
useState
<
boolean
>
(
false
);
const
[
choseDeck
,
setChoseDeck
]
=
useState
<
boolean
>
(
false
);
const
[
observerCount
,
setObserverCount
]
=
useState
<
number
>
(
0
);
const
[
player0
,
setPlayer0
]
=
useState
<
Player
>
({});
const
[
player1
,
setPlayer1
]
=
useState
<
Player
>
({});
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
const
ws
=
useRef
<
WebSocket
|
null
>
(
null
);
...
@@ -64,41 +73,73 @@ export default function WaitRoom() {
...
@@ -64,41 +73,73 @@ export default function WaitRoom() {
case
"
stoc_hs_player_change
"
:
{
case
"
stoc_hs_player_change
"
:
{
const
change
=
pb
.
stoc_hs_player_change
;
const
change
=
pb
.
stoc_hs_player_change
;
switch
(
change
.
state
)
{
if
(
change
.
pos
>
1
)
{
case
ygopro
.
StocHsPlayerChange
.
State
.
UNKNOWN
:
{
console
.
log
(
"
Currently only supported 2v2 mode.
"
);
console
.
log
(
"
Unknown HsPlayerChange State
"
);
}
else
{
switch
(
change
.
state
)
{
break
;
case
ygopro
.
StocHsPlayerChange
.
State
.
UNKNOWN
:
{
}
console
.
log
(
"
Unknown HsPlayerChange State
"
);
case
ygopro
.
StocHsPlayerChange
.
State
.
MOVE
:
{
console
.
log
(
break
;
"
Player
"
+
change
.
pos
+
"
moved to
"
+
change
.
moved_pos
}
);
case
ygopro
.
StocHsPlayerChange
.
State
.
MOVE
:
{
console
.
log
(
break
;
"
Player
"
+
change
.
pos
+
"
moved to
"
+
change
.
moved_pos
}
);
case
ygopro
.
StocHsPlayerChange
.
State
.
READY
:
{
console
.
log
(
"
Player
"
+
change
.
pos
+
"
has ready
"
);
let
src
=
change
.
pos
;
let
dst
=
change
.
moved_pos
;
break
;
}
if
(
src
===
0
&&
dst
===
1
)
{
case
ygopro
.
StocHsPlayerChange
.
State
.
NO_READY
:
{
setPlayer1
(
player0
);
console
.
log
(
"
Player
"
+
change
.
pos
+
"
not ready
"
);
setPlayer0
({});
}
else
if
(
src
===
1
&&
dst
===
0
)
{
break
;
setPlayer0
(
player1
);
}
setPlayer1
({});
case
ygopro
.
StocHsPlayerChange
.
State
.
LEAVE
:
{
}
console
.
log
(
"
Player
"
+
change
.
pos
+
"
has leave
"
);
break
;
break
;
}
}
case
ygopro
.
StocHsPlayerChange
.
State
.
READY
:
{
case
ygopro
.
StocHsPlayerChange
.
State
.
TO_OBSERVER
:
{
console
.
log
(
"
Player
"
+
change
.
pos
+
"
has ready
"
);
console
.
log
(
"
Player
"
+
change
.
pos
+
"
has moved to observer
"
);
const
state
=
"
ready
"
;
break
;
let
player
=
change
.
pos
==
0
?
player0
:
player1
;
}
player
.
state
=
state
;
default
:
{
break
;
change
.
pos
==
0
?
setPlayer0
(
player
)
:
setPlayer1
(
player
);
break
;
}
case
ygopro
.
StocHsPlayerChange
.
State
.
NO_READY
:
{
console
.
log
(
"
Player
"
+
change
.
pos
+
"
not ready
"
);
const
state
=
"
not ready
"
;
let
player
=
change
.
pos
==
0
?
player0
:
player1
;
player
.
state
=
state
;
change
.
pos
==
0
?
setPlayer0
(
player
)
:
setPlayer1
(
player
);
break
;
}
case
ygopro
.
StocHsPlayerChange
.
State
.
LEAVE
:
{
console
.
log
(
"
Player
"
+
change
.
pos
+
"
has leave
"
);
change
.
pos
==
0
?
setPlayer0
({})
:
setPlayer1
({});
break
;
}
case
ygopro
.
StocHsPlayerChange
.
State
.
TO_OBSERVER
:
{
console
.
log
(
"
Player
"
+
change
.
pos
+
"
has moved to observer
"
);
change
.
pos
==
0
?
setPlayer0
({})
:
setPlayer1
({});
setObserverCount
(
observerCount
+
1
);
break
;
}
default
:
{
break
;
}
}
}
}
}
...
@@ -107,7 +148,7 @@ export default function WaitRoom() {
...
@@ -107,7 +148,7 @@ export default function WaitRoom() {
case
"
stoc_hs_watch_change
"
:
{
case
"
stoc_hs_watch_change
"
:
{
const
count
=
pb
.
stoc_hs_watch_change
.
count
;
const
count
=
pb
.
stoc_hs_watch_change
.
count
;
console
.
log
(
"
Watch change to
"
+
count
);
setObserverCount
(
count
);
break
;
break
;
}
}
default
:
{
default
:
{
...
@@ -142,15 +183,31 @@ export default function WaitRoom() {
...
@@ -142,15 +183,31 @@ export default function WaitRoom() {
};
};
return
(
return
(
<
div
>
<
div
className=
"container"
>
<
p
>
joined:
{
joined
?
"
true
"
:
"
false
"
}
</
p
>
<
div
className=
"playerRegion"
>
<
button
disabled=
{
!
joined
}
onClick=
{
handleChoseDeck
}
>
<
h2
>
{
joined
?
"
Room Joined!
"
:
"
Room Not Joined.
"
}
</
h2
>
choose hero.ydk
<
p
>
</
button
>
<
button
disabled=
{
!
joined
}
onClick=
{
handleChoseDeck
}
>
<
button
disabled=
{
!
choseDeck
}
onClick=
{
handleChoseReady
}
>
choose hero.ydk
ready
</
button
>
</
button
>
</
p
>
<
p
>
chat:
{
chat
}
</
p
>
<
p
>
<
button
disabled=
{
!
choseDeck
}
onClick=
{
handleChoseReady
}
>
ready
</
button
>
</
p
>
</
div
>
<
div
className=
"roomRegion"
>
<
h2
>
Room PassWd:
{
passWd
}
</
h2
>
<
p
>
player0:
{
player0
.
name
}
{
player0
.
state
}
</
p
>
<
p
>
player1:
{
player1
.
name
}
{
player1
.
state
}
</
p
>
<
p
>
observer:
{
observerCount
}
</
p
>
<
p
>
chat:
{
chat
}
</
p
>
</
div
>
</
div
>
</
div
>
);
);
}
}
...
...
src/css/JoinRoom.css
0 → 100644
View file @
6c48f7ee
body
{
margin
:
0
;
justify-content
:
center
;
}
div
{
margin
:
auto
;
padding
:
10%
;
}
p
{
text-align
:
center
;
}
src/css/WaitRoom.css
View file @
6c48f7ee
body
{
.container
{
margin
:
0
;
display
:
flex
;
justify-content
:
center
;
}
div
{
margin
:
auto
;
margin
:
auto
;
padding
:
10%
;
padding
:
0
;
}
}
p
{
.playerRegion
{
text-align
:
center
;
text-align
:
center
;
flex
:
1
;
}
.roomRegion
{
flex
:
1
;
}
.roomRegion
>
p
{
text-align
:
start
;
}
}
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