diff --git a/index.html b/index.html index 4f0271b..5a06056 100644 --- a/index.html +++ b/index.html @@ -56,7 +56,7 @@ -

My Grid Game

+

Grid Game

diff --git a/lib/classes/tile.js b/lib/classes/tile.js index 1382893..b76c2ff 100644 --- a/lib/classes/tile.js +++ b/lib/classes/tile.js @@ -11,6 +11,7 @@ GridGame.classes.tile = function (x, y) { this.city = false; this.rock = false; this.wall = false; + this.changed = true; // used in turn process this.value_change = 0; @@ -83,18 +84,19 @@ GridGame.classes.tile = function (x, y) { // Draw this.draw = function () { - this.cell - .html(this.display_character()) - .removeClass(function (index, css) { - return (css.match(/\btile_\S+/g) || []).join(' '); - }) - .toggleClass('tile_city', this.city) - .toggleClass('tile_rock', this.rock) - .toggleClass('tile_wall', this.wall); - - - if (this.player && this.value > 0) { - this.cell.addClass('tile_' + this.player.name); + if (this.changed) { + this.cell + .html(this.display_character()) + .removeClass('tile_red tile_green tile_yellow tile_blue') + .toggleClass('tile_city', this.city) + .toggleClass('tile_rock', this.rock) + .toggleClass('tile_wall', this.wall); + + + if (this.player && this.value > 0) { + this.cell.addClass('tile_' + this.player.name); + } + this.changed = false; } }; diff --git a/lib/grid_game.js b/lib/grid_game.js index 26e347c..becc0d1 100644 --- a/lib/grid_game.js +++ b/lib/grid_game.js @@ -118,6 +118,8 @@ var GridGame = { } }, + turn_active: false, + turn: function () { $.each(GridGame.apis, function (i, api) { api.func() diff --git a/lib/turn_phases/do_damage_phase.js b/lib/turn_phases/do_damage_phase.js index ce7d290..96baa76 100644 --- a/lib/turn_phases/do_damage_phase.js +++ b/lib/turn_phases/do_damage_phase.js @@ -2,6 +2,9 @@ GridGame.turn_phases.do_damage_phase = function() { this.do_damage_phase = function() { this.value += this.value_change; + if (!this.changed) { + this.changed = (this.value_change != 0); + } if (this.value <= 0) {this.kill()} this.value_change = 0; }; diff --git a/lib/turn_phases/do_movement_phase.js b/lib/turn_phases/do_movement_phase.js index 33eea50..a547716 100644 --- a/lib/turn_phases/do_movement_phase.js +++ b/lib/turn_phases/do_movement_phase.js @@ -2,6 +2,9 @@ GridGame.turn_phases.do_movement_phase = function () { this.do_movement_phase = function () { this.value += this.value_change; + if (!this.changed) { + this.changed = (this.value_change != 0); + } this.do_city_conversion(); this.end_movement_phase(); }; diff --git a/manual.html b/manual.html index 2a38f03..c87951d 100644 --- a/manual.html +++ b/manual.html @@ -48,7 +48,7 @@ -

My Grid Game

+

Grid Game