summaryrefslogtreecommitdiff
path: root/lib/mods/theme/core
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-07 14:50:36 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:27 +0200
commita01f15e08da3b2e0e326b2a94100e17962136741 (patch)
treefa07a987e816cc752f909b689e2118f6c963c3b3 /lib/mods/theme/core
parent41b6617e992d3fedda4c0a93ddd0fa4ad834a2ae (diff)
Lua: Refactor all the corruption code into C
Diffstat (limited to 'lib/mods/theme/core')
-rw-r--r--lib/mods/theme/core/crpt_aux.lua144
-rw-r--r--lib/mods/theme/core/init.lua1
2 files changed, 0 insertions, 145 deletions
diff --git a/lib/mods/theme/core/crpt_aux.lua b/lib/mods/theme/core/crpt_aux.lua
deleted file mode 100644
index 24b71860..00000000
--- a/lib/mods/theme/core/crpt_aux.lua
+++ /dev/null
@@ -1,144 +0,0 @@
--- Core functions for corruptions
-
-__corruptions = {}
-__corruptions_max = 0
-__corruptions_callbacks_max = 0
-
--- Get the corruption
-function player.corruption(c)
- return player.corruptions_aux[c + 1]
-end
-
--- Test if we have that corruption
--- We must:
--- 1) have it or be willing to get it
--- 2) have all its dependancies
--- 3) have none of its opposing corruptions
--- 4) pass the possible tests
-function test_depend_corrupt(corrupt, can_gain)
- local i, c
-
- if not can_gain then can_gain = FALSE end
-
- if can_gain == TRUE then
- if (player.corruption(corrupt) ~= FALSE) then
- return FALSE
- end
- else
- if (player.corruption(corrupt) ~= TRUE) then
- return FALSE
- end
- end
-
- for c, i in __corruptions[corrupt].depends do
- if test_depend_corrupt(c) ~= TRUE then
- return FALSE
- end
- end
-
- for c, i in __corruptions[corrupt].oppose do
- if test_depend_corrupt(c) ~= FALSE then
- return FALSE
- end
- end
-
- -- are we even allowed to get it?
- return player_can_gain_corruption(corrupt)
-end
-
--- Gain a new corruption
-function gain_corruption(group)
- local i, max
- local pos = {}
-
- -- Get the list of all possible ones
- max = 0
- for i = 0, __corruptions_max - 1 do
- if __corruptions[i].group == group and test_depend_corrupt(i, TRUE) == TRUE and __corruptions[i].random == TRUE and __corruptions[i].allow() then
- pos[max] = i
- max = max + 1
- end
- end
-
- -- Ok now get one of them
- if (max > 0) then
- local ret = rand_int(max)
-
- player_gain_corruption(pos[ret])
- cmsg_print(TERM_L_RED, __corruptions[pos[ret]].get_text)
-
- return pos[ret]
- else
- return -1
- end
-end
-
--- Lose an existing corruption
-function lose_corruption()
- local i, max
- local pos = {}
-
- -- Get the list of all possible ones
- max = 0
- for i = 0, __corruptions_max - 1 do
- if test_depend_corrupt(i) == TRUE and __corruptions[i].removable == TRUE then
- pos[max] = i
- max = max + 1
- end
- end
-
- -- Ok now get one of them
- if (max > 0) then
- local ret = rand_int(max)
-
- player_lose_corruption(pos[ret])
- cmsg_print(TERM_L_RED, __corruptions[pos[ret]].lose_text)
-
- -- Ok now lets see if it broke some dependancies
- for i = 0, max - 1 do
- if player.corruption(pos[i]) ~= test_depend_corrupt(pos[i]) then
- player_lose_corruption(pos[i])
- cmsg_print(TERM_L_RED, __corruptions[pos[i]].lose_text)
- end
- end
-
- return pos[ret]
- else
- return -1
- end
-end
-
--- Creates a new corruption
-function add_corruption(c)
- assert(c.color, "No corruption color")
- assert(c.name, "No corruption name")
- assert(c.get_text, "No corruption get_text")
- assert(c.lose_text, "No corruption lose_text")
- assert(c.desc, "No corruption desc")
- if not c.random then c.random = TRUE end
- if not c.removable then c.removable = TRUE end
- if not c.allow then c.allow = function() return not nil end end
-
- if c.depends == nil then c.depends = {} end
- if c.oppose == nil then c.oppose = {} end
-
- -- We must make sure the other ones opposes too
- local o, i
- for o, i in c.oppose do
- __corruptions[o].oppose[__corruptions_max] = TRUE
- end
-
- if type(c.desc) == "table" then
- local new_desc = ""
- local index, h
- for index, h in c.desc do
- new_desc = new_desc..h.."\n"
- end
- c.desc = new_desc
- end
-
- __corruptions[__corruptions_max] = c
- __corruptions_max = __corruptions_max + 1
- return (__corruptions_max - 1)
-end
-
diff --git a/lib/mods/theme/core/init.lua b/lib/mods/theme/core/init.lua
index 11b812d5..3db34076 100644
--- a/lib/mods/theme/core/init.lua
+++ b/lib/mods/theme/core/init.lua
@@ -17,7 +17,6 @@ tome_dofile_anywhere(ANGBAND_DIR_CORE, "monsters.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "building.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "s_aux.lua")
-tome_dofile_anywhere(ANGBAND_DIR_CORE, "crpt_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "mimc_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "quests.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "gods.lua")