Skip to content

Commit

Permalink
KOTOR: Add getLevelByPosition and getClassByPosition methods
Browse files Browse the repository at this point in the history
These two methods return the actual level and class regarding their position in the level vector.
  • Loading branch information
Nostritius committed Jan 19, 2018
1 parent 17eef98 commit 11d45cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/engines/kotor/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ int Creature::getLevel(const Class &c) const {
return 0;
}

int Creature::getLevelByPosition(int position) const {
if (_levels.size() >= static_cast<unsigned int>(position + 1))
return _levels[position].level;

return 0;
}

Class Creature::getClassByPosition(int position) const {
if (_levels.size() >= static_cast<unsigned int>(position + 1))
return _levels[position].characterClass;

return kClassInvalid;
}

Race Creature::getRace() const {
return _race;
}
Expand Down
3 changes: 3 additions & 0 deletions src/engines/kotor/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class Creature : public Object {
Race getRace() const; ///< Get the race of the creature.
SubRace getSubRace() const; ///< Get the subrace of the creature.

int getLevelByPosition(int position) const; ///< Get the level by its position in the level vector.
Class getClassByPosition(int position) const; ///< Get the class by its position in the level vector.

// Positioning

/** Set the creature's position. */
Expand Down

0 comments on commit 11d45cf

Please sign in to comment.