aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/BuildingInstance.hpp
blob: 9fc9df14398fa55099bca36805dc993d6c0c3c8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include "openvic-simulation/economy/BuildingType.hpp"

namespace OpenVic {

   struct BuildingInstance : HasIdentifier { // used in the actual game
      using level_t = BuildingType::level_t;

      enum class ExpansionState { CannotExpand, CanExpand, Preparing, Expanding };

   private:
      BuildingType const& PROPERTY(building_type);

      level_t PROPERTY(level);
      ExpansionState PROPERTY(expansion_state);
      Date PROPERTY(start_date)
      Date PROPERTY(end_date);
      float PROPERTY(expansion_progress);

      bool _can_expand() const;

   public:
      BuildingInstance(BuildingType const& new_building_type, level_t new_level = 0);
      BuildingInstance(BuildingInstance&&) = default;

      void set_level(level_t new_level);

      bool expand();
      void update_state(Date today);
      void tick(Date today);
   };
}