diff options
author | Bardur Arantsson <bardur@scientician.net> | 2016-06-20 22:49:05 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2016-06-20 22:49:05 +0200 |
commit | e17e742edb3809d45ce1edc716d71b3bb93056d6 (patch) | |
tree | f4570d74cd8f0f31aa198c589808cdfaa1ab2202 /src/obj_theme.hpp | |
parent | f693888666c64c75a636be3504e6decb55f2865b (diff) |
Make obj_theme a non-POD struct
Diffstat (limited to 'src/obj_theme.hpp')
-rw-r--r-- | src/obj_theme.hpp | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/obj_theme.hpp b/src/obj_theme.hpp index 13f185e8..d10d17fa 100644 --- a/src/obj_theme.hpp +++ b/src/obj_theme.hpp @@ -8,8 +8,45 @@ */ struct obj_theme { - byte treasure; - byte combat; - byte magic; - byte tools; + byte treasure = 0; + byte combat = 0; + byte magic = 0; + byte tools = 0; + + bool operator == (obj_theme const &other) const + { + return + (treasure == other.treasure) && + (combat == other.combat) && + (magic == other.magic) && + (tools == other.tools); + } + + bool operator != (obj_theme const &other) const + { + return !(*this == other); + } + + static constexpr obj_theme no_theme() + { + return equal_spread(100); + } + + static constexpr obj_theme defaults() + { + return equal_spread(20); + } + +private: + + static constexpr obj_theme equal_spread(byte v) + { + obj_theme ot; + ot.treasure = v; + ot.combat = v; + ot.magic = v; + ot.tools = v; + return ot; + } + }; |