Skip to content

Commit

Permalink
LIKE THE CLAPPERS!
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew james faraday committed Oct 14, 2019
1 parent fad02a8 commit 2496929
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
26 changes: 14 additions & 12 deletions lib/classes/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
};

Expand Down
2 changes: 2 additions & 0 deletions lib/grid_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ var GridGame = {
}
},

turn_active: false,

turn: function () {
$.each(GridGame.apis, function (i, api) {
api.func()
Expand Down
3 changes: 3 additions & 0 deletions lib/turn_phases/do_damage_phase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
3 changes: 3 additions & 0 deletions lib/turn_phases/do_movement_phase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
1 change: 0 additions & 1 deletion tournament.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ <h1>My Grid Game</h1>
</div>
<br clear="both"/>
<div class="info">
<h3>Info</h3>
<p class="turn"><b>Turn:</b> <span id="turn">0</span></p>
<table id="data">
<tr>
Expand Down

0 comments on commit 2496929

Please sign in to comment.