From 36120db400691be75199ff404e35f5c289b8818f Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 31 Jan 2014 19:46:51 +0100 Subject: Some updates for enchanting (2) --- src/Enchantments.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index e984df92e..e0861aa1e 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -29,6 +29,9 @@ mapping each enchantment's id onto its level. ID may be either a number or the e Level value of 0 means no such enchantment, and it will not be stored in the m_Enchantments. Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs. */ + +typedef std::vector cEnchantmentsArray; + // tolua_begin class cEnchantments { @@ -62,7 +65,7 @@ public: enchLuckOfTheSea = 61, enchLure = 62, } ; - + /// Creates an empty enchantments container cEnchantments(void); -- cgit v1.2.3 From e6e702e7fdbc8b7475d3dbecc0f81a08304997ae Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 12 Apr 2014 14:58:46 +0200 Subject: Added complete Enchanting System http://minecraft.gamepedia.com/Enchantment_mechanics --- src/Enchantments.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 2af772928..70d6b6613 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -29,7 +29,7 @@ Level value of 0 means no such enchantment, and it will not be stored in the m_E Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs. */ -typedef std::vector cEnchantmentsArray; +typedef std::vector cEnchantmentsVector; // tolua_begin class cEnchantments @@ -105,7 +105,7 @@ public: /// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) friend void EnchantmentSerializer::ParseFromNBT(cEnchantments& a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx); - + protected: /// Maps enchantment ID -> enchantment level typedef std::map cMap; -- cgit v1.2.3 From f9343a8490b50cb28a62c7327c0013da48ca2745 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 17 Apr 2014 13:15:35 +0200 Subject: Modified many things --- src/Enchantments.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 70d6b6613..1d226330a 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -8,7 +8,9 @@ #pragma once +#include "Defines.h" #include "WorldStorage/EnchantmentSerializer.h" +#include "Entities/Player.h" @@ -29,7 +31,6 @@ Level value of 0 means no such enchantment, and it will not be stored in the m_E Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs. */ -typedef std::vector cEnchantmentsVector; // tolua_begin class cEnchantments @@ -94,9 +95,24 @@ public: /// Returns true if a_Other contains exactly the same enchantments and levels bool operator ==(const cEnchantments & a_Other) const; - + // tolua_end + + /** Add enchantment weights from item to the vector */ + static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short & a_ItemType, int a_EnchantmentLevel); + + /** Add a enchantment weight to the vector */ + static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, cEnchantments a_Enchantment); + /** Remove a enchantment weight from the vector */ + static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, int a_EnchantmentID); + + /** Check enchantment conflicts from enchantments from the vector */ + static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, cEnchantments a_FirstEnchantment); + + /** Gets random enchantment from Vector and returns it */ + static cEnchantments GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments); + /// Returns true if a_Other doesn't contain exactly the same enchantments and levels bool operator !=(const cEnchantments & a_Other) const; @@ -115,5 +131,15 @@ protected: } ; // tolua_export +/** Things below for the Enchanting System */ +struct cWeightedEnchantment +{ + int m_Weight; + cEnchantments m_Enchantments; +}; + +typedef std::vector cWeightedEnchantments; + + -- cgit v1.2.3 From 0086fcfef18db58f3a4509853399c0a9b610e950 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 17 Apr 2014 19:31:43 +0200 Subject: Fixed some Errors (not all) --- src/Enchantments.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 1d226330a..fa07dc2d4 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -20,6 +20,11 @@ class cFastNBTWriter; class cParsedNBT; +// fwd: +struct cWeightedEnchantment; + +typedef std::vector cWeightedEnchantments; + @@ -111,7 +116,6 @@ public: /** Gets random enchantment from Vector and returns it */ static cEnchantments GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments); - /// Returns true if a_Other doesn't contain exactly the same enchantments and levels bool operator !=(const cEnchantments & a_Other) const; @@ -131,15 +135,14 @@ protected: } ; // tolua_export -/** Things below for the Enchanting System */ + + +// Define the cWeightedEnchantment struct: struct cWeightedEnchantment { int m_Weight; cEnchantments m_Enchantments; }; -typedef std::vector cWeightedEnchantments; - - -- cgit v1.2.3 From 3efd232829aaa15193550a300d3385f59316b4a8 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 18 Apr 2014 14:10:31 +0200 Subject: Removed old include --- src/Enchantments.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index fa07dc2d4..1b3561faf 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -10,7 +10,6 @@ #include "Defines.h" #include "WorldStorage/EnchantmentSerializer.h" -#include "Entities/Player.h" -- cgit v1.2.3 From 56613d2b22c82f301eb651d1f24a0c2155917d24 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 18 Apr 2014 14:34:29 +0200 Subject: Fixed Errors --- src/Enchantments.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 1b3561faf..3cb979042 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -109,6 +109,7 @@ public: static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, cEnchantments a_Enchantment); /** Remove a enchantment weight from the vector */ static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, int a_EnchantmentID); + static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, cEnchantments a_Enchantment); /** Check enchantment conflicts from enchantments from the vector */ static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, cEnchantments a_FirstEnchantment); -- cgit v1.2.3 From a6de7bf1cd80847abed22e3b962a5b8650b2911c Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 19 Apr 2014 15:10:50 +0200 Subject: Fixed Code --- src/Enchantments.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 3cb979042..fc848ebec 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -103,13 +103,13 @@ public: // tolua_end /** Add enchantment weights from item to the vector */ - static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short & a_ItemType, int a_EnchantmentLevel); + static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short a_ItemType, int a_EnchantmentLevel); /** Add a enchantment weight to the vector */ - static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, cEnchantments a_Enchantment); + static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, int a_EnchantmentID, int a_EnchantmentLevel); /** Remove a enchantment weight from the vector */ - static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, int a_EnchantmentID); - static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, cEnchantments a_Enchantment); + static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, int a_EnchantmentID); + static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, const cEnchantments & a_Enchantment); /** Check enchantment conflicts from enchantments from the vector */ static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, cEnchantments a_FirstEnchantment); -- cgit v1.2.3 From 098be1c7fc0d2e0309bc2a649d21090265535a3e Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 19 Apr 2014 22:37:29 +0200 Subject: Fixed Code --- src/Enchantments.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index fc848ebec..a376d27cf 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -105,10 +105,13 @@ public: /** Add enchantment weights from item to the vector */ static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short a_ItemType, int a_EnchantmentLevel); - /** Add a enchantment weight to the vector */ - static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, int a_EnchantmentID, int a_EnchantmentLevel); - /** Remove a enchantment weight from the vector */ + /** Add a enchantment with weight to the vector */ + static void AddEnchantmentWeightToVector(cWeightedEnchantments & a_Enchantments, int a_Weight, int a_EnchantmentID, int a_EnchantmentLevel); + + /** Remove the entire enchantment (with weight) from the vector */ static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, int a_EnchantmentID); + + /** Remove the entire enchantment (with weight) from the vector */ static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, const cEnchantments & a_Enchantment); /** Check enchantment conflicts from enchantments from the vector */ @@ -137,7 +140,7 @@ protected: -// Define the cWeightedEnchantment struct: +// Define the cWeightedEnchantment struct for the Enchanting System to store the EnchantmentWeights: struct cWeightedEnchantment { int m_Weight; -- cgit v1.2.3