diff options
author | Manoj Srivastava <srivasta@debian.org> | 2020-05-23 00:33:19 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2020-05-23 00:33:19 -0700 |
commit | d6b913d3ca2e84b75f3675fd6e9f5246c100cf27 (patch) | |
tree | 5fc28b7efc737bf2c79dc7d799e0a6013957fe11 /src/player_type.cc | |
parent | c42f029316c0c004a795ca170bdb50644a800534 (diff) | |
parent | 73a0259be1d44fdb2ab34266ae0ff63f0d8f0b60 (diff) |
Merge branch 'master' into dgit/siddebian/2.4.0-ah-1archive/debian/2.4.0-ah-1
Diffstat (limited to 'src/player_type.cc')
-rw-r--r-- | src/player_type.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/player_type.cc b/src/player_type.cc new file mode 100644 index 00000000..0cc66de7 --- /dev/null +++ b/src/player_type.cc @@ -0,0 +1,28 @@ +#include "player_type.hpp" + +#include <algorithm> + +bool player_type::has_ability(u16b ability_idx) const +{ + return std::find( + abilities.begin(), + abilities.end(), + ability_idx) != abilities.end(); +} + +void player_type::gain_ability(u16b ability_idx) +{ + // Duplicates don't really matter, so let's just + // accept whatever value we get without checking + // anything. + abilities.push_back(ability_idx); +} + +void player_type::lose_ability(u16b ability_idx) +{ + abilities.erase( + std::remove( + abilities.begin(), + abilities.end(), + ability_idx)); +} |