Commit 113958b6 authored by pixeldesu's avatar pixeldesu
Browse files

Merge branch 'master' of github.com:Leafcat/FarmingGame-web

parents 8e2ed27e d113a543
......@@ -45,6 +45,7 @@ window.gameVars = {
# update all the counters and stop everything if the game was lost
updateCounters = ->
# left panel
$('span#valuables-gold').html window.gameVars.gold
$('span#goods-wheat').html window.gameVars.wheat.count
$('span#goods-livestock').html window.gameVars.liveStock.count
......@@ -55,13 +56,24 @@ updateCounters = ->
$('span#builds-fields').html window.gameVars.fields.count
$('span#builds-cattle').html window.gameVars.cattleGrids.count
# statistics
$('td#stats-wheat-produced').html window.gameVars.wheat.produced
$('td#stats-wheat-consumed').html window.gameVars.wheat.consumed
$('span#valuables-gold').html 0 if window.gameVars.gold < 0
$('span#goods-wheat').html 0 if window.gameVars.wheat.count < 0
if window.gameVars.wheat.count <= 0
window.clearInterval evtim
window.clearInterval fitim
$('#game-over-modal').modal 'show'
# Field Timer
fieldTimer = ->
window.gameVars.wheat.count += window.gameVars.fields.count
window.gameVars.wheat.produced += window.gameVars.fields.count
updateCounters()
#Krieg
warTimer = ->
die = Math.floor((Math.random() * 10000000) % 2) == 0
......@@ -160,6 +172,7 @@ eventTimer = ->
message: message
}
evtim = window.setInterval eventTimer, 5000
evtim = window.setInterval eventTimer, 30000
fitim = window.setInterval fieldTimer, 100
$(document).ready -> updateCounters()
// Generated by CoffeeScript 1.7.1
(function() {
var eventTimer, evtim, initItem, updateCounters, warTimer;
var eventTimer, evtim, fieldTimer, fitim, initItem, updateCounters, warTimer;
initItem = function(defaultCount, consumable) {
var retobj;
......@@ -53,6 +53,8 @@
$('span#people-all').html(window.gameVars.people.home + window.gameVars.people.war + window.gameVars.people.shelter);
$('span#builds-fields').html(window.gameVars.fields.count);
$('span#builds-cattle').html(window.gameVars.cattleGrids.count);
$('td#stats-wheat-produced').html(window.gameVars.wheat.produced);
$('td#stats-wheat-consumed').html(window.gameVars.wheat.consumed);
if (window.gameVars.gold < 0) {
$('span#valuables-gold').html(0);
}
......@@ -61,10 +63,17 @@
}
if (window.gameVars.wheat.count <= 0) {
window.clearInterval(evtim);
window.clearInterval(fitim);
return $('#game-over-modal').modal('show');
}
};
fieldTimer = function() {
window.gameVars.wheat.count += window.gameVars.fields.count;
window.gameVars.wheat.produced += window.gameVars.fields.count;
return updateCounters();
};
warTimer = function() {
var die, g, message, title;
die = Math.floor((Math.random() * 10000000) % 2) === 0;
......@@ -175,7 +184,9 @@
});
};
evtim = window.setInterval(eventTimer, 5000);
evtim = window.setInterval(eventTimer, 30000);
fitim = window.setInterval(fieldTimer, 100);
$(document).ready(function() {
return updateCounters();
......
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