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
276169f8
Commit
276169f8
authored
Jul 09, 2019
by
18신대성
Committed by
18류지석
Jul 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
왜였는지 모를 에러 수정
parent
13860f74
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
16 deletions
+26
-16
GameServer.js
GameServer.js
+3
-3
WordObject.js
js/WordObject.js
+1
-1
server.js
server.js
+22
-12
No files found.
GameServer.js
View file @
276169f8
var
GameServer
=
GameServer
||
{};
var
GameServer
=
GameServer
||
{};
GameServer
.
Phase
=
{
READY
:
0
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
Phase
=
{
READY
:
0
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
startCount
=
4
;
GameServer
.
startCount
=
2
;
GameServer
.
currentPlayer
=
[];
GameServer
.
currentPlayer
=
[];
GameServer
.
playingRoom
=
[];
GameServer
.
playingRoom
=
[];
...
@@ -98,10 +98,10 @@ GameServer.startRoom = function(roomIdx)
...
@@ -98,10 +98,10 @@ GameServer.startRoom = function(roomIdx)
roomNum
:
room
.
roomNum
,
roomNum
:
room
.
roomNum
,
players
:
room
.
currentPlayer
players
:
room
.
currentPlayer
};
};
console
.
log
(
toSync
);
//
console.log(toSync);
this
.
announceToRoom
(
roomIdx
,
'
syncRoomData
'
,
toSync
);
this
.
announceToRoom
(
roomIdx
,
'
syncRoomData
'
,
toSync
);
console
.
log
(
'
[ROOM#
'
+
room
.
roomNum
+
'
] Game Start
'
);
console
.
log
(
'
[ROOM#
'
+
room
.
roomNum
+
'
] Game Start
with
'
+
room
.
currentPlayer
.
length
+
'
players
'
);
this
.
announceToRoom
(
roomIdx
,
'
changePhase
'
,
this
.
Phase
.
START
);
this
.
announceToRoom
(
roomIdx
,
'
changePhase
'
,
this
.
Phase
.
START
);
this
.
announceToRoom
(
roomIdx
,
'
startGame
'
);
this
.
announceToRoom
(
roomIdx
,
'
startGame
'
);
}
}
...
...
js/WordObject.js
View file @
276169f8
...
@@ -14,7 +14,7 @@ class WordObject
...
@@ -14,7 +14,7 @@ class WordObject
instantiate
(
scene
,
lenRate
)
instantiate
(
scene
,
lenRate
)
{
{
let
p
=
[{
x
:
3
,
y
:
0.7
},
{
x
:
20
,
y
:
1.
8
}];
let
p
=
[{
x
:
3
,
y
:
0.7
},
{
x
:
20
,
y
:
1.
2
}];
let
scale
=
((
p
[
1
].
y
-
p
[
0
].
y
)
/
(
p
[
1
].
x
-
p
[
0
].
x
))
*
(
this
.
wordWeight
-
p
[
0
].
x
)
+
p
[
0
].
y
;
let
scale
=
((
p
[
1
].
y
-
p
[
0
].
y
)
/
(
p
[
1
].
x
-
p
[
0
].
x
))
*
(
this
.
wordWeight
-
p
[
0
].
x
)
+
p
[
0
].
y
;
let
fontscale
=
25
;
let
fontscale
=
25
;
var
random
=
WordSpace
.
getSpawnPoint
(
lenRate
);
var
random
=
WordSpace
.
getSpawnPoint
(
lenRate
);
...
...
server.js
View file @
276169f8
...
@@ -78,23 +78,33 @@ io.on('connection', function(socket)
...
@@ -78,23 +78,33 @@ io.on('connection', function(socket)
});
});
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
{
let
data
=
socket
.
playerData
;
console
.
log
(
'
[
'
+
data
.
id
+
'
] client disconnected, reason:
'
+
reason
);
if
(
data
.
id
===
undefined
)
{
console
.
log
(
'
[ERROR] data.id is undefined
'
);
console
.
log
(
GameServer
.
currentPlayer
);
}
else
// data.id is not undefined
{
{
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
{
{
return
element
.
id
===
socket
.
playerD
ata
.
id
;
return
element
.
id
===
d
ata
.
id
;
});
});
if
(
idxToDel
!=
-
1
)
if
(
idxToDel
!=
-
1
)
{
{
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] client disconnected, reason:
'
+
reason
);
GameServer
.
currentPlayer
.
splice
(
idxToDel
,
1
);
GameServer
.
currentPlayer
.
splice
(
idxToDel
,
1
);
// 룸에서도 제거
// 룸에서도 제거
if
(
socket
.
playerD
ata
.
currentRoom
!=
null
)
if
(
d
ata
.
currentRoom
!=
null
)
{
{
socket
.
playerData
.
playingData
.
isAlive
=
false
;
data
.
playingData
.
isAlive
=
false
;
if
(
socket
.
playerData
.
playingData
.
rank
===
-
1
)
socket
.
playerData
.
playingData
.
rank
=
socket
.
playerData
.
currentRoom
.
nextRank
--
;
if
(
data
.
playingData
.
rank
===
-
1
)
data
.
playingData
.
rank
=
data
.
currentRoom
.
nextRank
--
;
socket
.
playerData
.
currentRoom
.
currentSocket
.
splice
(
socket
.
playerData
.
playingData
.
index
,
1
);
data
.
currentRoom
.
currentSocket
.
splice
(
data
.
playingData
.
index
,
1
);
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
socket
.
playerData
.
currentRoom
.
roomNum
),
'
userDisconnect
'
,
socket
.
playerData
.
playingData
);
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
data
.
currentRoom
.
roomNum
),
'
userDisconnect
'
,
data
.
playingData
);
}
}
}
console
.
log
(
'
[
'
+
data
.
id
+
'
] disconnect complete
'
);
}
}
});
});
});
});
\ No newline at end of file
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