Skip to content
Snippets Groups Projects
Select Git revision
  • ecd2a07ab35490fd1db05de563bc91ddcee81dbf
  • main default protected
  • leveleditor
  • david-author
  • clang-tidy-cleanup
  • architecture-refactoring
  • cleanUpMenus
  • doxygen-cleanup
  • project-structure-refactoring
  • interpolation
  • buildingFeatures
  • win_end_screen
  • helpMenu
  • leveleditor-placement
  • text-rendering
  • updated_unit_contextmenu
  • level-from-commandline
  • unit_contextmenu
  • player
  • engine-scaling
  • clang-tidy
21 results

Building.hpp

Blame
  • Building.hpp 1.46 KiB
    /**
     * @authors Max Körschen
     */
    
    #pragma once
    
    #include "../core/Engine.hpp"
    #include "../core/Scene.hpp"
    #include "../entities/Unit.hpp"
    
    #include <unordered_map>
    
    namespace advanced_wars
    {
    
    class Building
    {
        public:
            Building(int x, int y, BuildingId id, Faction faction);
    
            void render(Engine& engine, int scale);
    
            int getXPosition();
    
            int getYPosition();
    
            Faction getFaction();
    
            BuildingId getId();
    
            /**
            Changes the faction to the specified one
    
            @param faction The new faction the unit will belong to
    
            @return true if building was a headquarter
            */
            bool switchFaction(Faction faction);
    
            /*
            checks if the tile ontop of the building is free
            */
            bool checkSpawn(std::unordered_map<int, std::unique_ptr<Unit>>& units);
    
            /*
            checks if the player has enough money for the unit to be recruited
            */
            bool checkMoney(int price, int playerMoney);
    
            /**
            If the building is clicked, it shows information to the player, here it will be a list of
            all available units
             */
            void onClick();
    
            /**
             * Provides a vector of recruitable units, depending on the building id
             *
             */
            std::vector<UnitTypeId> recruitableUnits();
    
        private:
            int        m_x;
            int        m_y;
            BuildingId m_id;
            Faction    m_faction;
    };
    
    } // namespace advanced_wars