summaryrefslogtreecommitdiff
path: root/lib/core
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-06 19:24:21 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:27 +0200
commit41b6617e992d3fedda4c0a93ddd0fa4ad834a2ae (patch)
tree14828062fd2d5faf7947feecae48ef6be1efcd00 /lib/core
parent1de4221b9e906ce8324237943165c161f78b5e07 (diff)
Lua: Refactor the "set" part of player.corruption() to C
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/crpt_aux.lua22
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/core/crpt_aux.lua b/lib/core/crpt_aux.lua
index 369cf5d1..24b71860 100644
--- a/lib/core/crpt_aux.lua
+++ b/lib/core/crpt_aux.lua
@@ -5,20 +5,8 @@ __corruptions_max = 0
__corruptions_callbacks_max = 0
-- Get the corruption
-function player.corruption(c, set)
- if set then
- player.corruptions_aux[c + 1] = set
- player.redraw = bor(player.redraw, PR_BASIC)
- player.update = bor(player.update, PU_BONUS, PU_TORCH, PU_BODY, PU_POWERS)
- if (set == TRUE) and (__corruptions[c].gain) then
- __corruptions[c].gain()
- end
- if (set == FALSE) and (__corruptions[c].lose) then
- __corruptions[c].lose()
- end
- else
- return player.corruptions_aux[c + 1]
- end
+function player.corruption(c)
+ return player.corruptions_aux[c + 1]
end
-- Test if we have that corruption
@@ -76,7 +64,7 @@ function gain_corruption(group)
if (max > 0) then
local ret = rand_int(max)
- player.corruption(pos[ret], TRUE)
+ player_gain_corruption(pos[ret])
cmsg_print(TERM_L_RED, __corruptions[pos[ret]].get_text)
return pos[ret]
@@ -103,13 +91,13 @@ function lose_corruption()
if (max > 0) then
local ret = rand_int(max)
- player.corruption(pos[ret], FALSE)
+ 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.corruption(pos[i], FALSE)
+ player_lose_corruption(pos[i])
cmsg_print(TERM_L_RED, __corruptions[pos[i]].lose_text)
end
end