Skip to content

Commit

Permalink
Fixed money-bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderv committed Apr 23, 2018
1 parent 7577688 commit 86213f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ end

DEBUG = true
STATE = {
properties = { population = 0, money = -50 },
properties = { population = 0, money = 50 },
buildings = {
{ x = 1, y = 1, building = "small_park" },
{ x = 1, y = 1, building = "medium_generator" },
},
hand = {},
discardPile = { "small_office", "small_generator", "small_residential"},
drawPile = {"loan"},
discardPile = { },
drawPile = {"small_office", "small_generator", "small_residential"},
currentTurnEffects = {},
cars = {},
helis = {},
Expand Down
3 changes: 2 additions & 1 deletion scripts/helpers/gamerules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ function gamerules.endTurn(state)
table.insert(changed, "energy_up_green")
end

local nextMoney = gamerules.getMoneyPerTurn(state) + state.properties.money + math.min ( gamerules.getTotalResource(state, "work"), state.properties.population)
local nextMoney = state.properties.money + gamerules.getMoneyPerTurn(state) + math.min ( -gamerules.getTotalResource(state, "work"), state.properties.population)
print(nextMoney, beforeTurn.money)
if beforeTurn.money > nextMoney then
table.insert(changed, "money_down_red")
elseif beforeTurn.money < nextMoney then
Expand Down

0 comments on commit 86213f7

Please sign in to comment.