From 976b23be724385db3deb7376961ae2ffb2499b1e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Apr 2017 20:54:53 +0200 Subject: [PATCH] refactor E3 to use the same raindance/harvest spells as E2. only indirect effects are different. --- res/e3a/spells.xml | 2 ++ scripts/eressea/e3/init.lua | 1 - scripts/eressea/e3/rules.lua | 35 ----------------------------------- scripts/tests/e3/spells.lua | 5 ++--- src/economy.c | 3 +-- src/spells.c | 5 +++-- 6 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 scripts/eressea/e3/rules.lua diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml index 89a977275..80d9e6260 100644 --- a/res/e3a/spells.xml +++ b/res/e3a/spells.xml @@ -296,6 +296,7 @@ + @@ -494,6 +495,7 @@ + diff --git a/scripts/eressea/e3/init.lua b/scripts/eressea/e3/init.lua index e376eaadc..f7402268c 100644 --- a/scripts/eressea/e3/init.lua +++ b/scripts/eressea/e3/init.lua @@ -1,4 +1,3 @@ -require 'eressea.e3.rules' require 'eressea.spells' eressea.log.debug("rules for game E3") diff --git a/scripts/eressea/e3/rules.lua b/scripts/eressea/e3/rules.lua deleted file mode 100644 index e49e03438..000000000 --- a/scripts/eressea/e3/rules.lua +++ /dev/null @@ -1,35 +0,0 @@ --- the "raindance" spell -function raindance(r, mage, level, force) - if (create_curse(mage, r, "blessedharvest", force, 1+force*2, 100 * force)) then - -- slightly crooked way of reporting an action to everyone in the region - local msg = message.create("raindance_effect") - msg:set_unit("mage", mage) - if (msg:report_action(r, mage, 3)) then - local msg2 = message.create("raindance_effect") - msg2:set_unit("mage", nil) - msg2:report_action(r, mage, 4) - end - end - return level -end - --- the "blessed harvest" spell -function blessedharvest(r, mage, level, force) - if create_curse(mage, r, "blessedharvest", force, 1+force*2, 50 * force) then - -- slightly crooked way of reporting an action to everyone in the region - local msg = message.create("harvest_effect") - msg:set_unit("mage", mage) - if (msg:report_action(r, mage, 3)) then - local msg2 = message.create("harvest_effect") - msg2:set_unit("mage", nil) - msg2:report_action(r, mage, 4) - end - for idx, rn in ipairs(r.adj) do - -- nur landregionen haben moral>=0 - if r.morale>=0 then - create_curse(mage, r, "blessedharvest", force, force*2, 50 * force) - end - end - end - return level -end diff --git a/scripts/tests/e3/spells.lua b/scripts/tests/e3/spells.lua index 5cd8ef431..24f97c221 100644 --- a/scripts/tests/e3/spells.lua +++ b/scripts/tests/e3/spells.lua @@ -32,10 +32,9 @@ function test_raindance() u:add_order("ARBEITEN") process_orders() process_orders() + assert_equal(500, r:get_resource("money")) process_orders() - assert_equal(800, r:get_resource("money")) - process_orders() - assert_equal(900, r:get_resource("money")) + assert_equal(600, r:get_resource("money")) end function test_magic() diff --git a/src/economy.c b/src/economy.c index 1a4cc5b18..48653d0aa 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2658,8 +2658,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) const curse_type *blessedharvest_ct = ct_find("blessedharvest"); if (blessedharvest_ct) { int happy = - (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); - happy = MIN(happy, jobs); + (int)(jobs * curse_geteffect(get_curse(r->attribs, blessedharvest_ct))); earnings += happy; } } diff --git a/src/spells.c b/src/spells.c index 8bf30de88..5341a8e11 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1104,8 +1104,9 @@ static int sp_blessedharvest(castorder * co) if (create_curse(mage, &r->attribs, ct_find("blessedharvest"), co->force, duration, 1.0, 0)) { - message *seen = msg_message("harvest_effect", "mage", mage); - message *unseen = msg_message("harvest_effect", "mage", NULL); + const char * effect = co->sp->sname[0]=='b' ? "harvest_effect" : "raindance_effect"; + message *seen = msg_message(effect, "mage", mage); + message *unseen = msg_message(effect, "mage", NULL); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen);