Skip to content

Commit

Permalink
limit max food to storage
Browse files Browse the repository at this point in the history
  • Loading branch information
warronbebster committed May 30, 2023
1 parent c8248ff commit a1941f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/mayor_game/city_calculator/city_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ defmodule MayorGame.CityHelpers do
else
max_possible_food = acc |> TownStatistics.getResource(food_type) |> ResourceStatistics.getNextStock()

max_possible_food =
min(max_possible_food, acc |> TownStatistics.getResource(food_type) |> ResourceStatistics.getStorage())

# IO.inspect(max_possible_food, label: town.title <> " max_possible_food " <> to_string(food_type))

food_production_resources =
ResourceStatistics.merge(
acc
Expand Down
6 changes: 3 additions & 3 deletions lib/mayor_game/market/market_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ defmodule MayorGame.MarketHelpers do
false
else
# replace this with getNextStock
IO.inspect(TownStatistics.getResource(leftovers_by_id[market.town_id], resource),
label: leftovers_by_id[market.town_id].title
)
# IO.inspect(TownStatistics.getResource(leftovers_by_id[market.town_id], resource),
# label: leftovers_by_id[market.town_id].title
# )

TownStatistics.getResource(leftovers_by_id[market.town_id], resource) |> ResourceStatistics.getNextStock() >
0
Expand Down

0 comments on commit a1941f2

Please sign in to comment.