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
fea42ff4
Commit
fea42ff4
authored
Jul 08, 2019
by
18신대성
Committed by
18류지석
Jul 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
패배시 서버에 알림이 가며, 다른 클라에 패배했다고 뿌림
parent
30e0a44f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
GameServer.js
GameServer.js
+1
-1
Client.js
js/Client.js
+6
-0
WordSpace.js
js/WordSpace.js
+3
-1
server.js
server.js
+11
-1
No files found.
GameServer.js
View file @
fea42ff4
...
@@ -118,7 +118,7 @@ GameServer.announceToTarget = function(roomIdx, targetNum, _message, _data = nul
...
@@ -118,7 +118,7 @@ GameServer.announceToTarget = function(roomIdx, targetNum, _message, _data = nul
{
{
return
element
.
id
===
targetNum
;
return
element
.
id
===
targetNum
;
}).
socketId
;
}).
socketId
;
targetSocket
.
emit
(
_message
,
_data
);
if
(
targetSocket
!=
'
undefined
'
)
targetSocket
.
emit
(
_message
,
_data
);
}
}
// 데이터 동기화 함수 만들기
// 데이터 동기화 함수 만들기
// 동기화할것: 유저리스트(id - nickname 쌍)
// 동기화할것: 유저리스트(id - nickname 쌍)
...
...
js/Client.js
View file @
fea42ff4
...
@@ -36,6 +36,12 @@ socket.on('attacked', function(msg) // object attackData
...
@@ -36,6 +36,12 @@ socket.on('attacked', function(msg) // object attackData
{
{
WordSpace
.
generateWord
.
Attack
(
WordSpace
.
gameSceneForTest
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
isStrong
);
WordSpace
.
generateWord
.
Attack
(
WordSpace
.
gameSceneForTest
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
isStrong
);
});
});
socket
.
on
(
'
defeat
'
,
function
(
msg
)
// object player
{
RoomData
.
players
[
msg
.
index
]
=
msg
;
RoomData
.
aliveCount
--
;
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated
'
);
});
// out game
// out game
socket
.
on
(
'
userDisconnect
'
,
function
(
msg
)
// {num index , num id, str nickname}
socket
.
on
(
'
userDisconnect
'
,
function
(
msg
)
// {num index , num id, str nickname}
...
...
js/WordSpace.js
View file @
fea42ff4
...
@@ -277,7 +277,9 @@ function gameOver()
...
@@ -277,7 +277,9 @@ function gameOver()
WordSpace
.
wordCycle
.
currentCycle
.
remove
();
WordSpace
.
wordCycle
.
currentCycle
.
remove
();
WordSpace
.
nameCycle
.
currentCycle
.
remove
();
WordSpace
.
nameCycle
.
currentCycle
.
remove
();
//To Do
//To Do
socket
.
emit
(
'
defeated
'
);
console
.
log
(
'
defeat
'
);
console
.
log
(
'
defeat
'
);
alert
(
'
defeat
'
);
}
}
//게임 오버 판정을 위한 타이머
//게임 오버 판정을 위한 타이머
...
@@ -380,7 +382,7 @@ WordSpace.attack = function(wordText, grade)
...
@@ -380,7 +382,7 @@ WordSpace.attack = function(wordText, grade)
//WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData.nickname, element.isStrong);
//WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData.nickname, element.isStrong);
});
});
WordSpace
.
nameGroup
=
[];
WordSpace
.
nameGroup
=
[];
WordSpace
.
attackGauge
.
resetValue
();
WordSpace
.
attackGauge
.
resetValue
();
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
}
}
...
...
server.js
View file @
fea42ff4
...
@@ -27,6 +27,7 @@ io.on('connection', function(socket)
...
@@ -27,6 +27,7 @@ io.on('connection', function(socket)
nickname
:
'
게스트
'
,
nickname
:
'
게스트
'
,
socketId
:
socket
,
socketId
:
socket
,
currentRoom
:
null
,
currentRoom
:
null
,
playingData
:
null
,
playerTyping
:
0
playerTyping
:
0
};
};
...
@@ -67,6 +68,15 @@ io.on('connection', function(socket)
...
@@ -67,6 +68,15 @@ io.on('connection', function(socket)
GameServer
.
announceToTarget
(
GameServer
.
findRoomIndex
(
msg
.
roomNum
),
msg
.
target
,
'
attacked
'
,
msg
);
GameServer
.
announceToTarget
(
GameServer
.
findRoomIndex
(
msg
.
roomNum
),
msg
.
target
,
'
attacked
'
,
msg
);
});
});
socket
.
on
(
'
defeated
'
,
function
()
{
socket
.
playerData
.
playingData
.
isAlive
=
false
;
socket
.
playerData
.
playingData
.
rank
=
socket
.
playerData
.
currentRoom
.
nextRank
--
;
// 패배단어 체크
GameServer
.
announceToRoom
(
socket
.
playerData
.
currentRoom
.
roomNum
,
'
defeat
'
,
socket
.
playerData
.
playingData
);
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
]
'
+
'
defeated
'
);
});
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
{
{
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
...
@@ -81,7 +91,7 @@ io.on('connection', function(socket)
...
@@ -81,7 +91,7 @@ io.on('connection', function(socket)
if
(
socket
.
playerData
.
currentRoom
!=
null
)
if
(
socket
.
playerData
.
currentRoom
!=
null
)
{
{
socket
.
playerData
.
playingData
.
isAlive
=
false
;
socket
.
playerData
.
playingData
.
isAlive
=
false
;
socket
.
playerData
.
playingData
.
rank
=
socket
.
playerData
.
currentRoom
.
nextRank
--
;
if
(
socket
.
playerData
.
playingData
.
rank
===
-
1
)
socket
.
playerData
.
playingData
.
rank
=
socket
.
playerData
.
currentRoom
.
nextRank
--
;
socket
.
playerData
.
currentRoom
.
currentSocket
.
splice
(
socket
.
playerData
.
playingData
.
index
,
1
);
socket
.
playerData
.
currentRoom
.
currentSocket
.
splice
(
socket
.
playerData
.
playingData
.
index
,
1
);
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
socket
.
playerData
.
currentRoom
.
roomNum
),
'
userDisconnect
'
,
socket
.
playerData
.
playingData
);
GameServer
.
announceToRoom
(
GameServer
.
findRoomIndex
(
socket
.
playerData
.
currentRoom
.
roomNum
),
'
userDisconnect
'
,
socket
.
playerData
.
playingData
);
}
}
...
...
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