Skip to content

Commit

Permalink
Start of getting info for tournament
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Faraday committed Sep 30, 2019
1 parent b77a4a7 commit f3a05a0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<script type="text/javascript" src="./lib/positions.js"></script>
<script type="text/javascript" src="./config/players.js"></script>
<script type="text/javascript" src="./config/bots.js"></script>
<script type="text/javascript" src="./lib/info.js"></script>
<script type="text/javascript" src="./lib/data/key_maps.js"></script>
<script type="text/javascript" src="./lib/data/key_display.js"></script>

Expand Down
43 changes: 43 additions & 0 deletions lib/info.js
Original file line number Diff line number Diff line change
@@ -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
}
}

};
2 changes: 1 addition & 1 deletion manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script type="text/javascript" src="./config/game.js"></script>
<script type="text/javascript" src="./lib/positions.js"></script>
<script type="text/javascript" src="./config/players.js"></script>
<script type="text/javascript" src="./config/bots.js"></script>
<script type="text/javascript" src="./lib/info.js"></script>>
<script type="text/javascript" src="./lib/data/key_maps.js"></script>
<script type="text/javascript" src="./lib/data/key_display.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion obstacles.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script type="text/javascript" src="./config/game.js"></script>
<script type="text/javascript" src="./lib/positions.js"></script>
<script type="text/javascript" src="./config/players.js"></script>
<script type="text/javascript" src="./config/bots.js"></script>
<script type="text/javascript" src="./lib/info.js"></script>
<script type="text/javascript" src="./lib/data/key_maps.js"></script>
<script type="text/javascript" src="./lib/data/key_display.js"></script>

Expand Down
11 changes: 6 additions & 5 deletions tournament.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<script type="text/javascript" src="./lib/positions.js"></script>
<script type="text/javascript" src="./config/players.js"></script>
<script type="text/javascript" src="./config/bots.js"></script>
<script type="text/javascript" src="./lib/info.js"></script>
<script type="text/javascript" src="./lib/data/key_maps.js"></script>
<script type="text/javascript" src="./lib/data/key_display.js"></script>

Expand Down Expand Up @@ -76,14 +77,14 @@ <h3>Info</h3>

<tr>
<th>Walkers</th>
<td data-role="score" class=green>0</td>
<td data-role="score" class="red">0</td>
<td data-role="walkers" class=green>0</td>
<td data-role="walkers" class="red">0</td>
</tr>

<tr>
<th>Total health</th>
<td data-role="score" class=green>0</td>
<td data-role="score" class="red">0</td>
<td data-role="overall" class=green>0</td>
<td data-role="overall" class="red">0</td>
</tr>

</table>
Expand Down Expand Up @@ -111,7 +112,7 @@ <h3>Info</h3>
<div class="modal_background"></div>
<script type="text/javascript">
$(window).ready(function() {
GridGame.init({tournament: true});
GridGame.init({tournament: true, turn_time:50});
GridGame.api_ui.init();
});
</script>
Expand Down

0 comments on commit f3a05a0

Please sign in to comment.