diff options
author | Manoj Srivastava <srivasta@debian.org> | 2020-05-22 19:57:41 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2020-05-22 20:02:19 -0700 |
commit | c3d2579ad8d7eb33059aa8fdbaf5b564411a57f2 (patch) | |
tree | 1570cda0676fdcf4171a69a7fe313c1b89a52b0c /src/obj_theme.hpp | |
parent | 986b7742bf244b4073ecca0723615f70be8a1ab6 (diff) | |
parent | 4e9b9c402ed95bf9a17fd6d795bc49bb4128a6fa (diff) |
Merge branch 'upstream' into debian-cmake-fixes
Diffstat (limited to 'src/obj_theme.hpp')
-rw-r--r-- | src/obj_theme.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/obj_theme.hpp b/src/obj_theme.hpp new file mode 100644 index 00000000..d10d17fa --- /dev/null +++ b/src/obj_theme.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "h-basic.h" + +/** + * Object theme. Probability in percent for each class of + * objects to be dropped. + */ +struct obj_theme +{ + 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; + } + +}; |