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
2288ffd2
Commit
2288ffd2
authored
Aug 03, 2019
by
18류지석
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/server' into wordspace
parents
116d0330
7d3bafca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
28 deletions
+28
-28
Client.js
js/Client.js
+12
-11
WordObject.js
js/WordObject.js
+2
-2
WordSpace.js
js/WordSpace.js
+5
-5
main.js
js/main.js
+2
-2
server.js
server.js
+7
-8
No files found.
js/Client.js
View file @
2288ffd2
...
@@ -143,12 +143,12 @@ socket.on('attackMode', function(msg) // number playerId
...
@@ -143,12 +143,12 @@ socket.on('attackMode', function(msg) // number playerId
console
.
log
(
msg
+
'
is on attack Mode
'
);
console
.
log
(
msg
+
'
is on attack Mode
'
);
// msg의 id를 가진 사람이 attack Mode이다.
// msg의 id를 가진 사람이 attack Mode이다.
});
});
socket
.
on
(
'
someoneAttacked
'
,
function
(
msg
)
// {
Player attacker, Player victim
}
socket
.
on
(
'
someoneAttacked
'
,
function
(
msg
)
// {
Id attackerId, Id victimId
}
{
{
// 이때 위의 attack Mode인 사람(msg.attackerId)을 해제해주자.
// 이때 위의 attack Mode인 사람(msg.attackerId)을 해제해주자.
console
.
log
(
msg
.
attacker
.
id
+
'
attacked
'
+
msg
.
victim
.
i
d
);
console
.
log
(
msg
.
attacker
Id
+
'
attacked
'
+
msg
.
victimI
d
);
let
attackerPos
=
RoomData
.
findPlayer
(
msg
.
attacker
).
position
;
let
attackerPos
=
RoomData
.
findPlayer
(
msg
.
attacker
Id
).
position
;
let
victimPos
=
RoomData
.
findPlayer
(
msg
.
victim
).
position
;
let
victimPos
=
RoomData
.
findPlayer
(
msg
.
victim
Id
).
position
;
WordSpace
.
makeAttackPaper
(
ScenesData
.
gameScene
,
attackerPos
,
victimPos
,
msg
.
multiple
);
WordSpace
.
makeAttackPaper
(
ScenesData
.
gameScene
,
attackerPos
,
victimPos
,
msg
.
multiple
);
});
});
socket
.
on
(
'
attacked
'
,
function
(
msg
)
// object attackData
socket
.
on
(
'
attacked
'
,
function
(
msg
)
// object attackData
...
@@ -157,13 +157,13 @@ socket.on('attacked', function(msg) // object attackData
...
@@ -157,13 +157,13 @@ socket.on('attacked', function(msg) // object attackData
let
attackedEvent
=
new
Cycle
(
function
()
let
attackedEvent
=
new
Cycle
(
function
()
{
{
if
(
!
WordSpace
.
isInvincible
)
if
(
!
WordSpace
.
isInvincible
)
for
(
let
i
=
0
;
i
<
msg
.
multiple
;
i
++
)
WordSpace
.
generateWord
.
Attack
(
ScenesData
.
gameScene
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
attackOption
);
for
(
let
i
=
0
;
i
<
msg
.
multiple
;
i
++
)
WordSpace
.
generateWord
.
Attack
(
ScenesData
.
gameScene
,
msg
.
text
,
msg
.
grade
,
RoomData
.
findPlayer
(
msg
.
attackerId
)
,
msg
.
attackOption
);
attackedEvent
.
currentCycle
.
destroy
();
attackedEvent
.
currentCycle
.
destroy
();
WordSpace
.
attackedEvents
.
splice
(
WordSpace
.
attackedEvents
.
findIndex
(
function
(
element
)
{
WordSpace
.
attackedEvents
.
splice
(
WordSpace
.
attackedEvents
.
findIndex
(
function
(
element
)
{
return
element
.
cert
===
(
msg
.
text
+
msg
.
attacker
);
return
element
.
cert
===
(
msg
.
text
+
msg
.
attacker
Id
);
}),
1
);
}),
1
);
});
});
attackedEvent
.
cert
=
msg
.
text
+
msg
.
attacker
;
attackedEvent
.
cert
=
msg
.
text
+
msg
.
attacker
Id
;
attackedEvent
.
resetCycle
(
ScenesData
.
gameScene
,
4000
,
0
,
false
);
attackedEvent
.
resetCycle
(
ScenesData
.
gameScene
,
4000
,
0
,
false
);
WordSpace
.
attackedEvents
.
push
(
attackedEvent
);
WordSpace
.
attackedEvents
.
push
(
attackedEvent
);
...
@@ -175,8 +175,9 @@ socket.on('defeat', function(msg) // object player
...
@@ -175,8 +175,9 @@ socket.on('defeat', function(msg) // object player
RoomData
.
aliveCount
--
;
RoomData
.
aliveCount
--
;
if
(
msg
.
lastAttack
!=
null
)
if
(
msg
.
lastAttack
!=
null
)
{
{
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated by
'
+
msg
.
lastAttack
.
attacker
+
'
, with
'
+
msg
.
lastAttack
.
word
);
let
lastAttacker
=
RoomData
.
findPlayer
(
msg
.
lastAttack
.
attackerId
).
nickname
;
WordSpace
.
killLogForTest
+=
(
'
\n
'
+
msg
.
lastAttack
.
attacker
+
'
--
'
+
msg
.
lastAttack
.
word
+
'
->
'
+
RoomData
.
players
[
msg
.
index
].
nickname
);
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated by
'
+
lastAttacker
+
'
, with
'
+
msg
.
lastAttack
.
word
);
WordSpace
.
killLogForTest
+=
(
'
\n
'
+
lastAttacker
+
'
--
'
+
msg
.
lastAttack
.
word
+
'
->
'
+
RoomData
.
players
[
msg
.
index
].
nickname
);
if
(
msg
.
lastAttack
.
attackerId
==
RoomData
.
myself
.
id
)
if
(
msg
.
lastAttack
.
attackerId
==
RoomData
.
myself
.
id
)
{
{
var
keys
=
Object
.
keys
(
Enums
.
item
);
var
keys
=
Object
.
keys
(
Enums
.
item
);
...
@@ -196,8 +197,8 @@ socket.on('gameEnd', function(msg) // object player
...
@@ -196,8 +197,8 @@ socket.on('gameEnd', function(msg) // object player
socket
.
on
(
'
attackSucceed
'
,
function
(
msg
)
socket
.
on
(
'
attackSucceed
'
,
function
(
msg
)
{
{
//console.log('client');
//console.log('client');
let
tempWord
=
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
true
,
msg
.
victim
);
let
tempWord
=
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
true
,
RoomData
.
findPlayer
(
msg
.
victimId
)
);
let
victimPos
=
RoomData
.
findPlayer
(
msg
.
victim
).
position
;
let
victimPos
=
RoomData
.
findPlayer
(
msg
.
victim
Id
).
position
;
tempWord
.
physicsObj
.
setPosition
(
victimPos
.
x
,
victimPos
.
y
);
tempWord
.
physicsObj
.
setPosition
(
victimPos
.
x
,
victimPos
.
y
);
tempWord
.
wordObj
.
setPosition
(
tempWord
.
physicsObj
.
x
,
tempWord
.
physicsObj
.
y
);
tempWord
.
wordObj
.
setPosition
(
tempWord
.
physicsObj
.
x
,
tempWord
.
physicsObj
.
y
);
tempWord
.
destroy
();
tempWord
.
destroy
();
...
...
js/WordObject.js
View file @
2288ffd2
...
@@ -207,8 +207,8 @@ class AttackWord extends WordObject
...
@@ -207,8 +207,8 @@ class AttackWord extends WordObject
let
attackData
=
let
attackData
=
{
{
roomNum
:
RoomData
.
roomId
,
roomNum
:
RoomData
.
roomId
,
attacker
:
RoomData
.
myself
,
attacker
Id
:
RoomData
.
myself
.
id
,
target
:
this
.
attacker
.
id
,
victimId
:
this
.
attacker
.
id
,
text
:
this
.
wordText
,
text
:
this
.
wordText
,
grade
:
Math
.
min
(
3
,
this
.
wordGrade
+
1
),
grade
:
Math
.
min
(
3
,
this
.
wordGrade
+
1
),
attackOption
:
{
attackOption
:
{
...
...
js/WordSpace.js
View file @
2288ffd2
...
@@ -418,8 +418,8 @@ WordSpace.findWord = function(wordText)
...
@@ -418,8 +418,8 @@ WordSpace.findWord = function(wordText)
let
victimData
=
let
victimData
=
{
{
roomNum
:
RoomData
.
roomId
,
roomNum
:
RoomData
.
roomId
,
victim
:
RoomData
.
myself
,
attackerId
:
element
.
attacker
.
id
,
target
:
element
.
attacker
.
id
,
victimId
:
RoomData
.
myself
.
id
,
word
:
element
.
wordText
word
:
element
.
wordText
}
}
socket
.
emit
(
'
defenseFailed
'
,
victimData
);
socket
.
emit
(
'
defenseFailed
'
,
victimData
);
...
@@ -460,7 +460,7 @@ WordSpace.attack = function(wordText, grade)
...
@@ -460,7 +460,7 @@ WordSpace.attack = function(wordText, grade)
let
victimId
=
element
.
ownerId
;
let
victimId
=
element
.
ownerId
;
let
sendIdx
=
toSend
.
findIndex
(
function
(
element
)
let
sendIdx
=
toSend
.
findIndex
(
function
(
element
)
{
{
return
element
.
victim
.
i
d
===
victimId
;
return
element
.
victim
I
d
===
victimId
;
});
});
if
(
sendIdx
!=
-
1
)
toSend
[
sendIdx
].
multiple
++
;
if
(
sendIdx
!=
-
1
)
toSend
[
sendIdx
].
multiple
++
;
else
else
...
@@ -471,8 +471,8 @@ WordSpace.attack = function(wordText, grade)
...
@@ -471,8 +471,8 @@ WordSpace.attack = function(wordText, grade)
let
attackData
=
let
attackData
=
{
{
roomNum
:
RoomData
.
roomId
,
roomNum
:
RoomData
.
roomId
,
attacker
:
RoomData
.
myself
,
attacker
Id
:
RoomData
.
myself
.
id
,
victim
:
target
,
victim
Id
:
target
.
id
,
text
:
wordText
,
text
:
wordText
,
grade
:
grade
,
grade
:
grade
,
attackOption
:
{
attackOption
:
{
...
...
js/main.js
View file @
2288ffd2
...
@@ -33,7 +33,7 @@ RoomData.roomId = -1;
...
@@ -33,7 +33,7 @@ RoomData.roomId = -1;
RoomData
.
myself
=
null
;
RoomData
.
myself
=
null
;
RoomData
.
players
=
null
;
RoomData
.
players
=
null
;
RoomData
.
aliveCount
=
-
1
;
RoomData
.
aliveCount
=
-
1
;
RoomData
.
findPlayer
=
function
(
player
)
RoomData
.
findPlayer
=
function
(
player
Id
)
{
{
return
RoomData
.
players
.
find
(
function
(
element
){
return
element
.
id
==
player
.
i
d
;
});
return
RoomData
.
players
.
find
(
function
(
element
){
return
element
.
id
==
player
I
d
;
});
}
}
\ No newline at end of file
server.js
View file @
2288ffd2
...
@@ -94,18 +94,17 @@ io.on('connection', function(socket)
...
@@ -94,18 +94,17 @@ io.on('connection', function(socket)
socket
.
on
(
'
attack
'
,
function
(
msg
)
socket
.
on
(
'
attack
'
,
function
(
msg
)
{
{
socket
.
playerData
.
currentRoom
.
announceToTarget
(
msg
.
victim
.
i
d
,
'
attacked
'
,
msg
);
socket
.
playerData
.
currentRoom
.
announceToTarget
(
msg
.
victim
I
d
,
'
attacked
'
,
msg
);
socket
.
playerData
.
currentRoom
.
announceToRoom
(
'
someoneAttacked
'
,
{
attacker
:
msg
.
attacker
,
victim
:
msg
.
victim
,
multiple
:
msg
.
multiple
});
socket
.
playerData
.
currentRoom
.
announceToRoom
(
'
someoneAttacked
'
,
{
attacker
Id
:
msg
.
attackerId
,
victimId
:
msg
.
victimId
,
multiple
:
msg
.
multiple
});
//console.log('attack ' + msg.
target + ' by ' + msg.attacker.i
d + ' with ' + msg.text);
//console.log('attack ' + msg.
victimId + ' by ' + msg.attackerI
d + ' with ' + msg.text);
setTimeout
(
function
()
setTimeout
(
function
()
{
{
let
target
=
GameServer
.
findPlayerSocket
(
msg
.
victim
.
i
d
);
let
target
=
GameServer
.
findPlayerSocket
(
msg
.
victim
I
d
);
if
(
target
!=
null
)
if
(
target
!=
null
)
{
{
let
dataToPush
=
let
dataToPush
=
{
{
attackerId
:
msg
.
attacker
.
id
,
attackerId
:
msg
.
attackerId
,
attacker
:
msg
.
attacker
.
nickname
,
wrongCount
:
0
,
wrongCount
:
0
,
word
:
msg
.
text
,
word
:
msg
.
text
,
wordGrade
:
msg
.
grade
,
wordGrade
:
msg
.
grade
,
...
@@ -128,10 +127,10 @@ io.on('connection', function(socket)
...
@@ -128,10 +127,10 @@ io.on('connection', function(socket)
socket
.
on
(
'
defenseFailed
'
,
function
(
msg
)
socket
.
on
(
'
defenseFailed
'
,
function
(
msg
)
{
{
socket
.
playerData
.
currentRoom
.
announceToTarget
(
msg
.
target
,
'
attackSucceed
'
,
msg
);
socket
.
playerData
.
currentRoom
.
announceToTarget
(
msg
.
attackerId
,
'
attackSucceed
'
,
msg
);
let
wrongCountIndex
=
socket
.
playerData
.
playingData
.
lastAttacks
.
findIndex
(
function
(
element
)
let
wrongCountIndex
=
socket
.
playerData
.
playingData
.
lastAttacks
.
findIndex
(
function
(
element
)
{
{
return
(
element
.
word
===
msg
.
word
)
&&
(
element
.
attackerId
===
msg
.
target
);
return
(
element
.
word
===
msg
.
word
)
&&
(
element
.
attackerId
===
msg
.
victimId
);
});
});
if
(
wrongCountIndex
!==
-
1
)
socket
.
playerData
.
playingData
.
lastAttacks
[
wrongCountIndex
].
wrongCount
++
;
if
(
wrongCountIndex
!==
-
1
)
socket
.
playerData
.
playingData
.
lastAttacks
[
wrongCountIndex
].
wrongCount
++
;
});
});
...
...
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