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
61daf001
Commit
61daf001
authored
Jul 17, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
일단 최대한 안터지는 선까지 고침, 그래도 많이 민감하므로 주의하세요
parent
9976f316
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
GameServer.js
GameServer.js
+11
-6
server.js
server.js
+1
-1
No files found.
GameServer.js
View file @
61daf001
...
...
@@ -128,25 +128,30 @@ GameServer.startRoom = function(roomIdx)
{
let
room
=
this
.
playingRoom
[
roomIdx
];
room
.
currentPhase
=
this
.
Phase
.
START
;
room
.
nextRank
=
room
.
currentPlayer
.
length
;
room
.
aliveCount
=
room
.
currentPlayer
.
length
;
room
.
maxTypingPlayer
=
room
.
currentPlayer
[
0
];
room
.
minTypingPlayer
=
room
.
currentPlayer
[
0
];
room
.
currentSocket
.
forEach
(
function
(
element
)
{
element
.
isReceivable
=
true
;
if
(
element
!=
null
)
element
.
isReceivable
=
true
;
});
let
syncPlayers
=
[];
room
.
currentPlayer
.
forEach
(
function
(
element
)
{
if
(
element
!=
null
)
syncPlayers
.
push
(
element
);
});
room
.
nextRank
=
syncPlayers
.
length
;
room
.
aliveCount
=
syncPlayers
.
length
;
// sync roomData
let
toSync
=
{
roomNum
:
room
.
roomNum
,
players
:
room
.
currentPlayer
players
:
syncPlayers
};
//console.log(toSync);
this
.
announceToRoom
(
roomIdx
,
'
syncRoomData
'
,
toSync
);
console
.
log
(
'
[ROOM#
'
+
room
.
roomNum
+
'
] Game Start with
'
+
room
.
currentPlayer
.
length
+
'
players
'
);
console
.
log
(
'
[ROOM#
'
+
room
.
roomNum
+
'
] Game Start with
'
+
syncPlayers
.
length
+
'
players
'
);
this
.
announceToRoom
(
roomIdx
,
'
changePhase
'
,
this
.
Phase
.
START
);
this
.
announceToRoom
(
roomIdx
,
'
startGame
'
);
}
...
...
@@ -176,7 +181,7 @@ GameServer.playerDefeat = function(playerData)
{
let
winner
=
playerData
.
currentRoom
.
currentPlayer
.
find
(
function
(
element
)
{
return
element
.
isAlive
;
return
element
!=
null
&&
element
.
isAlive
;
});
GameServer
.
announceToRoom
(
this
.
findRoomIndex
(
playerData
.
currentRoom
.
roomNum
),
'
gameEnd
'
,
winner
);
GameServer
.
announceToTarget
(
this
.
findRoomIndex
(
playerData
.
currentRoom
.
roomNum
),
winner
.
id
,
'
alert
'
,
'
gameWin
'
);
...
...
server.js
View file @
61daf001
...
...
@@ -150,8 +150,8 @@ io.on('connection', function(socket)
else
if
(
data
.
playingData
.
isAlive
)
{
GameServer
.
playerDefeat
(
socket
.
playerData
);
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
data
.
currentRoom
.
roomNum
),
'
userDisconnect
'
,
data
.
playingData
);
}
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
data
.
currentRoom
.
roomNum
),
'
userDisconnect
'
,
data
.
playingData
);
}
}
console
.
log
(
'
[
'
+
data
.
id
+
'
] disconnect complete
'
);
...
...
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