OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
alchemy.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_ALCHEMY_H
2 #define GAME_MWMECHANICS_ALCHEMY_H
3 
4 #include <vector>
5 #include <set>
6 
8 
9 #include "../mwworld/ptr.hpp"
10 
11 namespace ESM
12 {
13  struct Potion;
14 }
15 
16 namespace MWMechanics
17 {
18  struct EffectKey;
19 
21  class Alchemy
22  {
23  public:
24 
25  Alchemy();
26 
27  typedef std::vector<MWWorld::Ptr> TToolsContainer;
28  typedef TToolsContainer::const_iterator TToolsIterator;
29 
30  typedef std::vector<MWWorld::Ptr> TIngredientsContainer;
31  typedef TIngredientsContainer::const_iterator TIngredientsIterator;
32 
33  typedef std::vector<ESM::ENAMstruct> TEffectsContainer;
34  typedef TEffectsContainer::const_iterator TEffectsIterator;
35 
36  enum Result
37  {
39 
45  };
46 
47  private:
48 
53  int mValue;
54 
55  void applyTools (int flags, float& value) const;
56 
57  void updateEffects();
58 
59  const ESM::Potion *getRecord(const ESM::Potion& toFind) const;
62 
63  void removeIngredients();
66 
67  void addPotion (const std::string& name);
69 
70  void increaseSkill();
72 
73  float getAlchemyFactor() const;
74 
75  int countIngredients() const;
76 
78 
80 
81  public:
82 
83  static bool knownEffect (unsigned int potionEffectIndex, const MWWorld::Ptr& npc);
85 
86  void setAlchemist (const MWWorld::Ptr& npc);
89 
90  TToolsIterator beginTools() const;
92 
93  TToolsIterator endTools() const;
94 
97 
99 
100  void clear();
102 
103  std::set<EffectKey> listEffects() const;
105 
106  int addIngredient (const MWWorld::Ptr& ingredient);
111 
112  void removeIngredient (int index);
114 
115  std::string suggestPotionName ();
117 
118  Result create (const std::string& name);
122  };
123 }
124 
125 #endif
126 
void setAlchemist(const MWWorld::Ptr &npc)
Definition: alchemy.cpp:345
TToolsIterator endTools() const
Definition: alchemy.cpp:384
std::vector< MWWorld::Ptr > TToolsContainer
Definition: alchemy.hpp:27
std::vector< ESM::ENAMstruct > TEffectsContainer
Definition: alchemy.hpp:33
std::set< EffectKey > listEffects() const
List all effects shared by at least two ingredients.
Definition: alchemy.cpp:36
void increaseSkill()
Increase alchemist's skill.
Definition: alchemy.cpp:318
TToolsIterator beginTools() const
Definition: alchemy.cpp:379
int mValue
Definition: alchemy.hpp:53
Result create(const std::string &name)
Definition: alchemy.cpp:463
TEffectsIterator beginEffects() const
Definition: alchemy.cpp:443
TEffectsContainer::const_iterator TEffectsIterator
Definition: alchemy.hpp:34
int countIngredients() const
Definition: alchemy.cpp:334
Definition: alchemy.hpp:42
Definition: alchemy.hpp:38
void updateEffects()
Definition: alchemy.cpp:128
void clear()
Remove alchemist, tools and ingredients.
Definition: alchemy.cpp:399
TIngredientsContainer::const_iterator TIngredientsIterator
Definition: alchemy.hpp:31
TEffectsContainer mEffects
Definition: alchemy.hpp:52
std::vector< MWWorld::Ptr > TIngredientsContainer
Definition: alchemy.hpp:30
Definition: alchemy.hpp:43
const ESM::Potion * getRecord(const ESM::Potion &toFind) const
Definition: alchemy.cpp:212
int addIngredient(const MWWorld::Ptr &ingredient)
Definition: alchemy.cpp:407
Result
Definition: alchemy.hpp:36
TToolsContainer mTools
Definition: alchemy.hpp:50
TIngredientsIterator endIngredients() const
Definition: alchemy.cpp:394
MWWorld::Ptr mAlchemist
Definition: alchemy.hpp:49
static bool knownEffect(unsigned int potionEffectIndex, const MWWorld::Ptr &npc)
Does npc have sufficient alchemy skill to know about this potion effect?
Definition: alchemy.cpp:453
Alchemy()
Definition: alchemy.cpp:31
TToolsContainer::const_iterator TToolsIterator
Definition: alchemy.hpp:28
void removeIngredients()
Definition: alchemy.cpp:263
void addPotion(const std::string &name)
Add a potion to the alchemist's inventory.
Definition: alchemy.cpp:283
TIngredientsIterator beginIngredients() const
Definition: alchemy.cpp:389
Potion creation via alchemy skill.
Definition: alchemy.hpp:21
float getAlchemyFactor() const
Definition: alchemy.cpp:323
std::string suggestPotionName()
Suggest a name for the potion, based on the current effects.
Definition: alchemy.cpp:502
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void applyTools(int flags, float &value) const
Definition: alchemy.cpp:70
TIngredientsContainer mIngredients
Definition: alchemy.hpp:51
Definition: loadalch.hpp:18
TEffectsIterator endEffects() const
Definition: alchemy.cpp:448
void removeIngredient(int index)
Remove ingredient from slot (calling this function on an empty slot is a no-op).
Definition: alchemy.cpp:434
const char * name
Definition: crashcatcher.cpp:59