]> git.localhorst.tv Git - blobs.git/blob - src/creature/Composition.hpp
overhaul need system
[blobs.git] / src / creature / Composition.hpp
1 #ifndef BLOBLS_CREATURE_COMPOSITION_HPP_
2 #define BLOBLS_CREATURE_COMPOSITION_HPP_
3
4 #include <vector>
5
6
7 namespace blobs {
8 namespace creature {
9
10 class Composition {
11
12 public:
13         struct Component {
14                 int resource;
15                 double value;
16                 Component(int r, double v)
17                 : resource(r), value(v) { }
18         };
19
20 public:
21         Composition();
22         ~Composition();
23
24         Composition(const Composition &) = delete;
25         Composition &operator =(const Composition &) = delete;
26
27         Composition(Composition &&) = delete;
28         Composition &operator =(Composition &&) = delete;
29
30 public:
31         void Add(int res, double amount);
32         bool Has(int res) const noexcept;
33         double Get(int res) const noexcept;
34
35 public:
36         std::vector<Component>::iterator begin() noexcept { return components.begin(); }
37         std::vector<Component>::iterator end() noexcept { return components.end(); }
38         std::vector<Component>::const_iterator begin() const noexcept { return components.begin(); }
39         std::vector<Component>::const_iterator end() const noexcept { return components.end(); }
40         std::vector<Component>::const_iterator cbegin() noexcept { return components.cbegin(); }
41         std::vector<Component>::const_iterator cend() noexcept { return components.cend(); }
42
43 private:
44         std::vector<Component> components;
45
46 };
47
48 }
49 }
50
51 #endif