Permalink
Browse files
Finishing round also after a draw now.
- Loading branch information...
Showing
with
15 additions
and
0 deletions.
-
+12
−0
lib/croxxo.js
-
+3
−0
lib/socketio.js
|
@@ -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;
|
|
|
|
@@ -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