Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sejong25
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Tear of Sejong
sejong25
Commits
b2cdc152
Commit
b2cdc152
authored
Aug 15, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'server' into gameScene
parents
332c0b9c
d51c3d3c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
13 deletions
+11
-13
GameServer.js
GameServer.js
+8
-1
server.js
server.js
+3
-12
No files found.
GameServer.js
View file @
b2cdc152
...
...
@@ -35,7 +35,9 @@ GameServer.enterEmptyRoom = function(playerSocket)
let
emptyRoomIndex
=
-
1
;
for
(
let
i
=
0
;
i
<
this
.
playingRoom
.
length
;
i
++
)
{
if
((
this
.
playingRoom
[
i
].
currentPhase
===
this
.
Phase
.
READY
||
this
.
playingRoom
[
i
].
currentPhase
===
this
.
Phase
.
COUNT
)
&&
this
.
playingRoom
[
i
].
maxPlayer
>
this
.
playingRoom
[
i
].
currentPlayer
.
length
)
if
((
this
.
playingRoom
[
i
].
currentPhase
===
this
.
Phase
.
READY
||
this
.
playingRoom
[
i
].
currentPhase
===
this
.
Phase
.
COUNT
)
&&
this
.
playingRoom
[
i
].
maxPlayer
>
this
.
playingRoom
[
i
].
currentPlayer
.
length
&&
this
.
playingRoom
[
i
].
checkHopae
(
playerSocket
.
playerData
.
nickname
))
{
emptyRoomIndex
=
i
;
break
;
...
...
@@ -116,6 +118,11 @@ class GameRoom
console
.
log
(
'
[LOG] new room #
'
+
this
.
roomId
+
'
made, roomCount:
'
+
GameServer
.
playingRoom
.
length
);
}
checkHopae
(
newHopae
)
{
return
!
this
.
currentPlayer
.
includes
((
element
)
=>
element
.
nickname
===
newHopae
);
}
enterRoom
(
playerSocket
)
{
let
playerInst
=
new
Player
(
this
,
playerSocket
.
playerData
);
...
...
server.js
View file @
b2cdc152
...
...
@@ -47,20 +47,11 @@ io.on('connection', function(socket)
{
if
(
msg
.
length
<
1
)
socket
.
emit
(
'
alert
'
,
'
errNicknameEmpty
'
);
else
{
let
isAlreadyHave
=
false
;
GameServer
.
currentPlayer
.
forEach
(
function
(
element
)
{
if
(
element
.
playerData
.
nickname
===
msg
)
isAlreadyHave
=
true
;
});
if
(
isAlreadyHave
)
socket
.
emit
(
'
alert
'
,
'
errNicknameOverlaped
'
);
else
{
socket
.
playerData
.
nickname
=
msg
;
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
GameServer
.
enterEmptyRoom
(
socket
);
}
}
});
socket
.
on
(
'
exitFromRoom
'
,
function
(
msg
){
...
...
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