summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Zidan <brahem@aotsw.com>2019-04-13 22:38:17 +0200
committerIbrahim Zidan <brahem@aotsw.com>2019-05-05 23:28:09 +0200
commit65d3828c5e91bab7d89e7e3e901d4f7ff8ab0a2a (patch)
treec9084d0ba2203b31c1b97d4cc457a4d86d012571
parenta8f85f757435bc6f409d78612b53e4c3c531abb9 (diff)
downloadhercules-65d3828c5e91bab7d89e7e3e901d4f7ff8ab0a2a.tar.gz
hercules-65d3828c5e91bab7d89e7e3e901d4f7ff8ab0a2a.tar.bz2
hercules-65d3828c5e91bab7d89e7e3e901d4f7ff8ab0a2a.tar.xz
hercules-65d3828c5e91bab7d89e7e3e901d4f7ff8ab0a2a.zip
Implement functions to returns refine database values to be used instead of direct access to database structure
* refine->get_bonus to retrive the refine bonus * refine->get_randombonus_max to retrive maximum refine random bonus NOTE: all functions expects the actual refine level and not the index of it unlike the previous code which used indexes Signed-off-by: Ibrahim Zidan <brahem@aotsw.com>
-rw-r--r--src/map/refine.c20
-rw-r--r--src/map/refine.h18
2 files changed, 37 insertions, 1 deletions
diff --git a/src/map/refine.c b/src/map/refine.c
index 8a172c40b..77d069643 100644
--- a/src/map/refine.c
+++ b/src/map/refine.c
@@ -40,6 +40,24 @@ static struct refine_interface_private refine_p;
static struct refine_interface_dbs refine_dbs;
struct refine_interface *refine;
+/// @copydoc refine_interface::get_randombonus_max()
+static int refine_get_randombonus_max(enum refine_type equipment_type, int refine_level)
+{
+ Assert_ret((int)equipment_type >= REFINE_TYPE_ARMOR && equipment_type < REFINE_TYPE_MAX);
+ Assert_ret(refine_level > 0 && refine_level <= MAX_REFINE);
+
+ return refine->dbs->refine_info[equipment_type].randombonus_max[refine_level - 1];
+}
+
+/// @copydoc refine_interface::get_bonus()
+static int refine_get_bonus(enum refine_type equipment_type, int refine_level)
+{
+ Assert_ret((int)equipment_type >= REFINE_TYPE_ARMOR && equipment_type < REFINE_TYPE_MAX);
+ Assert_ret(refine_level > 0 && refine_level <= MAX_REFINE);
+
+ return refine->dbs->refine_info[equipment_type].bonus[refine_level - 1];
+}
+
/// @copydoc refine_interface::get_refine_chance()
static int refine_get_refine_chance(enum refine_type wlv, int refine_level, enum refine_chance_type type)
{
@@ -230,4 +248,6 @@ void refine_defaults(void)
refine->init = refine_init;
refine->final = refine_final;
refine->get_refine_chance = refine_get_refine_chance;
+ refine->get_bonus = refine_get_bonus;
+ refine->get_randombonus_max = refine_get_randombonus_max;
}
diff --git a/src/map/refine.h b/src/map/refine.h
index 6e7506be7..05ab0f076 100644
--- a/src/map/refine.h
+++ b/src/map/refine.h
@@ -97,6 +97,22 @@ struct refine_interface {
* @return The chance to refine the item, in percent (0~100)
**/
int (*get_refine_chance) (enum refine_type wlv, int refine_level, enum refine_chance_type type);
+
+ /**
+ * Gets the attack/deffense bonus for the given equipment type and refine level
+ * @param equipment_type the equipment type
+ * @param refine_level the equipment refine level
+ * @return returns the bonus from refine db
+ **/
+ int (*get_bonus) (enum refine_type equipment_type, int refine_level);
+
+ /**
+ * Gets the maximum attack/deffense random bonus for the given equipment type and refine level
+ * @param equipment_type the equipment type
+ * @param refine_level the equipment refine level
+ * @return returns the bonus from refine db
+ **/
+ int(*get_randombonus_max) (enum refine_type equipment_type, int refine_level);
};
#ifdef HERCULES_CORE
@@ -104,4 +120,4 @@ void refine_defaults(void);
#endif
HPShared struct refine_interface *refine;
-#endif \ No newline at end of file
+#endif