Skip to content

Commit

Permalink
no change just rearranged code
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbarton committed Sep 4, 2016
1 parent 6150f79 commit cabe666
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions snatch-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,28 @@ module.exports = function (nTiles, WordChecker, SaveGameData){
}
},

//we could make this an embedded class and be snazzy! Is there time??
provideColorChoice: function(socket_key) {

var mySet = undefined;
fiveColorsSent_socketKey[socket_key] = {};

if(GD.my_color_palette.length >= 5){
mySet = GD.my_color_palette.splice(0,5);
fiveColorsSent_socketKey[socket_key].restore = true;
}
else{
mySet = GD.emergency_colors.slice(0,5);
GD.emergency_colors = GD.emergency_colors.concat(GD.emergency_colors.splice(0,5));
fiveColorsSent_socketKey[socket_key].restore = false;
}

fiveColorsSent_socketKey[socket_key].cols = mySet;//remove 5 colours from the palette
console.log("PALETTE:", GD.my_color_palette)
return mySet;
},


removePlayer: function(socket_key) {
var PI = player_index_from_socketKey_lkup[socket_key];
//there is the possibility that the player was never attached to this socket...
Expand Down Expand Up @@ -435,26 +457,6 @@ module.exports = function (nTiles, WordChecker, SaveGameData){
return Response;
},

//we could make this an embedded class and be snazzy! Is there time??
provideColorChoice: function(socket_key) {

var mySet = undefined;
fiveColorsSent_socketKey[socket_key] = {};

if(GD.my_color_palette.length >= 5){
mySet = GD.my_color_palette.splice(0,5);
fiveColorsSent_socketKey[socket_key].restore = true;
}
else{
mySet = GD.emergency_colors.slice(0,5);
GD.emergency_colors = GD.emergency_colors.concat(GD.emergency_colors.splice(0,5));
fiveColorsSent_socketKey[socket_key].restore = false;
}

fiveColorsSent_socketKey[socket_key].cols = mySet;//remove 5 colours from the palette
return mySet;
},

//this is copy-pasted client side code...
TileIDArray_to_LettersString: function(TileIDArray){
//get the letter set
Expand Down

0 comments on commit cabe666

Please sign in to comment.