summaryrefslogtreecommitdiff
path: root/lib/mods/theme/core
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-03-31 20:30:09 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-02 21:50:04 +0200
commite3ada797f1a576dce1f9289f76e35be98f1deeee (patch)
treef1f96b023a60445155de954b6bf50c744c18e80c /lib/mods/theme/core
parent39af619fc0ffd2804a009cd70cc7cfd7ad352ff4 (diff)
Refactor: Eliminate duplicate Lua code from print_{book,spell}
Diffstat (limited to 'lib/mods/theme/core')
-rw-r--r--lib/mods/theme/core/s_aux.lua27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/mods/theme/core/s_aux.lua b/lib/mods/theme/core/s_aux.lua
index 4cc4a199..ec609b04 100644
--- a/lib/mods/theme/core/s_aux.lua
+++ b/lib/mods/theme/core/s_aux.lua
@@ -293,6 +293,22 @@ function adjust_power(s, x)
end
end
+-- Get spell school name(s) as a /-separated string.
+function spell_school_name(s)
+ local xx, sch_str
+ xx = nil
+ sch_str = ""
+ for index, sch in __spell_school[s] do
+ if xx then
+ sch_str = sch_str.."/"..school(sch).name
+ else
+ xx = 1
+ sch_str = sch_str..school(sch).name
+ end
+ end
+ return sch_str
+end
+
-- Print the book and the spells
function print_book(book, spl, obj)
local x, y, index, sch, size, s
@@ -317,16 +333,7 @@ function print_book(book, spl, obj)
else color = TERM_L_GREEN end
end
- xx = nil
- sch_str = ""
- for index, sch in __spell_school[s] do
- if xx then
- sch_str = sch_str.."/"..school(sch).name
- else
- xx = 1
- sch_str = sch_str..school(sch).name
- end
- end
+ sch_str = spell_school_name(s)
if na then
c_prt(color, format("%c) %-20s%-16s %3s %4s %3d%s %s", size + strbyte("a"), spell(s).name, sch_str, na, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)