aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/BuildingInstance.hpp
blob: 00e2dd6f52e94a9b2e97d1910cfb31e6ef2b2f6a (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
#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_RW(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;

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