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
0d59c5be
Commit
0d59c5be
authored
Jul 09, 2019
by
18신대성
Committed by
18류지석
Jul 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'server'
# Conflicts: # js/WordSpace.js
parents
80a36517
e0a8ee56
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
7 deletions
+29
-7
GameServer.js
GameServer.js
+1
-1
Client.js
js/Client.js
+7
-1
ScenesData.js
js/ScenesData.js
+4
-0
WordSpace.js
js/WordSpace.js
+5
-3
server.js
server.js
+12
-2
No files found.
GameServer.js
View file @
0d59c5be
...
...
@@ -118,7 +118,7 @@ GameServer.announceToTarget = function(roomIdx, targetNum, _message, _data = nul
{
return
element
.
id
===
targetNum
;
}).
socketId
;
targetSocket
.
emit
(
_message
,
_data
);
if
(
targetSocket
!=
'
undefined
'
)
targetSocket
.
emit
(
_message
,
_data
);
}
// 데이터 동기화 함수 만들기
// 동기화할것: 유저리스트(id - nickname 쌍)
...
...
js/Client.js
View file @
0d59c5be
...
...
@@ -36,11 +36,17 @@ socket.on('attacked', function(msg) // object attackData
{
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
socket
.
on
(
'
userDisconnect
'
,
function
(
msg
)
// {num index , num id, str nickname}
{
console
.
log
(
msg
.
index
+
'
/
'
+
msg
.
id
+
'
/
'
+
msg
.
nickname
+
'
disconnected
'
);
RoomData
.
players
[
msg
.
index
]
.
isAlive
=
false
;
RoomData
.
players
[
msg
.
index
]
=
msg
;
RoomData
.
aliveCount
--
;
});
\ No newline at end of file
js/ScenesData.js
View file @
0d59c5be
...
...
@@ -56,6 +56,10 @@ var gameScene = new Phaser.Class(
WordSpace
.
wordCycle
.
resetCycle
(
this
,
3000
,
0
,
true
);
WordSpace
.
nameCycle
.
resetCycle
(
this
,
3000
,
0
,
true
);
WordSpace
.
varAdjustCycle
.
resetCycle
(
this
,
100
,
0
,
true
);
WordSpace
.
playerTypingCycle
=
setInterval
(
function
()
{
socket
.
emit
(
'
setPlayerTyping
'
,
WordSpace
.
playerTyping
);
},
500
);
WordSpace
.
setPlayerTyping
.
initiate
(
this
);
...
...
js/WordSpace.js
View file @
0d59c5be
...
...
@@ -5,8 +5,6 @@ WordSpace.gameSceneForTest = null;
WordSpace
.
weightTextObjForTest
=
null
;
WordSpace
.
nameWordTextForTest
=
null
;
WordSpace
.
isImageLoaded
=
false
;
WordSpace
.
nextWordCode
=
0
;
WordSpace
.
totalWeight
=
0
;
//현재 단어 무게 총합
WordSpace
.
totalWordNum
=
0
;
...
...
@@ -32,6 +30,7 @@ WordSpace.delay =
GameOver
:
5000
,
}
WordSpace
.
playerTypingCycle
=
null
;
WordSpace
.
NameSpawnReduce
=
1000
;
WordSpace
.
gravityPoint
=
{
x
:
640
,
y
:
300
};
...
...
@@ -277,8 +276,11 @@ function gameOver()
WordSpace
.
wordCycle
.
currentCycle
.
remove
();
WordSpace
.
nameCycle
.
currentCycle
.
remove
();
WordSpace
.
varAdjustCycle
.
currentCycle
.
remove
();
clearInterval
(
WordSpace
.
playerTypingCycle
);
//To Do
socket
.
emit
(
'
defeated
'
);
console
.
log
(
'
defeat
'
);
alert
(
'
defeat
'
);
}
//게임 오버 판정을 위한 타이머
...
...
@@ -365,7 +367,6 @@ WordSpace.setPlayerTyping =
{
this
.
totalTyping
+=
wordText
!=
null
?
WordReader
.
getWordTyping
(
wordText
)
:
0
;
WordSpace
.
playerTyping
=
this
.
totalTyping
/
WordSpace
.
gameTimer
.
now
*
60
*
1000
;
socket
.
emit
(
'
setPlayerTyping
'
,
WordSpace
.
playerTyping
);
this
.
text
.
setText
(
'
현재 타수 :
'
+
WordSpace
.
playerTyping
.
toFixed
(
1
));
},
initiate
:
function
(
scene
)
...
...
@@ -398,6 +399,7 @@ WordSpace.attack = function(wordText, grade)
//테스트용, 자기 자신에게 공격함
//WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData, false);
WordSpace
.
nameGroup
=
[];
WordSpace
.
attackGauge
.
resetValue
();
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
}
...
...
server.js
View file @
0d59c5be
...
...
@@ -27,12 +27,13 @@ io.on('connection', function(socket)
nickname
:
'
게스트
'
,
socketId
:
socket
,
currentRoom
:
null
,
playingData
:
null
,
playerTyping
:
0
};
GameServer
.
currentPlayer
.
push
(
socket
.
playerData
);
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] client request
'
);
socket
.
emit
(
'
idSet
'
,
socket
.
emit
(
'
setId
'
,
{
str
:
'
your number is
'
+
socket
.
playerData
.
id
,
num
:
socket
.
playerData
.
id
...
...
@@ -67,6 +68,15 @@ io.on('connection', function(socket)
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
)
{
let
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
...
...
@@ -81,7 +91,7 @@ io.on('connection', function(socket)
if
(
socket
.
playerData
.
currentRoom
!=
null
)
{
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
);
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