Commit c595dba9 authored by Jyrki's avatar Jyrki 🐾
Browse files

no more -2983576 wheat or gold

parent e964120b
......@@ -45,6 +45,15 @@ window.gameVars = {
# update all the counters and stop everything if the game was over
updateCounters = ->
if window.gameVars.gold <= 0 || window.gameVars.wheat.count <= 0
$.growl {
title: "The Game"
message: "You lost it"
}
window.clearInterval evtim
$('span#valuables-gold').html 0 if window.gameVars.gold < 0
$('span#goods-wheat').html 0 if window.gameVars.wheat.count < 0
$('span#valuables-gold').html window.gameVars.gold
$('span#goods-wheat').html window.gameVars.wheat.count
$('span#goods-livestock').html window.gameVars.liveStock.count
......@@ -54,13 +63,6 @@ updateCounters = ->
$('span#builds-fields').html window.gameVars.fields.count
$('span#builds-cattle').html window.gameVars.cattleGrids.count
if window.gameVars.gold <= 0 || window.gameVars.wheat.count <= 0
$.growl {
title: "The Game"
message: "You lost it"
}
window.clearInterval evtim
# random event
eventTimer = ->
ev = Math.floor((Math.random() * 10000000) % 7)
......
......@@ -44,6 +44,19 @@
};
updateCounters = function() {
if (window.gameVars.gold <= 0 || window.gameVars.wheat.count <= 0) {
$.growl({
title: "The Game",
message: "You lost it"
});
window.clearInterval(evtim);
if (window.gameVars.gold < 0) {
$('span#valuables-gold').html(0);
}
if (window.gameVars.wheat.count < 0) {
$('span#goods-wheat').html(0);
}
}
$('span#valuables-gold').html(window.gameVars.gold);
$('span#goods-wheat').html(window.gameVars.wheat.count);
$('span#goods-livestock').html(window.gameVars.liveStock.count);
......@@ -51,14 +64,7 @@
$('span#people-war').html(window.gameVars.people.war);
$('span#people-shelter').html(window.gameVars.people.shelter);
$('span#builds-fields').html(window.gameVars.fields.count);
$('span#builds-cattle').html(window.gameVars.cattleGrids.count);
if (window.gameVars.gold <= 0 || window.gameVars.wheat.count <= 0) {
$.growl({
title: "The Game",
message: "You lost it"
});
return window.clearInterval(evtim);
}
return $('span#builds-cattle').html(window.gameVars.cattleGrids.count);
};
eventTimer = function() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment