Commit ec474832 authored by Jyrki's avatar Jyrki 🐾

???

parent 969a6d28
......@@ -233,6 +233,7 @@ setPriceLabels = (type) ->
selectorSell = "span#market-price-#{type}-sell"
selectorValue = "span[name=market-#{type}-val]"
selectorBuyButton = "button[name=market-buy][data-type=#{type}]"
selectorSellButton = "button[name=market-sell][data-type=#{type}]"
[buyPrice, sellPrice] = getPrice type
......@@ -245,6 +246,29 @@ setPriceLabels = (type) ->
else
$(selectorBuyButton).removeAttr "disabled"
# check if we even have enough of this
switch type
when "wheat"
if Number($(selectorValue).html()) > window.gameVars.wheat.count
$(selectorSellButton).attr "disabled", "disabled"
else
$(selectorSellButton).removeAttr "disabled"
when "livestock"
if Number($(selectorValue).html()) > window.gameVars.liveStock.count
$(selectorSellButton).attr "disabled", "disabled"
else
$(selectorSellButton).removeAttr "disabled"
when "fields"
if Number($(selectorValue).html()) > window.gameVars.fields.count
$(selectorSellButton).attr "disabled", "disabled"
else
$(selectorSellButton).removeAttr "disabled"
when "cattle"
if Number($(selectorValue).html()) > window.gameVars.cattleGrid.count
$(selectorSellButton).attr "disabled", "disabled"
else
$(selectorSellButton).removeAttr "disabled"
$(selectorBuy).html buyPrice
$(selectorSell).html sellPrice
......
......@@ -254,11 +254,12 @@
};
setPriceLabels = function(type) {
var buyPrice, selectorBuy, selectorBuyButton, selectorSell, selectorValue, sellPrice, _ref;
var buyPrice, selectorBuy, selectorBuyButton, selectorSell, selectorSellButton, selectorValue, sellPrice, _ref;
selectorBuy = "span#market-price-" + type + "-buy";
selectorSell = "span#market-price-" + type + "-sell";
selectorValue = "span[name=market-" + type + "-val]";
selectorBuyButton = "button[name=market-buy][data-type=" + type + "]";
selectorSellButton = "button[name=market-sell][data-type=" + type + "]";
_ref = getPrice(type), buyPrice = _ref[0], sellPrice = _ref[1];
buyPrice *= Number($(selectorValue).html());
sellPrice *= Number($(selectorValue).html());
......@@ -267,6 +268,35 @@
} else {
$(selectorBuyButton).removeAttr("disabled");
}
switch (type) {
case "wheat":
if (Number($(selectorValue).html()) > window.gameVars.wheat.count) {
$(selectorSellButton).attr("disabled", "disabled");
} else {
$(selectorSellButton).removeAttr("disabled");
}
break;
case "livestock":
if (Number($(selectorValue).html()) > window.gameVars.liveStock.count) {
$(selectorSellButton).attr("disabled", "disabled");
} else {
$(selectorSellButton).removeAttr("disabled");
}
break;
case "fields":
if (Number($(selectorValue).html()) > window.gameVars.fields.count) {
$(selectorSellButton).attr("disabled", "disabled");
} else {
$(selectorSellButton).removeAttr("disabled");
}
break;
case "cattle":
if (Number($(selectorValue).html()) > window.gameVars.cattleGrid.count) {
$(selectorSellButton).attr("disabled", "disabled");
} else {
$(selectorSellButton).removeAttr("disabled");
}
}
$(selectorBuy).html(buyPrice);
$(selectorSell).html(sellPrice);
return true;
......
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