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
442fd515
Commit
442fd515
authored
Aug 21, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'server'
parents
5af28e1d
8b5a3cef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
45 deletions
+58
-45
GameServer.js
GameServer.js
+11
-11
index.html
index.html
+21
-19
FirebaseClient.js
js/FirebaseClient.js
+16
-5
server.js
server.js
+10
-10
No files found.
GameServer.js
View file @
442fd515
...
...
@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId)
{
if
(
GameServer
.
playingRoom
[
i
].
roomId
===
roomId
)
return
GameServer
.
playingRoom
[
i
];
}
console
.
log
(
'
[ERR] no room with num
'
+
roomId
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ERR] no room with num
'
+
roomId
);
}
GameServer
.
findPlayerSocket
=
function
(
playerId
)
{
...
...
@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId)
if
(
idx
!=
-
1
)
return
this
.
currentPlayer
[
idx
];
else
{
console
.
log
(
'
[ERR] wrong playerId(
'
+
playerId
+
'
) to find
'
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ERR] wrong playerId(
'
+
playerId
+
'
) to find
'
);
return
null
;
}
}
...
...
@@ -115,7 +115,7 @@ class GameRoom
{
GameServer
.
playingRoom
[
this
.
roomIndex
]
=
this
;
}
console
.
log
(
'
[LOG] new room #
'
+
this
.
roomId
+
'
made, roomCount:
'
+
GameServer
.
playingRoom
.
length
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[LOG] new room #
'
+
this
.
roomId
+
'
made, roomCount:
'
+
GameServer
.
playingRoom
.
length
);
}
checkHopae
(
newHopae
)
...
...
@@ -136,7 +136,7 @@ class GameRoom
this
.
announceToTarget
(
playerInst
.
id
,
'
syncRoomScene
'
,
this
.
currentPlayer
);
this
.
currentPlayer
.
push
(
playerInst
);
console
.
log
(
'
[
'
+
playerInst
.
id
+
'
] entered to room #
'
+
this
.
roomId
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[
'
+
playerInst
.
id
+
'
] entered to room #
'
+
this
.
roomId
);
this
.
aliveCount
++
;
if
(
this
.
currentPlayer
.
length
>=
this
.
startCount
)
...
...
@@ -202,7 +202,7 @@ class GameRoom
return
;
}
}
console
.
log
(
'
[ERR] No player who have
'
+
playerId
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ERR] No player who have
'
+
playerId
);
return
;
}
...
...
@@ -223,7 +223,7 @@ class GameRoom
isEnable
:
false
,
endTime
:
0
,
playerCount
:
this
.
currentPlayer
.
length
,
isEnter
:
false
,
player
:
{
id
:
-
1
}
});
console
.
error
(
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed
'
);
console
.
error
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed
'
);
}
else
{
...
...
@@ -238,7 +238,7 @@ class GameRoom
this
.
rateArrangePoint
=
300
;
this
.
maxTypingPlayer
=
null
;
this
.
minTypingPlayer
=
null
;
console
.
log
(
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed with End of Game
'
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ROOM#
'
+
this
.
roomId
+
'
] room Refreshed with End of Game
'
);
}
}
...
...
@@ -261,7 +261,7 @@ class GameRoom
};
this
.
announceToRoom
(
'
syncRoomData
'
,
toSync
);
console
.
log
(
'
[ROOM#
'
+
this
.
roomId
+
'
] Game Start with
'
+
this
.
currentPlayer
.
length
+
'
players
'
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ROOM#
'
+
this
.
roomId
+
'
] Game Start with
'
+
this
.
currentPlayer
.
length
+
'
players
'
);
console
.
table
(
this
.
currentPlayer
);
this
.
announceToRoom
(
'
startGame
'
);
this
.
startTime
=
Date
.
now
();
...
...
@@ -309,7 +309,7 @@ class GameRoom
{
if
(
this
.
aliveCount
>
0
)
{
console
.
log
(
'
[ERR] can not destroy room#
'
+
this
.
roomId
+
'
, cause player left
'
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ERR] can not destroy room#
'
+
this
.
roomId
+
'
, cause player left
'
);
}
else
{
...
...
@@ -406,7 +406,7 @@ class Player
}
room
.
announceToRoom
(
'
defeat
'
,
this
);
console
.
log
(
'
[
'
+
this
.
id
+
'
] defeated, rank:
'
+
this
.
rank
+
'
,
'
+
room
.
aliveCount
+
'
player left
'
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[
'
+
this
.
id
+
'
] defeated, rank:
'
+
this
.
rank
+
'
,
'
+
room
.
aliveCount
+
'
player left
'
);
if
(
room
.
aliveCount
===
1
)
{
...
...
@@ -418,7 +418,7 @@ class Player
room
.
announceToRoom
(
'
gameEnd
'
,
winner
.
id
);
room
.
announceToTarget
(
winner
.
id
,
'
alert
'
,
'
gameWin
'
);
room
.
currentPhase
=
GameServer
.
Phase
.
GAMEEND
;
console
.
log
(
'
[
'
+
winner
.
id
+
'
]
'
+
'
winner!
'
+
winner
.
nickname
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[
'
+
winner
.
id
+
'
]
'
+
'
winner!
'
+
winner
.
nickname
);
}
}
}
...
...
index.html
View file @
442fd515
...
...
@@ -3,20 +3,20 @@
<head>
<meta
charset=
"utf-8"
/>
<script
src=
"/socket.io/socket.io.js"
></script>
<script
src=
"js/phaser.js"
></script>
<script
src=
"js/ScenesData.js"
></script>
<script
src=
"js/Background.js"
></script>
<script
src=
"js/Input.js"
></script>
<script
src=
"js/WordSpace.js"
></script>
<script
src=
"js/GameCycle.js"
></script>
<script
src=
"js/WordObject.js"
></script>
<script
src=
"js/WordReader.js"
></script>
<script
src=
"js/CSVParsing.js"
></script>
<script
src=
"js/SelectWord.js"
></script>
<script
src=
"js/BGMsound.js"
></script>
<script
src=
"js/Enums.js"
></script>
<script
src=
"js/ResourceLoader.js"
></script>
<script
src=
"js/UIObject.js"
></script>
<script
src=
"
/
js/phaser.js"
></script>
<script
src=
"
/
js/ScenesData.js"
></script>
<script
src=
"
/
js/Background.js"
></script>
<script
src=
"
/
js/Input.js"
></script>
<script
src=
"
/
js/WordSpace.js"
></script>
<script
src=
"
/
js/GameCycle.js"
></script>
<script
src=
"
/
js/WordObject.js"
></script>
<script
src=
"
/
js/WordReader.js"
></script>
<script
src=
"
/
js/CSVParsing.js"
></script>
<script
src=
"
/
js/SelectWord.js"
></script>
<script
src=
"
/
js/BGMsound.js"
></script>
<script
src=
"
/
js/Enums.js"
></script>
<script
src=
"
/
js/ResourceLoader.js"
></script>
<script
src=
"
/
js/UIObject.js"
></script>
<style
media=
'screen'
type=
'text/css'
>
@font-face
{
font-family
:
sejongFont
;
...
...
@@ -31,18 +31,20 @@
<style>
img
{
position
:
relative
;
width
:
100%
;
height
:
100%
;
z-index
:
0
;}
#dvLogin
{
position
:
absolute
;
left
:
65%
;
top
:
35%
;
width
:
30%
;
height
:
30%
;
padding
:
10px
;
background
:
black
;
z-index
:
1
;}
#notSupport
{
position
:
absolute
;
left
:
25%
;
top
:
25%
;
background
:
white
;
z-index
:
1
;
width
:
50%
;
height
:
50%
;
display
:
none
;}
</style>
</head>
<body>
<div
id=
"mainTitle"
>
<img
id=
"titleImg"
src=
"assets/image/background/title.png"
alt=
"title"
>
<img
id=
"titleImg"
src=
"
/
assets/image/background/title.png"
alt=
"title"
>
<div
id=
"dvLogin"
>
<input
id=
"userEmail"
type=
"email"
placeholder=
"email"
style=
"width: 100%; height: 10%;"
></br>
<input
id=
"userPassword"
type=
"password"
placeholder=
"password"
maxlength=
"17"
style=
"width: 100%; height: 10%;"
></br>
<button
id=
"joinBtn"
style=
"width: 100%; height: 10%;"
>
이메일로 가입하기
</button></br>
<button
id=
"emailBtn"
style=
"width: 100%; height: 10%;"
>
이메일로 로그인
</button></br>
<button
id=
"googleBtn"
style=
"width: 10%; height: 10%;"
><img
src=
"assets/title/googleBtn.png"
style=
"object-fit: contain"
></button></br>
<button
id=
"googleBtn"
style=
"width: 10%; height: 10%;"
><img
src=
"
/
assets/title/googleBtn.png"
style=
"object-fit: contain"
></button></br>
</div>
<p
id=
"notSupport"
>
해당하는 환경에서는 지원되지 않습니다. PC에서 이용 부탁드립니다.
</p>
</div>
<script
src=
"https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"
></script>
...
...
@@ -64,8 +66,8 @@
firebase
.
initializeApp
(
firebaseConfig
);
</script>
<script
src=
"js/Client.js"
></script>
<script
src=
"
js/M
ain.js"
></script>
<script
src=
"js/FirebaseClient.js"
></script>
<script
src=
"
/
js/Client.js"
></script>
<script
src=
"
/js/m
ain.js"
></script>
<script
src=
"
/
js/FirebaseClient.js"
></script>
</body>
</html>
\ No newline at end of file
js/FirebaseClient.js
View file @
442fd515
...
...
@@ -243,12 +243,23 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
document
.
addEventListener
(
'
DOMContentLoaded
'
,
function
()
{
window
.
fbClient
=
new
FirebaseClient
();
document
.
onkeydown
=
function
(
e
)
{
if
(
!
fbClient
.
isGameStarted
&&
e
.
keyCode
===
13
)
var
filter
=
"
win16|win32|win64|mac|macintel
"
;
if
(
navigator
.
platform
){
if
(
filter
.
indexOf
(
navigator
.
platform
.
toLowerCase
())
<
0
){
document
.
getElementById
(
'
dvLogin
'
).
style
.
display
=
'
none
'
;
document
.
getElementById
(
'
notSupport
'
).
style
.
display
=
'
block
'
;
}
else
{
fbClient
.
onEmailBtnClick
();
window
.
fbClient
=
new
FirebaseClient
();
document
.
onkeydown
=
function
(
e
)
{
if
(
!
fbClient
.
isGameStarted
&&
e
.
keyCode
===
13
)
{
fbClient
.
onEmailBtnClick
();
}
}
}
}
console
.
log
(
'
done load
'
);
...
...
server.js
View file @
442fd515
...
...
@@ -13,10 +13,10 @@ app.get('/', function(req, res) {
});
// http 기본 포트(80)에 서버 열기
server
.
listen
(
80
80
,
function
()
{
console
.
log
(
'
[SERVER] Listening on port
'
+
server
.
address
().
port
);
server
.
listen
(
80
,
function
()
{
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[SERVER] Listening on port
'
+
server
.
address
().
port
);
GameServer
.
serverNumber
=
Math
.
floor
(
Math
.
random
()
*
1000
+
1
);
console
.
log
(
'
[SERVER] server number is
'
+
GameServer
.
serverNumber
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[SERVER] server number is
'
+
GameServer
.
serverNumber
);
});
...
...
@@ -34,7 +34,7 @@ io.on('connection', function(socket)
isReceivable
:
false
};
GameServer
.
currentPlayer
.
push
(
socket
);
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] client request
'
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[
'
+
socket
.
playerData
.
id
+
'
] client request
'
);
socket
.
emit
(
'
setId
'
,
{
str
:
'
your number is
'
+
socket
.
playerData
.
id
,
...
...
@@ -49,7 +49,7 @@ io.on('connection', function(socket)
else
{
socket
.
playerData
.
nickname
=
msg
;
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
GameServer
.
enterEmptyRoom
(
socket
);
}
});
...
...
@@ -100,7 +100,7 @@ io.on('connection', function(socket)
},
1000
);
}
catch
(
e
)
{
console
.
error
(
'
[ERR] error catched on setPlayerTyping (
'
+
e
+
'
)
'
);
console
.
error
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ERR] error catched on setPlayerTyping (
'
+
e
+
'
)
'
);
socket
.
disconnect
();
}
});
...
...
@@ -123,7 +123,7 @@ io.on('connection', function(socket)
let
deads
=
room
.
currentPlayer
.
filter
(
element
=>
!
element
.
isAlive
);
if
(
room
.
aliveCount
!=
0
&&
room
.
currentPlayer
.
length
-
deads
.
length
>=
room
.
startCount
)
{
console
.
error
(
'
[ROOM#
'
+
room
.
roomId
+
'
] FORCE START!!!
'
);
console
.
error
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ROOM#
'
+
room
.
roomId
+
'
] FORCE START!!!
'
);
room
.
startRoom
();
deads
.
forEach
(
function
(
element
)
{
...
...
@@ -202,7 +202,7 @@ io.on('connection', function(socket)
let
data
=
socket
.
playerData
;
if
(
data
===
undefined
)
{
console
.
error
(
'
[ERROR] data is undefined
'
);
console
.
error
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[ERROR] data is undefined
'
);
console
.
table
(
GameServer
.
currentPlayer
);
GameServer
.
disconnectCount
--
;
}
...
...
@@ -223,7 +223,7 @@ io.on('connection', function(socket)
var
disconnectUser
=
function
(
data
,
reason
)
{
console
.
log
(
'
[
'
+
data
.
id
+
'
] client disconnected, reason:
'
+
reason
);
console
.
log
(
new
Date
().
toLocaleTimeString
(
'
ko-KR
'
)
+
'
[
'
+
data
.
id
+
'
] client disconnected, reason:
'
+
reason
);
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
{
return
element
.
playerData
.
id
===
data
.
id
;
...
...
@@ -245,5 +245,5 @@ var disconnectUser = function(data, reason)
}
GameServer
.
currentPlayer
.
splice
(
idxToDel
,
1
);
}
console
.
log
(
'
[
'
+
data
.
id
+
'
] disconnect complete
'
);
//
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