Commit 82103ce2 authored by Jyrki's avatar Jyrki 🐾

small fuchs

parent 4a56c2a6
......@@ -62,6 +62,10 @@ updateCounters = ->
$("input[name=market-slider][data-type=livestock]").attr "max", window.gameVars.liveStock.count
$("input[name=market-slider][data-type=fields]").attr "max", window.gameVars.fields.count
$("input[name=market-slider][data-type=cattle]").attr "max", window.gameVars.cattleGrid.count
setPriceLabels("wheat")
setPriceLabels("livestock")
setPriceLabels("fields")
setPriceLabels("cattle")
# statistics
$('td#stats-wheat-produced').html window.gameVars.wheat.produced
......@@ -207,10 +211,35 @@ whtim = window.setInterval wheatTimer, 100
$(document).ready -> updateCounters()
setPriceLabels = (type) ->
selectorBuy = "span#market-price-#{type}-buy"
selectorSell = "span#market-price-#{type}-sell"
switch type
when "wheat"
buyPrice = window.gameVars.prices.buy.wheat
sellPrice = window.gameVars.prices.sell.wheat
when "livestock"
buyPrice = window.gameVars.prices.buy.liveStock
sellPrice = window.gameVars.prices.sell.liveStock
when "fields"
buyPrice = window.gameVars.prices.buy.fields
sellPrice = window.gameVars.prices.sell.fields
when "cattle"
buyPrice = window.gameVars.prices.buy.cattleGrid
sellPrice = window.gameVars.prices.sell.cattleGrid
$(selectorBuy).html Number($("span[name=market-#{type}-val]").html()) * buyPrice
$(selectorSell).html Number($("span[name=market-#{type}-val]").html()) * sellPrice
return true
marketSliderChange = ->
self = $ this
selector = "span[name=market-#{self[0].dataset.type}-val]"
$(selector).html self.val()
setPriceLabels(self[0].dataset.type)
return true
$(document).on "change", "input[name=market-slider]", marketSliderChange
$(document).on "mousemove", "input[name=market-slider]", marketSliderChange
// Generated by CoffeeScript 1.7.1
(function() {
var eventTimer, evtim, fieldTimer, fitim, initItem, marketSliderChange, updateCounters, warTimer, wheatTimer, whtim;
var eventTimer, evtim, fieldTimer, fitim, initItem, marketSliderChange, setPriceLabels, updateCounters, warTimer, wheatTimer, whtim;
initItem = function(defaultCount, consumable) {
var retobj;
......@@ -63,6 +63,10 @@
$("input[name=market-slider][data-type=livestock]").attr("max", window.gameVars.liveStock.count);
$("input[name=market-slider][data-type=fields]").attr("max", window.gameVars.fields.count);
$("input[name=market-slider][data-type=cattle]").attr("max", window.gameVars.cattleGrid.count);
setPriceLabels("wheat");
setPriceLabels("livestock");
setPriceLabels("fields");
setPriceLabels("cattle");
$('td#stats-wheat-produced').html(window.gameVars.wheat.produced);
$('td#stats-wheat-consumed').html(window.gameVars.wheat.consumed);
$('td#stats-wheat-bought').html(window.gameVars.wheat.bought);
......@@ -227,11 +231,39 @@
return updateCounters();
});
setPriceLabels = function(type) {
var buyPrice, selectorBuy, selectorSell, sellPrice;
selectorBuy = "span#market-price-" + type + "-buy";
selectorSell = "span#market-price-" + type + "-sell";
switch (type) {
case "wheat":
buyPrice = window.gameVars.prices.buy.wheat;
sellPrice = window.gameVars.prices.sell.wheat;
break;
case "livestock":
buyPrice = window.gameVars.prices.buy.liveStock;
sellPrice = window.gameVars.prices.sell.liveStock;
break;
case "fields":
buyPrice = window.gameVars.prices.buy.fields;
sellPrice = window.gameVars.prices.sell.fields;
break;
case "cattle":
buyPrice = window.gameVars.prices.buy.cattleGrid;
sellPrice = window.gameVars.prices.sell.cattleGrid;
}
$(selectorBuy).html(Number($("span[name=market-" + type + "-val]").html()) * buyPrice);
$(selectorSell).html(Number($("span[name=market-" + type + "-val]").html()) * sellPrice);
return true;
};
marketSliderChange = function() {
var selector, self;
self = $(this);
selector = "span[name=market-" + self[0].dataset.type + "-val]";
return $(selector).html(self.val());
$(selector).html(self.val());
setPriceLabels(self[0].dataset.type);
return true;
};
$(document).on("change", "input[name=market-slider]", marketSliderChange);
......
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