Subtract player resources when building

This commit is contained in:
2024-01-29 12:40:47 +01:00
parent 3c63c68597
commit 6e848cf239

View File

@@ -263,6 +263,12 @@ void updatePlayerInput() {
bool canPlace = canPlaceBuilding(game, input->building, tileX, tileY);
if (canPlace && isInputBtnDown(input, primaryBtn)) {
placeBuilding(game, input->building, tileX, tileY, game->player);
// Update player resources
i32 cost[RES_COUNT] = {0};
getBuildingCost(input->building, cost);
game->playerResources[game->player].wood -= cost[RES_WOOD];
game->playerResources[game->player].gold -= cost[RES_GOLD];
game->playerResources[game->player].food -= cost[RES_FOOD];
}
input->buildingCanPlace = canPlace;
input->buildingPos = (Vec2i) {tileX, tileY};