diff options
author | Bardur Arantsson <bardur@scientician.net> | 2016-09-17 09:58:14 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2016-09-17 09:58:14 +0200 |
commit | cc857c940cfe1bfe8d78674dbce53e5b71acaf41 (patch) | |
tree | d1e62b5c66b9bd3d0f8cf1873b8dd858060816c5 /src/player_type.cc | |
parent | 5a3f511fd036dd73152786e83f32c32f274f2398 (diff) |
Move ability_type::acquired to p_ptr struct
This is justified by the fact that the 'acquired' flag is actually a
player-centered bit of information and must be
loaded/saved. Everything else in ability_type is defined by the *.txt
files.
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)); +} |