summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:55 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:55 +0100
commit4d02b27e4b657cd0691f990c10816090b8c2b316 (patch)
treeeeb6653b52e13c1126fd50e94894cd575ea2657b /src
parent28b5353a036b90f3515d1f6d273bd71ace15e98d (diff)
Make device skill a parameter of get_level_device()
This uncouples get_level_device() from s_info for easier testing.
Diffstat (limited to 'src')
-rw-r--r--src/lua_bind.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lua_bind.cc b/src/lua_bind.cc
index 78a86d13..ec44ce4e 100644
--- a/src/lua_bind.cc
+++ b/src/lua_bind.cc
@@ -45,10 +45,8 @@ s32b lua_get_level(spell_type *spell, s32b lvl, s32b max, s32b min, s32b bonus)
return lvl;
}
-static s32b get_level_device(spell_type *spell, s32b max, s32b min)
+static s32b get_level_device(spell_type *spell, s32b max, s32b min, s32b device_skill)
{
- int lvl;
-
/* No max specified ? assume 50 */
if (max <= 0) {
max = 50;
@@ -58,8 +56,7 @@ static s32b get_level_device(spell_type *spell, s32b max, s32b min)
min = 1;
}
- lvl = s_info[SKILL_DEVICE].value;
- lvl = lvl + (get_level_use_stick * SKILL_STEP);
+ int lvl = device_skill + (get_level_use_stick * SKILL_STEP);
/* Sticks are limited */
if (lvl - ((spell_type_skill_level(spell) + 1) * SKILL_STEP) >= get_level_max_stick * SKILL_STEP)
@@ -81,8 +78,9 @@ static s32b get_level_device_1(s32b s, s32b max, s32b min)
// Must be in "device" mode.
assert(get_level_use_stick > -1);
// Delegate
- spell_type *spell = spell_at(s);
- return get_level_device(spell, max, min);
+ auto spell = spell_at(s);
+ auto device_skill = s_info[SKILL_DEVICE].value;
+ return get_level_device(spell, max, min, device_skill);
}
static s32b get_level_school_1(spell_type *spell, s32b max, s32b min)