From 9749c3aac9dbfbc46a919193c97bb9c9e5339e03 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Thu, 24 Sep 2015 10:48:33 +0200 Subject: Implemented brewing --- src/BrewingRecipes.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/BrewingRecipes.h (limited to 'src/BrewingRecipes.h') diff --git a/src/BrewingRecipes.h b/src/BrewingRecipes.h new file mode 100644 index 000000000..82fb0b822 --- /dev/null +++ b/src/BrewingRecipes.h @@ -0,0 +1,55 @@ + +#pragma once + + + + + +class cItem; + + + + + +class cBrewingRecipes +{ +public: + cBrewingRecipes(void); + ~cBrewingRecipes(); + + void ReloadRecipes(void); + + struct cRecipe + { + cRecipe() {} + cRecipe(cRecipe &&) {} + + cRecipe(const cRecipe&) = delete; + cRecipe & operator=(const cRecipe&) = delete; + + std::unique_ptr Input; + std::unique_ptr Output; + std::unique_ptr Ingredient; + }; + + /** Returns a recipe for the specified input, nullptr if no recipe found */ + const cRecipe * GetRecipeFrom(const cItem & a_Input, const cItem & a_Ingredient) const; + + /** Returns true if the item is a ingredient, false if not. */ + bool IsIngredient(const cItem & a_Ingredient) const; + + /** Returns true if the item is a bottle / potion, false if not. */ + bool IsBottle(const cItem & a_Bottle) const; +private: + void ClearRecipes(void); + + /** Parses the recipe contained in the line, adds it to m_pState's recipes. + Logs a warning to the console on input error. */ + void AddRecipeFromLine(const AString & a_Line, unsigned int a_LineNum); + + /** Parses an item string, returns true if successful. */ + bool ParseItem(const AString & a_String, cItem & a_Item); + + struct sBrewingRecipeState; + std::unique_ptr m_pState; +}; -- cgit v1.2.3