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
7d51dbda
Commit
7d51dbda
authored
Aug 15, 2019
by
18신대성
Committed by
18손재민
Aug 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1등이 정해진 이후로는 통신을 안하도록 바꿈
parent
bd3b9a82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
16 deletions
+41
-16
GameServer.js
GameServer.js
+41
-16
No files found.
GameServer.js
View file @
7d51dbda
...
...
@@ -2,7 +2,7 @@ var GameServer = GameServer || {};
GameServer
.
serverNumber
=
-
1
;
GameServer
.
Phase
=
{
READY
:
0
,
COUNT
:
-
1
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
Phase
=
{
READY
:
0
,
COUNT
:
-
1
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
,
GAMEEND
:
4
};
GameServer
.
connectCount
=
0
;
GameServer
.
disconnectCount
=
0
;
...
...
@@ -215,13 +215,31 @@ class GameRoom
clearTimeout
(
this
.
startTimer
);
this
.
startTimer
=
undefined
;
}
this
.
announceToRoom
(
'
enterRoom
'
);
this
.
announceToRoom
(
'
syncRoomScene
'
,
this
.
currentPlayer
);
this
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
false
,
endTime
:
0
,
playerCount
:
this
.
currentPlayer
.
length
,
isEnter
:
false
,
player
:
{
id
:
-
1
}
});
console
.
error
(
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed
'
);
if
(
this
.
currentPhase
!=
GameServer
.
Phase
.
GAMEEND
)
{
this
.
announceToRoom
(
'
enterRoom
'
);
this
.
announceToRoom
(
'
syncRoomScene
'
,
this
.
currentPlayer
);
this
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
false
,
endTime
:
0
,
playerCount
:
this
.
currentPlayer
.
length
,
isEnter
:
false
,
player
:
{
id
:
-
1
}
});
console
.
error
(
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed
'
);
}
else
{
this
.
startTime
=
0
;
this
.
currentPlayer
=
[];
this
.
aliveCount
=
0
;
this
.
currentSocket
=
[];
this
.
currentPhase
=
GameServer
.
Phase
.
READY
;
this
.
phaseChanger
=
-
1
;
this
.
countEndTime
=
0
;
this
.
rateArrangePoint
=
300
;
this
.
maxTypingPlayer
=
null
;
this
.
minTypingPlayer
=
null
;
console
.
log
(
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed with End of Game
'
);
}
}
startRoom
()
...
...
@@ -308,20 +326,26 @@ class GameRoom
announceToRoom
(
_message
,
_data
=
null
)
{
this
.
currentSocket
.
forEach
(
function
(
element
)
if
(
this
.
currentPhase
!=
GameServer
.
Phase
.
GAMEEND
)
{
if
(
element
.
playerData
.
playingData
.
isInThisRoom
)
element
.
emit
(
_message
,
_data
);
});
this
.
currentSocket
.
forEach
(
function
(
element
)
{
if
(
element
.
playerData
.
playingData
.
isInThisRoom
)
element
.
emit
(
_message
,
_data
);
});
}
}
announceToTarget
(
targetId
,
_message
,
_data
=
null
)
{
let
targetSocketIndex
=
this
.
currentSocket
.
findIndex
(
function
(
element
)
if
(
this
.
currentPhase
!=
GameServer
.
Phase
.
GAMEEND
)
{
return
element
.
playerData
.
id
===
targetId
;
});
//console.log('send to ' + targetSocketIndex + ', receivable? ' + this.currentSocket[targetSocketIndex].playerData.isReceivable);
if
(
targetSocketIndex
!=
-
1
&&
this
.
currentSocket
[
targetSocketIndex
].
playerData
.
isReceivable
)
this
.
currentSocket
[
targetSocketIndex
].
emit
(
_message
,
_data
);
let
targetSocketIndex
=
this
.
currentSocket
.
findIndex
(
function
(
element
)
{
return
element
.
playerData
.
id
===
targetId
;
});
//console.log('send to ' + targetSocketIndex + ', receivable? ' + this.currentSocket[targetSocketIndex].playerData.isReceivable);
if
(
targetSocketIndex
!=
-
1
&&
this
.
currentSocket
[
targetSocketIndex
].
playerData
.
isReceivable
)
this
.
currentSocket
[
targetSocketIndex
].
emit
(
_message
,
_data
);
}
}
}
...
...
@@ -391,6 +415,7 @@ class Player
});
room
.
announceToRoom
(
'
gameEnd
'
,
winner
);
room
.
announceToTarget
(
winner
.
id
,
'
alert
'
,
'
gameWin
'
);
room
.
currentPhase
=
GameServer
.
Phase
.
GAMEEND
;
console
.
log
(
'
[
'
+
winner
.
id
+
'
]
'
+
'
winner!
'
+
winner
.
nickname
);
}
}
...
...
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