39 lines
906 B
C++
39 lines
906 B
C++
//
|
|
// Created by sebastian on 08.02.26.
|
|
//
|
|
|
|
#include "GameMode.h"
|
|
|
|
#include <iostream>
|
|
#include <bits/ostream.tcc>
|
|
|
|
#include "player/Player.h"
|
|
|
|
GameMode::GameMode() {
|
|
addPlayer(0, "Player 1");
|
|
}
|
|
|
|
bool GameMode::canBuild(PlayerID player, BuildingType buildingType) {
|
|
int woodCost = 10;
|
|
if (!players[player].getInventory()->hasEnough(RessourceType::WOOD, woodCost)) {
|
|
std::cout << "Not enough wood" << std::endl;
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void GameMode::build(PlayerID player, EntityID tileEntity, BuildingType buildingType) {
|
|
if (canBuild(player, buildingType)) {
|
|
players[player].getInventory()->spend(RessourceType::WOOD, 10);
|
|
}
|
|
}
|
|
|
|
void GameMode::addPlayer(PlayerID playerID, std::string name) {
|
|
PlayerID id = static_cast<PlayerID>(players.size());
|
|
players[id] = Player(id, name);
|
|
}
|
|
|
|
PlayerID GameMode::getCurrentPlayer() {
|
|
return 0;
|
|
}
|