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
c885c2b6
Commit
c885c2b6
authored
Jul 14, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Plain Diff
시즌 10호 머지
parents
80e1e2f6
3fe7e321
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
192 additions
and
43 deletions
+192
-43
GameServer.js
GameServer.js
+63
-6
Client.js
js/Client.js
+35
-7
ScenesData.js
js/ScenesData.js
+47
-1
WordSpace.js
js/WordSpace.js
+12
-15
main.js
js/main.js
+1
-1
server.js
server.js
+34
-13
No files found.
GameServer.js
View file @
c885c2b6
var
GameServer
=
GameServer
||
{};
var
GameServer
=
GameServer
||
{};
GameServer
.
Phase
=
{
READY
:
0
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
Phase
=
{
READY
:
0
,
COUNT
:
-
1
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
startCount
=
2
;
GameServer
.
startCount
=
2
;
GameServer
.
currentPlayer
=
[];
GameServer
.
currentPlayer
=
[];
...
@@ -18,26 +18,29 @@ GameServer.findPlayer = function(playerId)
...
@@ -18,26 +18,29 @@ GameServer.findPlayer = function(playerId)
{
{
var
idx
=
this
.
currentPlayer
.
findIndex
(
function
(
element
)
var
idx
=
this
.
currentPlayer
.
findIndex
(
function
(
element
)
{
{
return
element
.
id
===
socket
;
return
element
.
id
===
playerId
;
});
});
if
(
idx
!=
-
1
)
return
this
.
currentPlayer
[
idx
];
if
(
idx
!=
-
1
)
return
this
.
currentPlayer
[
idx
];
else
else
{
{
console
.
log
(
'
[ERR] wrong playerId to find
'
);
console
.
log
(
'
[ERR] wrong playerId
(
'
+
playerId
+
'
)
to find
'
);
return
null
;
return
null
;
}
}
}
}
GameServer
.
nextRoomNumber
=
0
;
GameServer
.
nextRoomNumber
=
0
;
GameServer
.
makeRoom
=
function
()
GameServer
.
makeRoom
=
function
()
{
{
// 나중에 room 삭제시 생긴 null에 채워넣는식으로 만들것, 룸의 인덱스를 고정
var
roomOption
=
var
roomOption
=
{
{
roomNum
:
GameServer
.
nextRoomNumber
++
,
roomNum
:
GameServer
.
nextRoomNumber
++
,
maxPlayer
:
5
,
maxPlayer
:
100
,
nextRank
:
5
,
nextRank
:
100
,
currentPlayer
:
[],
currentPlayer
:
[],
aliveCount
:
0
,
currentSocket
:
[],
currentSocket
:
[],
currentPhase
:
GameServer
.
Phase
.
READY
,
currentPhase
:
GameServer
.
Phase
.
READY
,
endTime
:
0
,
rateArrangePoint
:
300
,
rateArrangePoint
:
300
,
maxTypingPlayer
:
null
,
maxTypingPlayer
:
null
,
...
@@ -80,10 +83,26 @@ GameServer.enterRoom = function(roomIdx, playerData)
...
@@ -80,10 +83,26 @@ GameServer.enterRoom = function(roomIdx, playerData)
}
}
playerData
.
playingData
=
player
;
playerData
.
playingData
=
player
;
playerData
.
currentRoom
=
room
;
playerData
.
currentRoom
=
room
;
room
.
aliveCount
++
;
console
.
log
(
'
[
'
+
playerData
.
id
+
'
] entered to room #
'
+
room
.
roomNum
);
console
.
log
(
'
[
'
+
playerData
.
id
+
'
] entered to room #
'
+
room
.
roomNum
);
playerData
.
socketId
.
emit
(
'
enterRoom
'
);
playerData
.
socketId
.
emit
(
'
enterRoom
'
);
if
(
room
.
currentPlayer
.
length
>=
this
.
startCount
)
GameServer
.
startRoom
(
roomIdx
);
room
.
endTime
=
Date
.
now
()
+
6000
;
// 테스트로 6초로 남겨둠
if
(
room
.
currentPlayer
.
length
>=
this
.
startCount
)
{
if
(
room
.
currentPhase
===
this
.
Phase
.
READY
)
// start count
{
this
.
announceToRoom
(
room
.
roomNum
,
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
room
.
endTime
});
}
else
if
(
room
.
currentPhase
===
this
.
Phase
.
COUNT
)
// countinue count
{
playerData
.
socketId
.
emit
(
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
room
.
endTime
});
}
}
else
// stop count
{
this
.
announceToRoom
(
room
.
roomNum
,
'
setCount
'
,
{
isEnable
:
false
,
endTime
:
0
});
}
return
room
;
return
room
;
}
}
GameServer
.
enterEmptyRoom
=
function
(
playerData
)
GameServer
.
enterEmptyRoom
=
function
(
playerData
)
...
@@ -107,6 +126,8 @@ GameServer.startRoom = function(roomIdx)
...
@@ -107,6 +126,8 @@ GameServer.startRoom = function(roomIdx)
{
{
let
room
=
this
.
playingRoom
[
roomIdx
];
let
room
=
this
.
playingRoom
[
roomIdx
];
room
.
currentPhase
=
this
.
Phase
.
START
;
room
.
currentPhase
=
this
.
Phase
.
START
;
room
.
nextRank
=
room
.
currentPlayer
.
length
;
room
.
aliveCount
=
room
.
currentPlayer
.
length
;
room
.
maxTypingPlayer
=
room
.
currentPlayer
[
0
];
room
.
maxTypingPlayer
=
room
.
currentPlayer
[
0
];
room
.
minTypingPlayer
=
room
.
currentPlayer
[
0
];
room
.
minTypingPlayer
=
room
.
currentPlayer
[
0
];
room
.
currentSocket
.
forEach
(
function
(
element
)
room
.
currentSocket
.
forEach
(
function
(
element
)
...
@@ -127,6 +148,39 @@ GameServer.startRoom = function(roomIdx)
...
@@ -127,6 +148,39 @@ GameServer.startRoom = function(roomIdx)
this
.
announceToRoom
(
roomIdx
,
'
changePhase
'
,
this
.
Phase
.
START
);
this
.
announceToRoom
(
roomIdx
,
'
changePhase
'
,
this
.
Phase
.
START
);
this
.
announceToRoom
(
roomIdx
,
'
startGame
'
);
this
.
announceToRoom
(
roomIdx
,
'
startGame
'
);
}
}
GameServer
.
playerDefeat
=
function
(
playerData
)
{
playerData
.
playingData
.
isAlive
=
false
;
playerData
.
playingData
.
rank
=
playerData
.
currentRoom
.
nextRank
--
;
playerData
.
isReceivable
=
false
;
playerData
.
currentRoom
.
aliveCount
--
;
if
(
playerData
.
playingData
.
lastAttacks
.
length
>
0
)
{
playerData
.
playingData
.
lastAttack
=
playerData
.
playingData
.
lastAttacks
[
playerData
.
playingData
.
lastAttacks
.
length
-
1
];
if
(
Date
.
now
()
-
playerData
.
playingData
.
lastAttack
.
time
>
40000
)
playerData
.
playingData
.
lastAttack
=
null
;
else
{
playerData
.
playingData
.
lastAttacks
.
forEach
(
function
(
element
)
{
if
(
Date
.
now
()
-
element
.
time
<
40000
&&
element
.
wordGrade
>
playerData
.
playingData
.
lastAttack
.
wordGrade
)
playerData
.
playingData
.
lastAttack
=
element
;
});
}
}
GameServer
.
announceToRoom
(
this
.
findRoomIndex
(
playerData
.
currentRoom
.
roomNum
),
'
defeat
'
,
playerData
.
playingData
);
console
.
log
(
'
[
'
+
playerData
.
id
+
'
]
'
+
'
defeated, rank:
'
+
playerData
.
playingData
.
rank
);
if
(
playerData
.
currentRoom
.
aliveCount
===
1
)
{
let
winner
=
playerData
.
currentRoom
.
currentPlayer
.
find
(
function
(
element
)
{
return
element
.
isAlive
;
});
GameServer
.
announceToRoom
(
this
.
findRoomIndex
(
playerData
.
currentRoom
.
roomNum
),
'
gameEnd
'
,
winner
);
GameServer
.
announceToTarget
(
this
.
findRoomIndex
(
playerData
.
currentRoom
.
roomNum
),
winner
.
id
,
'
alert
'
,
'
gameWin
'
);
console
.
log
(
'
[
'
+
winner
.
id
+
'
]
'
+
'
winner!
'
+
winner
.
nickname
);
}
}
GameServer
.
announceToRoom
=
function
(
roomIdx
,
_message
,
_data
=
null
)
GameServer
.
announceToRoom
=
function
(
roomIdx
,
_message
,
_data
=
null
)
{
{
this
.
playingRoom
[
roomIdx
].
currentSocket
.
forEach
(
function
(
element
)
this
.
playingRoom
[
roomIdx
].
currentSocket
.
forEach
(
function
(
element
)
...
@@ -154,7 +208,10 @@ class Player
...
@@ -154,7 +208,10 @@ class Player
this
.
nickname
=
playerData
.
nickname
;
this
.
nickname
=
playerData
.
nickname
;
this
.
isAlive
=
true
;
this
.
isAlive
=
true
;
this
.
rank
=
-
1
;
this
.
rank
=
-
1
;
this
.
playerTyping
=
0
;
this
.
playerTyping
=
0
;
this
.
lastAttacks
=
[];
// { attackerId, word, wordGrade, time }
this
.
lastAttack
=
null
;
}
}
}
}
...
...
js/Client.js
View file @
c885c2b6
...
@@ -2,18 +2,29 @@ var socket = io.connect();
...
@@ -2,18 +2,29 @@ var socket = io.connect();
// init account
// init account
socket
.
emit
(
'
idRequest
'
);
socket
.
emit
(
'
idRequest
'
);
socket
.
on
(
'
alert
'
,
function
(
msg
)
// string errorcode
{
let
toAlert
=
'
null alert
'
;
if
(
msg
===
'
errNicknameOverlaped
'
)
toAlert
=
'
이미 사용중인 닉네임입니다.
'
;
if
(
msg
===
'
gameWin
'
)
toAlert
=
'
승리!
'
;
alert
(
toAlert
);
});
socket
.
on
(
'
setId
'
,
function
(
msg
)
// {str, num playerNum}
socket
.
on
(
'
setId
'
,
function
(
msg
)
// {str, num playerNum}
{
{
console
.
log
(
msg
.
str
);
console
.
log
(
msg
.
str
);
PlayerData
.
idNum
=
msg
.
num
;
PlayerData
.
idNum
=
msg
.
num
;
});
});
socket
.
on
(
'
errNicknameOverlaped
'
,
function
()
{
alert
(
'
이미 사용중인 닉네임입니다.
'
);
});
socket
.
on
(
'
enterRoom
'
,
function
()
socket
.
on
(
'
enterRoom
'
,
function
()
{
{
game
.
scene
.
remove
(
'
menuScene
'
);
game
.
scene
.
remove
(
'
menuScene
'
);
game
.
scene
.
start
(
'
roomScene
'
);
});
socket
.
on
(
'
setCount
'
,
function
(
msg
)
{
ScenesData
.
roomScene
.
isCounting
=
msg
.
isEnable
;
ScenesData
.
roomScene
.
endTime
=
msg
.
endTime
;
});
});
// init game
// init game
...
@@ -26,6 +37,7 @@ socket.on('syncRoomData', function(msg) // {num roomNum, [] players}
...
@@ -26,6 +37,7 @@ socket.on('syncRoomData', function(msg) // {num roomNum, [] players}
});
});
socket
.
on
(
'
startGame
'
,
function
()
socket
.
on
(
'
startGame
'
,
function
()
{
{
game
.
scene
.
remove
(
'
roomScene
'
);
game
.
scene
.
start
(
'
gameScene
'
);
game
.
scene
.
start
(
'
gameScene
'
);
});
});
...
@@ -42,13 +54,29 @@ socket.on('setPlayerTypingRate', function(msg) // number playerTypingRate
...
@@ -42,13 +54,29 @@ socket.on('setPlayerTypingRate', function(msg) // number playerTypingRate
});
});
socket
.
on
(
'
attacked
'
,
function
(
msg
)
// object attackData
socket
.
on
(
'
attacked
'
,
function
(
msg
)
// object attackData
{
{
WordSpace
.
generateWord
.
Attack
(
WordSpace
.
gameSceneForTest
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
isStrong
);
setTimeout
(
function
()
{
WordSpace
.
generateWord
.
Attack
(
ScenesData
.
gameScene
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
isStrong
);
},
4000
);
});
});
socket
.
on
(
'
defeat
'
,
function
(
msg
)
// object player
socket
.
on
(
'
defeat
'
,
function
(
msg
)
// object player
{
{
RoomData
.
players
[
msg
.
index
]
=
msg
;
RoomData
.
players
[
msg
.
index
]
=
msg
;
RoomData
.
aliveCount
--
;
RoomData
.
aliveCount
--
;
if
(
msg
.
lastAttack
!=
null
)
{
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated by
'
+
msg
.
lastAttack
.
attacker
+
'
, with
'
+
msg
.
lastAttack
.
word
);
WordSpace
.
killLogForTest
+=
(
'
\n
'
+
msg
.
lastAttack
.
attacker
+
'
--
'
+
msg
.
lastAttack
.
word
+
'
->
'
+
RoomData
.
players
[
msg
.
index
].
nickname
);
}
else
{
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated
'
);
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated
'
);
WordSpace
.
killLogForTest
+=
(
'
\n
--Suicide->
'
+
RoomData
.
players
[
msg
.
index
].
nickname
);
}
});
socket
.
on
(
'
gameEnd
'
,
function
(
msg
)
// object player
{
console
.
log
(
msg
.
nickname
+
'
Win!!!!!!
'
);
});
});
socket
.
on
(
'
attackSucceed
'
,
function
(
msg
)
socket
.
on
(
'
attackSucceed
'
,
function
(
msg
)
...
...
js/ScenesData.js
View file @
c885c2b6
var
ScenesData
=
ScenesData
||
{};
var
menuScene
=
new
Phaser
.
Class
(
var
menuScene
=
new
Phaser
.
Class
(
{
{
Extends
:
Phaser
.
Scene
,
Extends
:
Phaser
.
Scene
,
...
@@ -11,6 +13,7 @@ var menuScene = new Phaser.Class(
...
@@ -11,6 +13,7 @@ var menuScene = new Phaser.Class(
preload
:
function
()
preload
:
function
()
{
{
ScenesData
.
menuScene
=
this
;
Input
.
inputField
.
loadImage
(
this
);
Input
.
inputField
.
loadImage
(
this
);
BackGround
.
loadImage
(
this
);
BackGround
.
loadImage
(
this
);
Audio
.
loadSound
(
this
);
Audio
.
loadSound
(
this
);
...
@@ -24,6 +27,47 @@ var menuScene = new Phaser.Class(
...
@@ -24,6 +27,47 @@ var menuScene = new Phaser.Class(
}
}
});
});
var
roomScene
=
new
Phaser
.
Class
(
{
Extends
:
Phaser
.
Scene
,
initialize
:
function
roomScene
()
{
Phaser
.
Scene
.
call
(
this
,
{
key
:
'
roomScene
'
});
},
preload
:
function
()
{
ScenesData
.
roomScene
=
this
;
},
create
:
function
()
{
this
.
isCounting
=
false
;
this
.
endTime
=
0
;
this
.
countText
=
this
.
add
.
text
(
640
,
360
,
'
사람들을 위해 대기중입니다...
'
).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
);
},
update
:
function
()
{
if
(
this
.
isCounting
)
{
this
.
countText
.
setText
((
this
.
endTime
-
Date
.
now
())
/
1000
);
if
(
this
.
endTime
-
Date
.
now
()
<
0
)
{
socket
.
emit
(
'
endCount
'
);
this
.
isCounting
=
false
;
}
}
else
{
this
.
countText
.
setText
(
'
사람들을 위해 대기중입니다...
'
);
}
}
})
var
gameScene
=
new
Phaser
.
Class
(
var
gameScene
=
new
Phaser
.
Class
(
{
{
Extends
:
Phaser
.
Scene
,
Extends
:
Phaser
.
Scene
,
...
@@ -37,6 +81,7 @@ var gameScene = new Phaser.Class(
...
@@ -37,6 +81,7 @@ var gameScene = new Phaser.Class(
preload
:
function
()
preload
:
function
()
{
{
ScenesData
.
gameScene
=
this
;
BackGround
.
loadImage
(
this
);
BackGround
.
loadImage
(
this
);
WordSpace
.
loadImage
(
this
);
WordSpace
.
loadImage
(
this
);
Input
.
inputField
.
loadImage
(
this
);
Input
.
inputField
.
loadImage
(
this
);
...
@@ -65,7 +110,7 @@ var gameScene = new Phaser.Class(
...
@@ -65,7 +110,7 @@ var gameScene = new Phaser.Class(
WordSpace
.
setPlayerTyping
.
initiate
(
this
);
WordSpace
.
setPlayerTyping
.
initiate
(
this
);
WordSpace
.
nameWordTextForTest
=
WordSpace
.
gameSceneForTest
.
add
.
text
(
50
,
400
,
'
현재 가진 호패들 : 없음
'
).
setDepth
(
10
).
setColor
(
'
#000000
'
);
WordSpace
.
nameWordTextForTest
=
ScenesData
.
gameScene
.
add
.
text
(
50
,
400
,
'
현재 가진 호패들 : 없음
'
).
setDepth
(
10
).
setColor
(
'
#000000
'
);
WordSpace
.
nameQueue
.
initiate
();
WordSpace
.
nameQueue
.
initiate
();
RoomData
.
players
.
forEach
(
function
(
element
)
RoomData
.
players
.
forEach
(
function
(
element
)
{
{
...
@@ -112,6 +157,7 @@ var gameScene = new Phaser.Class(
...
@@ -112,6 +157,7 @@ var gameScene = new Phaser.Class(
WordSpace
.
nameWordTextForTest
.
setText
(
'
현재 가진 호패들 :
\n
'
+
tempNames
);
WordSpace
.
nameWordTextForTest
.
setText
(
'
현재 가진 호패들 :
\n
'
+
tempNames
);
WordSpace
.
weightTextObjForTest
.
setText
(
'
뇌의 무게: (현재)
'
+
WordSpace
.
totalWeight
+
'
/
'
+
WordSpace
.
brainCapacity
+
'
(전체)
'
);
WordSpace
.
weightTextObjForTest
.
setText
(
'
뇌의 무게: (현재)
'
+
WordSpace
.
totalWeight
+
'
/
'
+
WordSpace
.
brainCapacity
+
'
(전체)
'
);
WordSpace
.
killLogTextForTest
.
setText
(
WordSpace
.
killLogForTest
);
WordSpace
.
setPlayerTyping
.
add
(
''
);
WordSpace
.
setPlayerTyping
.
add
(
''
);
}
}
});
});
\ No newline at end of file
js/WordSpace.js
View file @
c885c2b6
...
@@ -3,9 +3,10 @@ var WordSpace = WordSpace || {};
...
@@ -3,9 +3,10 @@ var WordSpace = WordSpace || {};
WordSpace
.
test
=
null
;
WordSpace
.
test
=
null
;
// for test
// for test
WordSpace
.
gameSceneForTest
=
null
;
WordSpace
.
weightTextObjForTest
=
null
;
WordSpace
.
weightTextObjForTest
=
null
;
WordSpace
.
nameWordTextForTest
=
null
;
WordSpace
.
nameWordTextForTest
=
null
;
WordSpace
.
killLogTextForTest
=
null
;
WordSpace
.
killLogForTest
=
''
;
WordSpace
.
nextWordCode
=
0
;
WordSpace
.
nextWordCode
=
0
;
WordSpace
.
totalWeight
=
0
;
//현재 단어 무게 총합
WordSpace
.
totalWeight
=
0
;
//현재 단어 무게 총합
...
@@ -73,7 +74,7 @@ WordSpace.gameOverCycle = new Cycle(gameOver);
...
@@ -73,7 +74,7 @@ WordSpace.gameOverCycle = new Cycle(gameOver);
//호패 생성 사이클
//호패 생성 사이클
WordSpace
.
nameCycle
=
new
Cycle
(
function
()
WordSpace
.
nameCycle
=
new
Cycle
(
function
()
{
{
WordSpace
.
generateWord
.
Name
(
WordSpace
.
gameSceneForTest
,
false
,
null
);
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
});
});
//이건 뭐지
//이건 뭐지
WordSpace
.
varAdjustCycle
=
new
Cycle
(
function
()
WordSpace
.
varAdjustCycle
=
new
Cycle
(
function
()
...
@@ -147,8 +148,8 @@ WordSpace.AdjustVarByPhase = function(typingRate, phase)
...
@@ -147,8 +148,8 @@ WordSpace.AdjustVarByPhase = function(typingRate, phase)
WordSpace
.
GradeProb
[
1
]
=
0.8
-
0.45
*
typingRate
;
WordSpace
.
GradeProb
[
1
]
=
0.8
-
0.45
*
typingRate
;
WordSpace
.
GradeProb
[
2
]
=
0.9
-
0.15
*
typingRate
;
WordSpace
.
GradeProb
[
2
]
=
0.9
-
0.15
*
typingRate
;
}
}
WordSpace
.
wordCycle
.
resetCycle
(
WordSpace
.
gameSceneForTest
,
WordSpace
.
delay
.
WordSpawn
,
WordSpace
.
wordCycle
.
currentCycle
.
getElapsed
(),
true
);
WordSpace
.
wordCycle
.
resetCycle
(
ScenesData
.
gameScene
,
WordSpace
.
delay
.
WordSpawn
,
WordSpace
.
wordCycle
.
currentCycle
.
getElapsed
(),
true
);
WordSpace
.
nameCycle
.
resetCycle
(
WordSpace
.
gameSceneForTest
,
WordSpace
.
delay
.
NameSpawn
,
WordSpace
.
nameCycle
.
currentCycle
.
getElapsed
(),
true
);
WordSpace
.
nameCycle
.
resetCycle
(
ScenesData
.
gameScene
,
WordSpace
.
delay
.
NameSpawn
,
WordSpace
.
nameCycle
.
currentCycle
.
getElapsed
(),
true
);
}
}
WordSpace
.
attackGauge
=
WordSpace
.
attackGauge
=
...
@@ -239,10 +240,8 @@ WordSpace.loadImage = function(scene)
...
@@ -239,10 +240,8 @@ WordSpace.loadImage = function(scene)
scene
.
load
.
image
(
'
nameBgr
'
+
i
,
'
assets/placeholder/name
'
+
i
+
'
.png
'
);
scene
.
load
.
image
(
'
nameBgr
'
+
i
,
'
assets/placeholder/name
'
+
i
+
'
.png
'
);
}
}
WordSpace
.
gameSceneForTest
=
scene
;
// for test
WordSpace
.
weightTextObjForTest
=
scene
.
add
.
text
(
100
,
75
,
'
뇌의 무게: (현재) 0 / 100 (전체)
'
).
setDepth
(
10
).
setColor
(
'
#000000
'
);
WordSpace
.
weightTextObjForTest
=
scene
.
add
.
text
(
100
,
75
,
'
뇌의 무게: (현재) 0 / 100 (전체)
'
).
setDepth
(
10
).
setColor
(
'
#000000
'
);
WordSpace
.
killLogTextForTest
=
scene
.
add
.
text
(
1100
,
50
,
WordSpace
.
killLogForTest
).
setDepth
(
10
).
setColor
(
'
#000000
'
).
setAlign
(
'
right
'
);
scene
.
load
.
image
(
'
test
'
,
'
assets/placeholder/attackalert1.png
'
)
}
}
WordSpace
.
generateWord
=
WordSpace
.
generateWord
=
...
@@ -302,7 +301,7 @@ WordSpace.setGameOverTimer = function()
...
@@ -302,7 +301,7 @@ WordSpace.setGameOverTimer = function()
if
(
this
.
brainCapacity
<
this
.
totalWeight
&&
!
this
.
isTimerOn
)
if
(
this
.
brainCapacity
<
this
.
totalWeight
&&
!
this
.
isTimerOn
)
{
{
this
.
isTimerOn
=
true
;
this
.
isTimerOn
=
true
;
WordSpace
.
gameOverCycle
.
resetCycle
(
WordSpace
.
gameSceneForTest
,
WordSpace
.
delay
.
GameOver
,
0
,
false
);
WordSpace
.
gameOverCycle
.
resetCycle
(
ScenesData
.
gameScene
,
WordSpace
.
delay
.
GameOver
,
0
,
false
);
}
}
}
}
...
@@ -329,12 +328,12 @@ WordSpace.findWord = function(wordText)
...
@@ -329,12 +328,12 @@ WordSpace.findWord = function(wordText)
if
(
weightest
.
wordWeight
<
element
.
wordWeight
)
weightest
=
element
;
if
(
weightest
.
wordWeight
<
element
.
wordWeight
)
weightest
=
element
;
});
});
weightest
.
destroy
();
weightest
.
destroy
();
WordSpace
.
nameCycle
.
resetCycle
(
WordSpace
.
gameSceneForTest
,
WordSpace
.
delay
.
NameSpawn
,
WordSpace
.
nameCycle
.
currentCycle
.
getElapsed
()
+
WordSpace
.
NameSpawnReduce
,
true
);
WordSpace
.
nameCycle
.
resetCycle
(
ScenesData
.
gameScene
,
WordSpace
.
delay
.
NameSpawn
,
WordSpace
.
nameCycle
.
currentCycle
.
getElapsed
()
+
WordSpace
.
NameSpawnReduce
,
true
);
while
(
WordSpace
.
totalWordNum
<
5
)
while
(
WordSpace
.
totalWordNum
<
5
)
{
{
WordSpace
.
genWordByProb
(
WordSpace
.
gameSceneForTest
);
WordSpace
.
genWordByProb
(
ScenesData
.
gameScene
);
WordSpace
.
wordCycle
.
resetCycle
(
WordSpace
.
gameSceneForTest
,
WordSpace
.
delay
.
WordSpawn
,
0
);
WordSpace
.
wordCycle
.
resetCycle
(
ScenesData
.
gameScene
,
WordSpace
.
delay
.
WordSpawn
,
0
);
}
}
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
}
}
...
@@ -417,10 +416,8 @@ WordSpace.attack = function(wordText, grade)
...
@@ -417,10 +416,8 @@ WordSpace.attack = function(wordText, grade)
element
.
physicsObj
.
destroy
();
element
.
physicsObj
.
destroy
();
element
.
wordObj
.
destroy
();
element
.
wordObj
.
destroy
();
});
});
//테스트용, 자기 자신에게 공격함
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
//WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData, false);
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
WordSpace
.
generateWord
.
Name
(
WordSpace
.
gameSceneForTest
,
false
,
null
);
WordSpace
.
generateWord
.
Name
(
WordSpace
.
gameSceneForTest
,
false
,
null
);
WordSpace
.
nameGroup
=
[];
WordSpace
.
nameGroup
=
[];
WordSpace
.
attackGauge
.
resetValue
();
WordSpace
.
attackGauge
.
resetValue
();
...
...
js/main.js
View file @
c885c2b6
...
@@ -14,7 +14,7 @@ var config = {
...
@@ -14,7 +14,7 @@ var config = {
}
}
},
},
backgroundColor
:
Phaser
.
Display
.
Color
.
HexStringToColor
(
'
#F0CB85
'
).
color
,
//GetColor(245,208,138),
backgroundColor
:
Phaser
.
Display
.
Color
.
HexStringToColor
(
'
#F0CB85
'
).
color
,
//GetColor(245,208,138),
scene
:
[
menuScene
,
gameScene
]
scene
:
[
menuScene
,
roomScene
,
gameScene
]
};
};
var
game
=
new
Phaser
.
Game
(
config
)
var
game
=
new
Phaser
.
Game
(
config
)
...
...
server.js
View file @
c885c2b6
...
@@ -46,7 +46,7 @@ io.on('connection', function(socket)
...
@@ -46,7 +46,7 @@ io.on('connection', function(socket)
{
{
if
(
element
.
nickname
===
msg
)
isAlreadyHave
=
true
;
if
(
element
.
nickname
===
msg
)
isAlreadyHave
=
true
;
});
});
if
(
isAlreadyHave
)
socket
.
emit
(
'
errNicknameOverlaped
'
);
if
(
isAlreadyHave
)
socket
.
emit
(
'
alert
'
,
'
errNicknameOverlaped
'
);
else
else
{
{
socket
.
playerData
.
nickname
=
msg
;
socket
.
playerData
.
nickname
=
msg
;
...
@@ -72,19 +72,42 @@ io.on('connection', function(socket)
...
@@ -72,19 +72,42 @@ io.on('connection', function(socket)
socket
.
emit
(
'
setPlayerTypingRate
'
,
playerTypingRate
);
socket
.
emit
(
'
setPlayerTypingRate
'
,
playerTypingRate
);
});
});
socket
.
on
(
'
endCount
'
,
function
()
{
socket
.
playerData
.
currentRoom
.
aliveCount
--
;
if
(
socket
.
playerData
.
currentRoom
.
aliveCount
===
0
)
{
GameServer
.
startRoom
(
GameServer
.
findRoomIndex
(
socket
.
playerData
.
currentRoom
.
roomNum
));
}
});
socket
.
on
(
'
attack
'
,
function
(
msg
)
socket
.
on
(
'
attack
'
,
function
(
msg
)
{
{
GameServer
.
announceToTarget
(
GameServer
.
findRoomIndex
(
msg
.
roomNum
),
msg
.
target
,
'
attacked
'
,
msg
);
GameServer
.
announceToTarget
(
GameServer
.
findRoomIndex
(
msg
.
roomNum
),
msg
.
target
,
'
attacked
'
,
msg
);
let
target
=
GameServer
.
findPlayer
(
msg
.
target
);
if
(
target
!=
null
)
{
let
dataToPush
=
{
attackerId
:
msg
.
attacker
.
idNum
,
attacker
:
msg
.
attacker
.
nickname
,
word
:
msg
.
text
,
wordGrade
:
msg
.
grade
,
time
:
Date
.
now
()
}
if
(
target
.
playingData
.
lastAttacks
.
length
<
5
)
target
.
playingData
.
lastAttacks
.
push
(
dataToPush
);
else
{
target
.
playingData
.
lastAttacks
.
splice
(
0
,
1
);
target
.
playingData
.
lastAttacks
.
push
(
dataToPush
);
}
}
});
});
socket
.
on
(
'
defeated
'
,
function
()
socket
.
on
(
'
defeated
'
,
function
()
{
{
socket
.
playerData
.
playingData
.
isAlive
=
false
;
GameServer
.
playerDefeat
(
socket
.
playerData
);
socket
.
playerData
.
playingData
.
rank
=
socket
.
playerData
.
currentRoom
.
nextRank
--
;
socket
.
playerData
.
isReceivable
=
false
;
// 패배단어 체크
GameServer
.
announceToRoom
(
socket
.
playerData
.
currentRoom
.
roomNum
,
'
defeat
'
,
socket
.
playerData
.
playingData
);
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
]
'
+
'
defeated
'
);
});
});
socket
.
on
(
'
defenseFailed
'
,
function
(
msg
)
socket
.
on
(
'
defenseFailed
'
,
function
(
msg
)
...
@@ -95,7 +118,6 @@ io.on('connection', function(socket)
...
@@ -95,7 +118,6 @@ io.on('connection', function(socket)
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
{
{
let
data
=
socket
.
playerData
;
let
data
=
socket
.
playerData
;
console
.
log
(
'
[
'
+
data
.
id
+
'
] client disconnected, reason:
'
+
reason
);
if
(
typeof
data
.
id
===
undefined
)
if
(
typeof
data
.
id
===
undefined
)
{
{
console
.
log
(
'
[ERROR] data.id is undefined
'
);
console
.
log
(
'
[ERROR] data.id is undefined
'
);
...
@@ -103,6 +125,7 @@ io.on('connection', function(socket)
...
@@ -103,6 +125,7 @@ io.on('connection', function(socket)
}
}
else
// data.id is not undefined
else
// data.id is not undefined
{
{
console
.
log
(
'
[
'
+
data
.
id
+
'
] client disconnected, reason:
'
+
reason
);
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
{
{
return
element
.
id
===
data
.
id
;
return
element
.
id
===
data
.
id
;
...
@@ -118,13 +141,11 @@ io.on('connection', function(socket)
...
@@ -118,13 +141,11 @@ io.on('connection', function(socket)
data
.
currentRoom
.
currentPlayer
[
data
.
playingData
.
index
]
=
null
;
data
.
currentRoom
.
currentPlayer
[
data
.
playingData
.
index
]
=
null
;
data
.
currentRoom
.
currentSocket
[
data
.
playingData
.
index
]
=
null
;
data
.
currentRoom
.
currentSocket
[
data
.
playingData
.
index
]
=
null
;
}
}
else
else
if
(
data
.
playingData
.
isAlive
)
{
{
data
.
playingData
.
isAlive
=
false
;
GameServer
.
playerDefeat
(
socket
.
playerData
);
if
(
data
.
playingData
.
rank
===
-
1
)
data
.
playingData
.
rank
=
data
.
currentRoom
.
nextRank
--
;
data
.
currentRoom
.
currentSocket
[
data
.
playingData
.
index
].
isReceivable
=
false
;
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
'
);
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