diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index adcad8f3f..dd3dd941c 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -56,6 +56,8 @@ #include #include +#include + /* util includes */ #include #include @@ -3025,6 +3027,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) /* fishes: maximale Arbeiter */ int jobs = maxwork; int p_wage = wage(r, NULL, NULL); + int money = rmoney(r); request *o; for (o = work_begin; o != work_end; ++o) { @@ -3056,7 +3059,19 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) jobs = rpeasants(r); } earnings = jobs * p_wage; - rsetmoney(r, rmoney(r) + earnings); + if (rule_blessed_harvest()==HARVEST_TAXES) { + /* E3 rules */ + static const curse_type * blessedharvest_ct; + if (!blessedharvest_ct) { + blessedharvest_ct = ct_find("blessedharvest"); + } + if (blessedharvest_ct) { + int happy = curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); + happy = MIN(happy, jobs); + earnings += happy; + } + } + rsetmoney(r, money + earnings); } static int @@ -3240,10 +3255,9 @@ produce(struct region *r) request *taxorders, *sellorders, *stealorders, *buyorders; unit *u; int todo; - static int rule_taxation = -1; static int rule_autowork = -1; - boolean limited = true; - request * nextworker = workers; + boolean limited = true; + request * nextworker = workers; /* das sind alles befehle, die 30 tage brauchen, und die in thisorder * stehen! von allen 30-tage befehlen wird einfach der letzte verwendet @@ -3255,15 +3269,14 @@ produce(struct region *r) * * lehren vor lernen. */ - if (rule_taxation<0) { - rule_taxation = get_param_int(global.parameters, "rules.economy.taxation", 0); + if (rule_autowork<0) { rule_autowork = get_param_int(global.parameters, "work.auto", 0); } assert(rmoney(r) >= 0); assert(rpeasants(r) >= 0); - if (r->land && rule_taxation==1) { + if (r->land && rule_auto_taxation()) { /* new taxation rules, region owners make money based on morale and building */ peasant_taxes(r); } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index ee5102f4e..16bc1006a 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -53,6 +53,8 @@ #include "terrain.h" #include "unit.h" +#include + /* util includes */ #include #include @@ -2639,6 +2641,13 @@ boolean is_tax_building(const building * b) return false; } +int rule_auto_taxation(void) +{ + static int rule_taxation = -1; + rule_taxation = get_param_int(global.parameters, "rules.economy.taxation", TAX_ORDER); + return rule_taxation; +} + static int default_wage(const region *r, const faction * f, const race * rc) { @@ -2681,7 +2690,10 @@ default_wage(const region *r, const faction * f, const race * rc) } else { wage = wagetable[esize][2]; } - wage += curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); + if (rule_blessed_harvest()==HARVEST_WORK) { + /* E1 rules */ + wage += curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); + } } /* Artsculpture: Income +5 */ diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index bb58378b2..5bf2d25f2 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -248,6 +248,11 @@ struct building *largestbuilding(const struct region * r, boolean (*eval)(const boolean is_castle(const struct building * b); boolean is_tax_building(const struct building * b); boolean is_owner_building(const struct building * b); + +#define TAX_ORDER 0x00 +#define TAX_OWNER 0x01 +int rule_auto_taxation(void); + extern int count_all(const struct faction * f); extern int count_migrants (const struct faction * f); extern int count_maxmigrants(const struct faction * f); diff --git a/src/common/spells/regioncurse.c b/src/common/spells/regioncurse.c index 70902aca9..6912e7d8d 100644 --- a/src/common/spells/regioncurse.c +++ b/src/common/spells/regioncurse.c @@ -196,11 +196,22 @@ static struct curse_type ct_maelstrom = { CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR), cinfo_simple }; + static struct curse_type ct_blessedharvest = { "blessedharvest", CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), cinfo_simple }; + +int rule_blessed_harvest(void) +{ + static int rule = -1; + if (rule<0) { + rule = get_param_int(global.parameters, "rules.magic.blessed_harvest", HARVEST_WORK); + } + return rule; +} + static struct curse_type ct_drought = { "drought", CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), diff --git a/src/common/spells/regioncurse.h b/src/common/spells/regioncurse.h index 16d4a4adc..46b32872c 100644 --- a/src/common/spells/regioncurse.h +++ b/src/common/spells/regioncurse.h @@ -22,6 +22,10 @@ struct locale; extern void register_regioncurse(void); +#define HARVEST_WORK 0x00 +#define HARVEST_TAXES 0x01 +int rule_blessed_harvest(void); + #ifdef __cplusplus } #endif diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 2efe7c213..bd9ae1f09 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -1069,7 +1069,7 @@ sp_mallorn(castorder *co) } /* ------------------------------------------------------------- */ -/* Name: Segen der Erde +/* Name: Segen der Erde / Regentanz * Stufe: 1 * Kategorie: Region, positiv * Gebiet: Gwyrrd @@ -1087,14 +1087,34 @@ sp_blessedharvest(castorder *co) unit *mage = co->magician.u; int cast_level = co->level; double power = co->force; - int duration = (int)power+1; variant effect; - + int rule = rule_blessed_harvest(); /* Attribut auf Region. * Existiert schon ein curse, so wird dieser verstärkt * (Max(Dauer), Max(Stärke))*/ - effect.i = 1; - create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0); + if (rule==HARVEST_WORK) { + int duration = (int)power+1; + effect.i = 1; + create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0); + } else if (rule==HARVEST_TAXES) { + int duration = (int)(power*2); + if (co->sp->id!=SPL_BLESSEDHARVEST) { + effect.i = (int)(100 * power); + create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0); + } else { + int d; + region * rn[MAXDIRECTIONS]; + get_neighbours(r, rn); + effect.i = (int)(50 * power); + for (d=0;d!=MAXDIRECTIONS;++d) { + region * rx = rn[d]; + if (rx && rx->land) { + create_curse(mage, &rx->attribs, ct_find("blessedharvest"), power, duration, effect, 0); + } + } + create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0); + } + } { message * seen = msg_message("harvest_effect", "mage", mage); message * unseen = msg_message("harvest_effect", "mage", NULL); diff --git a/src/res/e3a.xml b/src/res/e3a.xml index 68373ad1c..f5a93efd8 100644 --- a/src/res/e3a.xml +++ b/src/res/e3a.xml @@ -155,6 +155,7 @@ + diff --git a/src/res/e3a/spells.xml b/src/res/e3a/spells.xml index 7160dc3c1..740060cd6 100644 --- a/src/res/e3a/spells.xml +++ b/src/res/e3a/spells.xml @@ -276,7 +276,7 @@ - + @@ -301,7 +301,7 @@ - + @@ -502,7 +502,7 @@ - + diff --git a/src/scripts/tests.lua b/src/scripts/tests.lua index ac90f1cdc..c19ca5aea 100644 --- a/src/scripts/tests.lua +++ b/src/scripts/tests.lua @@ -7,6 +7,34 @@ local function test_rename() assert(u:get_item("ao_healing")==1) end +local function test_blessed() + free_game() + local r = region.create(0, 0, "plain") + local f = faction.create("enno@eressea.de", "human", "de") + local u = unit.create(f, r) + r:set_resource("peasant", 100) + r:set_resource("money", 0) + u:add_item("money", 1000) + u.magic = "gwyrrd" + u.race = "elf" + u:set_skill("magic", 20) + u.aura = 200 + u:add_spell("raindance") + u:add_spell("blessedharvest") + u:clear_orders() + u:add_order("ZAUBERE STUFE 3 Regentanz") + print(r:get_resource("money")) + + process_orders() + print(r:get_resource("money")) + u:clear_orders() + u:add_order("ARBEITEN") + for i=1,3 do + process_orders() + print(r:get_resource("money")) + end +end + local function test_pure() free_game() local r = region.create(0, 0, "plain") @@ -621,9 +649,7 @@ tests = { ["market"] = test_market } mytests = { - ["owners"] = test_owners, - ["mallorn"] = test_mallorn, - ["recruit2"] = test_recruit2 +-- ["blessed"] = test_blessed -- foiled by peasantgrowth } fail = 0 for k, v in pairs(mytests) do