Permalink
Browse files

Finishing round also after a draw now.

  • Loading branch information...
Saman Sedighi Rad
Saman Sedighi Rad committed May 12, 2012
1 parent 225db17 commit d9a66037a272a67248ce6291be4965b0b2f2ded1
Showing with 15 additions and 0 deletions.
  1. +12 −0 lib/croxxo.js
  2. +3 −0 lib/socketio.js
View
@@ -143,6 +143,18 @@ Croxxo.prototype.clearField = function () {
];
};
+Croxxo.prototype.areAllFieldsOccupied = function () {
+ "use strict";
+
+ var joined = '',
+ i;
+
+ for(i = 0; i < this.field.length; i += 1) {
+ joined += this.field[i].join('');
+ }
+ return joined.length === 9;
+}
+
Croxxo.prototype.getSessionId = function () {
"use strict";
return this.session_id;
View
@@ -164,6 +164,9 @@ function SocketIO(express) {
message: winMessage,
players: game.getPlayersStatus()
});
+ }
+ // New game if winner or all field occupied
+ if (typeof winner === 'object' || game.areAllFieldsOccupied()) {
// Cleanup the field
game.clearField();
socket.emit('clear_field', { message: "Alright, new round!" });

0 comments on commit d9a6603

Please sign in to comment.