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
e0cba657
Commit
e0cba657
authored
Jul 09, 2019
by
18신대성
Committed by
18류지석
Jul 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
닉네임 중복되면 다시쓰게함
parent
23ea3f31
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
5 deletions
+23
-5
GameServer.js
GameServer.js
+1
-0
Client.js
js/Client.js
+8
-0
Input.js
js/Input.js
+1
-2
server.js
server.js
+13
-3
No files found.
GameServer.js
View file @
e0cba657
...
...
@@ -82,6 +82,7 @@ GameServer.enterRoom = function(roomIdx, playerData)
playerData
.
currentRoom
=
room
;
console
.
log
(
'
[
'
+
playerData
.
id
+
'
] entered to room #
'
+
room
.
roomNum
);
playerData
.
socketId
.
emit
(
'
enterRoom
'
);
if
(
room
.
currentPlayer
.
length
>=
this
.
startCount
)
GameServer
.
startRoom
(
roomIdx
);
return
room
;
}
...
...
js/Client.js
View file @
e0cba657
...
...
@@ -7,6 +7,14 @@ socket.on('setId', function(msg) // {str, num playerNum}
console
.
log
(
msg
.
str
);
PlayerData
.
idNum
=
msg
.
num
;
});
socket
.
on
(
'
errNicknameOverlaped
'
,
function
()
{
alert
(
'
이미 사용중인 닉네임입니다.
'
);
});
socket
.
on
(
'
enterRoom
'
,
function
()
{
game
.
scene
.
remove
(
'
menuScene
'
);
});
// init game
socket
.
on
(
'
syncRoomData
'
,
function
(
msg
)
// {num roomNum, [] players}
...
...
js/Input.js
View file @
e0cba657
...
...
@@ -26,12 +26,11 @@ Input.gameSceneEnterReaction = function()
Input
.
menuSceneEnterReaction
=
function
()
{
Input
.
convInput
=
Input
.
removeConVow
(
Input
.
convInput
);
if
(
Input
.
convInput
.
length
>
0
)
if
(
Input
.
convInput
.
length
>
1
)
{
socket
.
emit
(
'
setNickname
'
,
Input
.
convInput
);
PlayerData
.
nickname
=
Input
.
convInput
;
Input
.
reset
();
game
.
scene
.
remove
(
'
menuScene
'
);
}
else
{
...
...
server.js
View file @
e0cba657
...
...
@@ -41,9 +41,19 @@ io.on('connection', function(socket)
socket
.
on
(
'
setNickname
'
,
function
(
msg
)
// string new_nickname
{
socket
.
playerData
.
nickname
=
msg
;
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
GameServer
.
enterEmptyRoom
(
socket
.
playerData
);
let
isAlreadyHave
=
false
;
GameServer
.
currentPlayer
.
forEach
(
function
(
element
)
{
if
(
element
.
nickname
===
msg
)
isAlreadyHave
=
true
;
});
if
(
isAlreadyHave
)
socket
.
emit
(
'
errNicknameOverlaped
'
);
else
{
socket
.
playerData
.
nickname
=
msg
;
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
GameServer
.
enterEmptyRoom
(
socket
.
playerData
);
}
});
socket
.
on
(
'
setPlayerTyping
'
,
function
(
msg
)
// number playerTyping
...
...
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