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
bf079b75
Commit
bf079b75
authored
Jul 14, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
count중 나가도 오류 없게 만듬
parent
dfca8a59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
GameServer.js
GameServer.js
+3
-3
server.js
server.js
+7
-2
No files found.
GameServer.js
View file @
bf079b75
...
...
@@ -87,11 +87,11 @@ GameServer.enterRoom = function(roomIdx, playerData)
console
.
log
(
'
[
'
+
playerData
.
id
+
'
] entered to room #
'
+
room
.
roomNum
);
playerData
.
socketId
.
emit
(
'
enterRoom
'
);
room
.
endTime
=
Date
.
now
()
+
6000
;
// 테스트로 6초로 남겨둠
if
(
room
.
currentPlayer
.
length
>=
this
.
startCount
)
{
if
(
room
.
currentPhase
===
this
.
Phase
.
READY
)
// start count
{
room
.
endTime
=
Date
.
now
()
+
15000
;
// 테스트로 15초로 남겨둠
this
.
announceToRoom
(
room
.
roomNum
,
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
room
.
endTime
});
}
else
if
(
room
.
currentPhase
===
this
.
Phase
.
COUNT
)
// countinue count
...
...
@@ -185,14 +185,14 @@ GameServer.announceToRoom = function(roomIdx, _message, _data = null)
{
this
.
playingRoom
[
roomIdx
].
currentSocket
.
forEach
(
function
(
element
)
{
element
.
socketId
.
emit
(
_message
,
_data
);
if
(
element
!=
null
)
element
.
socketId
.
emit
(
_message
,
_data
);
});
}
GameServer
.
announceToTarget
=
function
(
roomIdx
,
targetNum
,
_message
,
_data
=
null
)
{
let
targetSocket
=
this
.
playingRoom
[
roomIdx
].
currentSocket
.
find
(
function
(
element
)
{
return
element
.
id
===
targetNum
;
return
(
element
!=
null
&&
element
.
id
===
targetNum
)
;
});
if
(
targetSocket
!=
undefined
&&
targetSocket
.
isReceivable
)
targetSocket
.
socketId
.
emit
(
_message
,
_data
);
}
...
...
server.js
View file @
bf079b75
...
...
@@ -53,7 +53,6 @@ io.on('connection', function(socket)
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
GameServer
.
enterEmptyRoom
(
socket
.
playerData
);
}
});
socket
.
on
(
'
setPlayerTyping
'
,
function
(
msg
)
// number playerTyping
...
...
@@ -84,6 +83,7 @@ io.on('connection', function(socket)
socket
.
on
(
'
attack
'
,
function
(
msg
)
{
GameServer
.
announceToTarget
(
GameServer
.
findRoomIndex
(
msg
.
roomNum
),
msg
.
target
,
'
attacked
'
,
msg
);
//console.log('find ' + msg.target + ' by ' + msg.attacker.idNum + ' with ' + msg.text);
let
target
=
GameServer
.
findPlayer
(
msg
.
target
);
if
(
target
!=
null
)
{
...
...
@@ -136,10 +136,15 @@ io.on('connection', function(socket)
// 룸에서도 제거
if
(
data
.
currentRoom
!=
null
)
{
if
(
data
.
currentRoom
.
currentPhase
===
GameServer
.
Phase
.
READY
)
if
(
data
.
currentRoom
.
currentPhase
===
GameServer
.
Phase
.
READY
||
data
.
currentRoom
.
currentPhase
===
GameServer
.
Phase
.
COUNT
)
{
data
.
currentRoom
.
currentPlayer
[
data
.
playingData
.
index
]
=
null
;
data
.
currentRoom
.
currentSocket
[
data
.
playingData
.
index
]
=
null
;
data
.
currentRoom
.
aliveCount
--
;
if
(
data
.
currentRoom
.
aliveCount
<
GameServer
.
startCount
)
{
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
data
.
currentRoom
.
roomNum
),
'
setCount
'
,
{
isEnable
:
false
,
endTime
:
0
});
}
}
else
if
(
data
.
playingData
.
isAlive
)
{
...
...
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