Dicewars-Siedler/src/game/PlayerInventory.cpp
2026-02-08 20:05:48 +01:00

23 lines
552 B
C++

//
// Created by sebastian on 08.02.26.
//
#include "PlayerInventory.h"
#include <cstdio>
bool PlayerInventory::hasEnough(RessourceType resourceType, int amount) const {
auto it = resources.find(resourceType);
return it != resources.end() && it->second >= amount;
}
void PlayerInventory::spend(RessourceType resourceType, int amount) {
if (hasEnough(resourceType, amount)) {
resources[resourceType] -= amount;
}
}
void PlayerInventory::add(RessourceType resourceType, int amount) {
resources[resourceType] += amount;
}