Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DoNaTio s.r.o.
PiPo
Commits
a071cdeb
Commit
a071cdeb
authored
Dec 11, 2014
by
DoNaTio s.r.o.
Browse files
WhoIsTurn
parent
349fd016
Changes
3
Hide whitespace changes
Inline
Side-by-side
WhoIsTurn.js
View file @
a071cdeb
...
...
@@ -24,6 +24,7 @@ module.exports = function (PlayersColliction, Score) {
getNext
:
function
()
{
var
next
;
console
.
log
(
_team0
,
_team1
);
if
(
_whichTeam
)
{
if
(
_team1
[
0
]
==
undefined
)
{
this
.
resetTeamStack
(
1
);
...
...
@@ -41,18 +42,12 @@ module.exports = function (PlayersColliction, Score) {
return
next
;
},
/**
*
* @returns id
*/
getWhoIsTurn
:
function
()
{
return
_whoIsTurn
;
},
/**
* return user.Id
* @param type
*/
chan
geWhoIsTurn
:
function
()
{
ge
t
WhoIsTurn
:
function
()
{
if
(
_whichTeam
)
{
_whichTeam
=
0
;
}
else
{
...
...
public/ClientMain.js
View file @
a071cdeb
...
...
@@ -88,10 +88,11 @@ $(function () {
socket
.
on
(
'
login
'
,
function
(
data
)
{
log
.
add
(
"
Joined:
"
+
data
.
numUsers
);
log
.
add
(
"
Your name:
"
+
data
.
username
);
log
.
add
(
"
Turn:
"
+
data
.
whoIsOnTurn
);
if
(
!
connected
){
user
.
setId
(
data
.
id
);
if
(
data
.
id
==
1
){
if
(
data
.
id
==
data
.
isOnTurn
){
user
.
setIsTurn
(
true
);
}
for
(
var
i
=
0
;
i
<
data
.
allIds
.
length
;
i
++
){
// if we need later to send all players whe can directly from them take ids
...
...
@@ -105,6 +106,7 @@ $(function () {
socket
.
on
(
'
who is turn
'
,
function
(
data
)
{
//console.log(data);
log
.
add
(
"
On turn:
"
+
data
.
username
);
if
(
data
.
userId
==
user
.
getId
()){
user
.
setIsTurn
(
true
);
}
...
...
server.js
View file @
a071cdeb
...
...
@@ -71,7 +71,8 @@ io.on('connection', function (socket) {
numUsers
:
PlayersCollection
.
getCount
(),
username
:
newPlayer
.
getName
(),
id
:
newPlayer
.
getId
(),
allIds
:
PlayersCollection
.
getIds
()
allIds
:
PlayersCollection
.
getIds
(),
whoIsOnTurn
:
whoIsTurn
.
getWhoIsTurn
()
});
//// echo globally (all clients) that a person has connected
socket
.
broadcast
.
emit
(
'
user joined
'
,
{
...
...
@@ -101,7 +102,7 @@ io.on('connection', function (socket) {
console
.
log
(
'
who is turn
'
,
data
);
socket
.
broadcast
.
emit
(
'
who is turn
'
,
{
'
userId
'
:
PlayersCollectio
n
.
getWhoIsTurn
()
'
userId
'
:
whoIsTur
n
.
getWhoIsTurn
()
});
});
...
...
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