Commit a071cdeb authored by DoNaTio s.r.o.'s avatar DoNaTio s.r.o.
Browse files

WhoIsTurn

parent 349fd016
......@@ -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
*/
changeWhoIsTurn: function () {
getWhoIsTurn: function () {
if (_whichTeam) {
_whichTeam = 0;
} else {
......
......@@ -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 );
}
......
......@@ -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': PlayersCollection.getWhoIsTurn()
'userId': whoIsTurn.getWhoIsTurn()
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment