Commit 969a6d28 authored by Jyrki's avatar Jyrki 🐾

hhhhhhhhhh

parent d04446b1
......@@ -284,6 +284,34 @@ marketBuyItem = ->
updateCounters()
marketSellItem = ->
self = $ this
selector = "input[name=market-slider][data-type=#{self[0].dataset.type}]"
amount = Number($(selector).val())
[buyPrice, sellPrice] = getPrice self[0].dataset.type
sellPrice *= amount
window.gameVars.gold += sellPrice
switch self[0].dataset.type
when "wheat"
window.gameVars.wheat.count -= amount
window.gameVars.wheat.sold += amount
when "livestock"
window.gameVars.liveStock.count -= amount
window.gameVars.liveStock.sold += amount
when "fields"
window.gameVars.fields.count -= amount
window.gameVars.fields.sold += amount
when "cattle"
window.gameVars.cattleGrid.count -= amount
window.gameVars.cattleGrid.sold += amount
updateCounters()
$(document).on "change", "input[name=market-slider]", marketSliderChange
$(document).on "mousemove", "input[name=market-slider]", marketSliderChange
$(document).on "click", "button[name=market-buy]", marketBuyItem
$(document).on "click", "button[name=market-sell]", marketSellItem
// Generated by CoffeeScript 1.7.1
(function() {
var eventTimer, evtim, fieldTimer, fitim, getPrice, initItem, marketBuyItem, marketSliderChange, setPriceLabels, updateCounters, warTimer, wheatTimer, whtim;
var eventTimer, evtim, fieldTimer, fitim, getPrice, initItem, marketBuyItem, marketSellItem, marketSliderChange, setPriceLabels, updateCounters, warTimer, wheatTimer, whtim;
initItem = function(defaultCount, consumable) {
var retobj;
......@@ -309,10 +309,40 @@
return updateCounters();
};
marketSellItem = function() {
var amount, buyPrice, selector, self, sellPrice, _ref;
self = $(this);
selector = "input[name=market-slider][data-type=" + self[0].dataset.type + "]";
amount = Number($(selector).val());
_ref = getPrice(self[0].dataset.type), buyPrice = _ref[0], sellPrice = _ref[1];
sellPrice *= amount;
window.gameVars.gold += sellPrice;
switch (self[0].dataset.type) {
case "wheat":
window.gameVars.wheat.count -= amount;
window.gameVars.wheat.sold += amount;
break;
case "livestock":
window.gameVars.liveStock.count -= amount;
window.gameVars.liveStock.sold += amount;
break;
case "fields":
window.gameVars.fields.count -= amount;
window.gameVars.fields.sold += amount;
break;
case "cattle":
window.gameVars.cattleGrid.count -= amount;
window.gameVars.cattleGrid.sold += amount;
}
return updateCounters();
};
$(document).on("change", "input[name=market-slider]", marketSliderChange);
$(document).on("mousemove", "input[name=market-slider]", marketSliderChange);
$(document).on("click", "button[name=market-buy]", marketBuyItem);
$(document).on("click", "button[name=market-sell]", marketSellItem);
}).call(this);
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