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
e987fbe2
Commit
e987fbe2
authored
Jul 12, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
끝내기 플레이어, 끝내기단어 결정 구현
공격시 4초 카운터 적용
parent
d6375559
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
5 deletions
+55
-5
GameServer.js
GameServer.js
+18
-3
Client.js
js/Client.js
+14
-2
ScenesData.js
js/ScenesData.js
+1
-0
WordSpace.js
js/WordSpace.js
+3
-0
server.js
server.js
+19
-0
No files found.
GameServer.js
View file @
e987fbe2
...
@@ -18,12 +18,12 @@ GameServer.findPlayer = function(playerId)
...
@@ -18,12 +18,12 @@ 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
;
}
}
}
}
...
@@ -137,7 +137,19 @@ GameServer.playerDefeat = function(playerData)
...
@@ -137,7 +137,19 @@ GameServer.playerDefeat = function(playerData)
playerData
.
playingData
.
rank
=
playerData
.
currentRoom
.
nextRank
--
;
playerData
.
playingData
.
rank
=
playerData
.
currentRoom
.
nextRank
--
;
playerData
.
isReceivable
=
false
;
playerData
.
isReceivable
=
false
;
playerData
.
currentRoom
.
aliveCount
--
;
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
);
GameServer
.
announceToRoom
(
this
.
findRoomIndex
(
playerData
.
currentRoom
.
roomNum
),
'
defeat
'
,
playerData
.
playingData
);
console
.
log
(
'
[
'
+
playerData
.
id
+
'
]
'
+
'
defeated, rank:
'
+
playerData
.
playingData
.
rank
);
console
.
log
(
'
[
'
+
playerData
.
id
+
'
]
'
+
'
defeated, rank:
'
+
playerData
.
playingData
.
rank
);
...
@@ -179,7 +191,10 @@ class Player
...
@@ -179,7 +191,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 @
e987fbe2
...
@@ -47,13 +47,25 @@ socket.on('setPlayerTypingRate', function(msg) // number playerTypingRate
...
@@ -47,13 +47,25 @@ 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
(
WordSpace
.
gameSceneForTest
,
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
--
;
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated
'
);
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
'
);
WordSpace
.
killLogForTest
+=
(
'
\n
--Suicide->
'
+
RoomData
.
players
[
msg
.
index
].
nickname
);
}
});
});
socket
.
on
(
'
gameEnd
'
,
function
(
msg
)
// object player
socket
.
on
(
'
gameEnd
'
,
function
(
msg
)
// object player
{
{
...
...
js/ScenesData.js
View file @
e987fbe2
...
@@ -92,6 +92,7 @@ var gameScene = new Phaser.Class(
...
@@ -92,6 +92,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 @
e987fbe2
...
@@ -4,6 +4,8 @@ var WordSpace = WordSpace || {};
...
@@ -4,6 +4,8 @@ var WordSpace = WordSpace || {};
WordSpace
.
gameSceneForTest
=
null
;
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
;
//현재 단어 무게 총합
...
@@ -237,6 +239,7 @@ WordSpace.loadImage = function(scene)
...
@@ -237,6 +239,7 @@ WordSpace.loadImage = function(scene)
WordSpace
.
gameSceneForTest
=
scene
;
// for test
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
'
);
}
}
WordSpace
.
generateWord
=
WordSpace
.
generateWord
=
...
...
server.js
View file @
e987fbe2
...
@@ -75,6 +75,25 @@ io.on('connection', function(socket)
...
@@ -75,6 +75,25 @@ io.on('connection', function(socket)
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
()
...
...
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