From f3a05a0860f507bfa823dc527a002fa7f39d2566 Mon Sep 17 00:00:00 2001 From: Andrew Faraday Date: Mon, 30 Sep 2019 21:39:14 +0100 Subject: [PATCH] Start of getting info for tournament --- index.html | 1 + lib/info.js | 43 +++++++++++++++++++++++++++++++++++++++++++ manual.html | 2 +- obstacles.html | 2 +- tournament.html | 11 ++++++----- 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 lib/info.js diff --git a/index.html b/index.html index 4d95ada..4f0271b 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,7 @@ + diff --git a/lib/info.js b/lib/info.js new file mode 100644 index 0000000..ed706ab --- /dev/null +++ b/lib/info.js @@ -0,0 +1,43 @@ +GridGame.info = { + + get_all: function() { + GridGame.info.display('cities', GridGame.info.count_cities()); + GridGame.info.display('walkers', GridGame.info.count_walkers()); + GridGame.info.display('overall', GridGame.info.get_overall_health()); + + }, + + display: function(role, scores) { + $.each( + scores, + function(player, score) { + $('td[data-role="'+role+'"].' + player).text(score); + } + ) + }, + + count_cities: function() { + var result = {red: 0, green: 0}; + GridGame.board.each_tile(function (tile) { + if(tile.value > 0 && tile.city) { + result[tile.player.name] += 1; + } + }); + return result; + }, + + count_walkers: function() { + return { + red: 10, + green: 40 + } + }, + + get_overall_health: function() { + return { + red: 80, + green: 40 + } + } + +}; \ No newline at end of file diff --git a/manual.html b/manual.html index a6ba457..2a38f03 100644 --- a/manual.html +++ b/manual.html @@ -26,7 +26,7 @@ - + > diff --git a/obstacles.html b/obstacles.html index 00a5657..f11ecb5 100644 --- a/obstacles.html +++ b/obstacles.html @@ -26,7 +26,7 @@ - + diff --git a/tournament.html b/tournament.html index 9a24ff3..246f4c1 100644 --- a/tournament.html +++ b/tournament.html @@ -34,6 +34,7 @@ + @@ -76,14 +77,14 @@

Info

Walkers - 0 - 0 + 0 + 0 Total health - 0 - 0 + 0 + 0 @@ -111,7 +112,7 @@

Info