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  std::string mPotionName;
55 
56  void applyTools (int flags, float& value) const;
57 
58  void updateEffects();
59 
60  Result getReadyStatus() const;
61 
62  const ESM::Potion *getRecord(const ESM::Potion& toFind) const;
65 
66  void removeIngredients();
69 
70  void addPotion (const std::string& name);
72 
73  void increaseSkill();
75 
79 
80  float getAlchemyFactor() const;
81 
82  int countIngredients() const;
83 
85 
87 
88  public:
89  int countPotionsToBrew() const;
91 
92  static bool knownEffect (unsigned int potionEffectIndex, const MWWorld::Ptr& npc);
94 
95  void setAlchemist (const MWWorld::Ptr& npc);
98 
99  TToolsIterator beginTools() const;
101 
102  TToolsIterator endTools() const;
103 
106 
108 
109  void clear();
111 
112  void setPotionName(const std::string& name);
114 
115  std::set<EffectKey> listEffects() const;
117 
118  int addIngredient (const MWWorld::Ptr& ingredient);
123 
124  void removeIngredient (int index);
126 
127  std::string suggestPotionName ();
129 
130  Result create (const std::string& name, int& count);
134  };
135 }
136 
137 #endif
138 
void setAlchemist(const MWWorld::Ptr &npc)
Definition: alchemy.cpp:359
TToolsIterator endTools() const
Definition: alchemy.cpp:398
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:37
void increaseSkill()
Increase alchemist's skill.
Definition: alchemy.cpp:313
Result getReadyStatus() const
Definition: alchemy.cpp:485
TToolsIterator beginTools() const
Definition: alchemy.cpp:393
int mValue
Definition: alchemy.hpp:53
TEffectsIterator beginEffects() const
Definition: alchemy.cpp:463
TEffectsContainer::const_iterator TEffectsIterator
Definition: alchemy.hpp:34
int countIngredients() const
Definition: alchemy.cpp:329
Definition: alchemy.hpp:42
Definition: alchemy.hpp:38
void updateEffects()
Definition: alchemy.cpp:129
void clear()
Remove alchemist, tools and ingredients.
Definition: alchemy.cpp:413
TIngredientsContainer::const_iterator TIngredientsIterator
Definition: alchemy.hpp:31
TEffectsContainer mEffects
Definition: alchemy.hpp:52
std::vector< MWWorld::Ptr > TIngredientsContainer
Definition: alchemy.hpp:30
void setPotionName(const std::string &name)
Set name of potion to create.
Definition: alchemy.cpp:422
Definition: alchemy.hpp:43
Result create(const std::string &name, int &count)
Definition: alchemy.cpp:502
const ESM::Potion * getRecord(const ESM::Potion &toFind) const
Definition: alchemy.cpp:213
int addIngredient(const MWWorld::Ptr &ingredient)
Definition: alchemy.cpp:427
Result
Definition: alchemy.hpp:36
TToolsContainer mTools
Definition: alchemy.hpp:50
TIngredientsIterator endIngredients() const
Definition: alchemy.cpp:408
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:473
Alchemy()
Definition: alchemy.cpp:31
TToolsContainer::const_iterator TToolsIterator
Definition: alchemy.hpp:28
int countPotionsToBrew() const
calculates maximum amount of potions, which you can make from selected ingredients ...
Definition: alchemy.cpp:340
void removeIngredients()
Definition: alchemy.cpp:264
void addPotion(const std::string &name)
Add a potion to the alchemist's inventory.
Definition: alchemy.cpp:278
TIngredientsIterator beginIngredients() const
Definition: alchemy.cpp:403
Potion creation via alchemy skill.
Definition: alchemy.hpp:21
float getAlchemyFactor() const
Definition: alchemy.cpp:318
std::string mPotionName
Definition: alchemy.hpp:54
std::string suggestPotionName()
Suggest a name for the potion, based on the current effects.
Definition: alchemy.cpp:552
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void applyTools(int flags, float &value) const
Definition: alchemy.cpp:71
TIngredientsContainer mIngredients
Definition: alchemy.hpp:51
Definition: loadalch.hpp:18
TEffectsIterator endEffects() const
Definition: alchemy.cpp:468
void removeIngredient(int index)
Remove ingredient from slot (calling this function on an empty slot is a no-op).
Definition: alchemy.cpp:454
Result createSingle()
Definition: alchemy.cpp:528
const char * name
Definition: crashcatcher.cpp:67