OpenMW
Public Types | Public Member Functions | Private Member Functions | Private Attributes
MWMechanics::Alchemy Class Reference

Potion creation via alchemy skill. More...

#include <alchemy.hpp>

List of all members.

Public Types

enum  Result {
  Result_Success, Result_NoMortarAndPestle, Result_LessThanTwoIngredients, Result_NoName,
  Result_NoEffects, Result_RandomFailure
}
typedef std::vector< MWWorld::PtrTToolsContainer
typedef
TToolsContainer::const_iterator 
TToolsIterator
typedef std::vector< MWWorld::PtrTIngredientsContainer
typedef
TIngredientsContainer::const_iterator 
TIngredientsIterator
typedef std::vector
< ESM::ENAMstruct
TEffectsContainer
typedef
TEffectsContainer::const_iterator 
TEffectsIterator

Public Member Functions

void setAlchemist (const MWWorld::Ptr &npc)
TToolsIterator beginTools () const
TToolsIterator endTools () const
TIngredientsIterator beginIngredients () const
TIngredientsIterator endIngredients () const
void clear ()
 Remove alchemist, tools and ingredients.
int addIngredient (const MWWorld::Ptr &ingredient)
void removeIngredient (int index)
 Remove ingredient from slot (calling this function on an empty slot is a no-op).
TEffectsIterator beginEffects () const
TEffectsIterator endEffects () const
std::string getPotionName () const
Result create (const std::string &name)

Private Member Functions

std::set< EffectKeylistEffects () const
 List all effects shared by at least two ingredients.
void applyTools (int flags, float &value) const
void updateEffects ()
const ESM::PotiongetRecord () const
 Return existing recrod for created potion (may return 0)
void removeIngredients ()
void addPotion (const std::string &name)
 Add a potion to the alchemist's inventory.
void increaseSkill ()
 Increase alchemist's skill.
float getChance () const
 Return chance of success.
int countIngredients () const

Private Attributes

MWWorld::Ptr mAlchemist
TToolsContainer mTools
TIngredientsContainer mIngredients
TEffectsContainer mEffects
int mValue

Detailed Description

Potion creation via alchemy skill.


Member Typedef Documentation

typedef TEffectsContainer::const_iterator MWMechanics::Alchemy::TEffectsIterator
typedef TIngredientsContainer::const_iterator MWMechanics::Alchemy::TIngredientsIterator
typedef TToolsContainer::const_iterator MWMechanics::Alchemy::TToolsIterator

Member Enumeration Documentation

Enumerator:
Result_Success 
Result_NoMortarAndPestle 
Result_LessThanTwoIngredients 
Result_NoName 
Result_NoEffects 
Result_RandomFailure 

Member Function Documentation

Add ingredient into the next free slot.

Returns:
Slot index or -1, if adding failed because of no free slot or the ingredient type being listed already.
void MWMechanics::Alchemy::addPotion ( const std::string &  name) [private]

Add a potion to the alchemist's inventory.

void MWMechanics::Alchemy::applyTools ( int  flags,
float &  value 
) const [private]
Attention:
Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
Attention:
Iterates over tool slots, not over tools. Some of the slots may be empty.

Remove alchemist, tools and ingredients.

int MWMechanics::Alchemy::countIngredients ( ) const [private]

Try to create a potion from the ingredients, place it in the inventory of the alchemist and adjust the skills of the alchemist accordingly.

Parameters:
namemust not be an empty string, unless there is already a potion record ( getPotionName() does not return an empty string).
float MWMechanics::Alchemy::getChance ( ) const [private]

Return chance of success.

std::string MWMechanics::Alchemy::getPotionName ( ) const

Return the name of the potion that would be created when calling create (if a record for such a potion already exists) or return an empty string.

const ESM::Potion * MWMechanics::Alchemy::getRecord ( ) const [private]

Return existing recrod for created potion (may return 0)

Increase alchemist's skill.

List all effects shared by at least two ingredients.

Remove ingredient from slot (calling this function on an empty slot is a no-op).

Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and update effect list accordingly.

Set alchemist and configure alchemy setup accordingly. npc may be empty to indicate that there is no alchemist (alchemy session has ended).


Member Data Documentation


The documentation for this class was generated from the following files: