kill ancient godcursezone code.

add some tests for planting seeds.
This commit is contained in:
Enno Rehling 2020-01-04 12:22:14 +01:00
parent 59d8775e21
commit fb21d6d932
14 changed files with 88 additions and 148 deletions

View File

@ -391,16 +391,6 @@
<arg name="id" type="int"/>
</type>
</message>
<message name="curseinfo::godcurseocean" section="events">
<type>
<arg name="id" type="int"/>
</type>
</message>
<message name="curseinfo::godcurse" section="events">
<type>
<arg name="id" type="int"/>
</type>
</message>
<message name="curseinfo::disorientationzone" section="events">
<type>
<arg name="id" type="int"/>
@ -712,11 +702,6 @@
<arg name="password" type="string"/>
</type>
</message>
<message name="godcurse_destroy_ship" section="events">
<type>
<arg name="ship" type="ship"/>
</type>
</message>
<message name="skillpotion_use" section="events">
<type>
<arg name="unit" type="unit"/>

View File

@ -437,9 +437,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Pferde kann man
msgid "error307"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Snotlinge sind zu dumm, um auf den Feldern zu arbeiten.\""
msgid "godcurse_destroy_ship"
msgstr "\"Die Mannschaft krank vom vergifteten Wasser, Planken, Ruder und Segel zerfressen von den Wassern des verfluchten Meeres, ergibt sich die $ship($ship) in ihr Schicksal und sinkt.\""
msgid "too_many_units_in_faction"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Eine Partei darf nicht aus mehr als $int($allowed) Einheiten bestehen.\""
@ -1034,9 +1031,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Auf dem Schiff
msgid "sp_icastle_effect"
msgstr "\"Verwundert blicken die Bauern von $region($region) auf ein neues Gebäude.\""
msgid "curseinfo::godcurse"
msgstr "\"Diese Region wurde von den Göttern verflucht. Stinkende Nebel ziehen über die tote Erde und furchtbare Kreaturen ziehen über das Land. Die Brunnen sind vergiftet, und die wenigen essbaren Früchte sind von einem rosa Pilz überzogen. Niemand kann hier lange überleben. ($int36($id))\""
msgid "recruit_archetype"
msgstr "\"$unit($unit) rekrutiert $int($amount) $localize($archetype).\""
@ -2555,9 +2549,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Man benötigt m
msgid "error177"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diesen Spruch kann der Vertraute nicht zaubern.\""
msgid "curseinfo::godcurseocean"
msgstr "\"Diese Region wurde von den Göttern verflucht. Das Meer ist eine ekelige Brühe, braunschwarze, stinkende Gase steigen aus den unergründlichen Tiefen hervor, und untote Seeungeheuer, Schiffe zerfressend und giftige grüne Galle geifernd, sind der Schrecken aller Seeleute, die diese Gewässer durchqueren. Niemand kann hier lange überleben. ($int36($id))\""
msgid "curseinfo::sparkle_4"
msgstr "\"Ein schimmernder Lichterkranz umgibt $unit($unit). ($int36($id))\""

View File

@ -437,9 +437,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - You can only br
msgid "error307"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - We snotlings is too stupid fer dat!\""
msgid "godcurse_destroy_ship"
msgstr "\"Her sailors sick from the poisened ocean, planks, rudder und sails corroded by the waters of the cursed ocean, the $ship($ship) finally succumbs to her destiny and sinks.\""
msgid "too_many_units_in_faction"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - A faction may not consist of more than $int($allowed) units.\""
@ -1034,9 +1031,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - There are not e
msgid "sp_icastle_effect"
msgstr "\"Flabbergasted, the peasants of $region($region) behold a new building.\""
msgid "curseinfo::godcurse"
msgstr "\"This region was cursed by the gods. Stinking vapors billow over the dead ground and hideous creatures move about the country. The wells are poisened and the edible plants are covered by a pink fungus. Noone can live here for long. ($int36($id))\""
msgid "recruit_archetype"
msgstr "\"$unit($unit) recruits $int($amount) $localize($archetype).\""
@ -2555,9 +2549,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - You need at lea
msgid "error177"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The familiar cannot cast this spell.\""
msgid "curseinfo::godcurseocean"
msgstr "\"This region was cursed by the gods. The sea is a foul cesspool, noxious gases rise from the deep, undead seamonsters attack all ships. Noone can live here for long. ($int36($id))\""
msgid "curseinfo::sparkle_4"
msgstr "\"A circle of shimmering lights surrounds $unit($unit). ($int36($id))\""

View File

@ -2331,10 +2331,6 @@ msgstr "Seelenfrieden"
msgid "list_and"
msgstr " und "
msgctxt "spell"
msgid "godcursezone"
msgstr "Fluch der Götter"
msgid "sptype_postcombat"
msgstr "Postkampfzauber"

View File

@ -1976,10 +1976,6 @@ msgstr " and "
msgid "h18_p"
msgstr "ice begonias"
msgctxt "spell"
msgid "godcursezone"
msgstr "Curse of the Gods"
msgid "sptype_postcombat"
msgstr "post-combat spell"

View File

@ -1,3 +1,6 @@
require 'tests.e2.trees'
require 'tests.e2.allies'
require 'tests.e2.quit'
require 'tests.e2.movement'
require 'tests.e2.carts'
require 'tests.e2.quit'

View File

@ -0,0 +1,66 @@
require "lunit"
module("tests.e2.trees", package.seeall, lunit.testcase )
function setup()
eressea.game.reset()
eressea.settings.set("rules.food.flags", "4") -- food is free
eressea.settings.set("NewbieImmunity", "0")
end
function test_no_growth()
set_turn(204)
assert_equal('spring', get_season())
local r = region.create(0, 0, 'plain')
r:set_resource('seed', 0)
r:set_resource('sapling', 0)
r:set_resource('tree', 0)
process_orders()
assert_equal(0, r:get_resource('seed'))
assert_equal(0, r:get_resource('sapling'))
assert_equal(0, r:get_resource('tree'))
end
function x_test_plant_seeds()
set_turn(184)
assert_equal('summer', get_season())
local f = faction.create('goblin')
local r = region.create(0, 0, 'plain')
r:set_resource('seed', 0)
r:set_resource('sapling', 0)
r:set_resource('tree', 0)
local u = unit.create(f, r)
u:set_skill('herbalism', 20)
u:add_item('seed', 40)
u:add_order("PFLANZE 20 Samen")
process_orders()
assert_equal(0, r:get_resource('sapling'))
assert_equal(20, r:get_resource('seed'))
assert_equal(0, r:get_resource('tree'))
assert_equal(20, u:get_item('seed'))
end
function test_plant_seeds_spring()
set_turn(202)
assert_equal('spring', get_season())
local f = faction.create('goblin')
local r = region.create(0, 0, 'plain')
r:set_resource('seed', 0)
r:set_resource('sapling', 0)
r:set_resource('tree', 0)
process_orders()
assert_equal(0, r:get_resource('sapling'))
assert_equal(0, r:get_resource('seed'))
assert_equal(0, r:get_resource('tree'))
local u = unit.create(f, r)
u:set_skill('herbalism', 20)
u:add_item('seed', 40)
u:add_order("PFLANZE 20 Samen")
process_orders()
assert_equal(20, r:get_resource('sapling')) -- T12+ in Spring
assert_equal(0, r:get_resource('seed'))
assert_equal(0, r:get_resource('tree'))
assert_equal(20, u:get_item('seed'))
end

View File

@ -260,7 +260,7 @@ static int tolua_dice_rand(lua_State * L)
static int tolua_get_season(lua_State * L)
{
int turn_no = (int)tolua_tonumber(L, 1, 0);
int turn_no = (int)tolua_tonumber(L, 1, turn);
season_t season = calendar_season(turn_no);
tolua_pushstring(L, seasonnames[season]);
return 1;

View File

@ -746,10 +746,6 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
variant vm;
/* Godcurse: Income -10 */
c = get_curse(r->attribs, &ct_godcursezone);
if (c && curse_active(c)) {
wage = (wage < 10) ? 0 : (wage - 10);
}
vm = frac_make(wage, 1);
/* Bei einer Duerre verdient man nur noch ein Viertel */

View File

@ -129,6 +129,7 @@ static int read_ccompat(const char *cursename, struct storage *store)
} *seek, old_curses[] = {
{ "disorientationzone", "" },
{ "shipdisorientation", "" },
{ "godcursezone", "" },
{ NULL, NULL }
};
for (seek = old_curses; seek->name; ++seek) {

View File

@ -463,10 +463,7 @@ static void horses(region * r)
maxhorses = region_maxworkers(r) / 10;
horses = rhorses(r);
if (horses > 0) {
if (is_cursed(r->attribs, &ct_godcursezone)) {
rsethorses(r, (int)(horses * 0.9));
}
else if (maxhorses > 0) {
if (maxhorses > 0) {
double growth =
(RESOURCE_QUANTITY * (HORSEGROWTH * 200.0 * ((double)maxhorses -
horses))) / (double)maxhorses;
@ -625,12 +622,6 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
a_removeall(&r->attribs, &at_germs);
}
if (is_cursed(r->attribs, &ct_godcursezone)) {
rsettrees(r, 1, (int)(rtrees(r, 1) * 0.9));
rsettrees(r, 2, (int)(rtrees(r, 2) * 0.9));
return;
}
mp = max_production(r);
if (mp <= 0)
return;
@ -685,9 +676,6 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
else if (current_season == SEASON_SPRING) {
int growth;
if (is_cursed(r->attribs, &ct_godcursezone))
return;
/* in at_germs merken uns die Zahl der Samen und Sproesslinge, die
* dieses Jahr aelter werden duerfen, damit nicht ein Same im selben
* Zyklus zum Baum werden kann */
@ -701,31 +689,7 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
* zu wachsen, damit sollten nach 5-6 Wochen alle gewachsen sein */
growth = 1800;
/* Samenwachstum */
/* Raubbau abfangen, es duerfen nie mehr Samen wachsen, als aktuell
* in der Region sind */
seeds = rtrees(r, 0);
if (seeds > a->data.sa[0]) seeds = a->data.sa[0];
sprout = 0;
for (i = 0; i < seeds; i++) {
if (rng_int() % 10000 < growth)
sprout++;
}
/* aus dem Samenpool dieses Jahres abziehen */
a->data.sa[0] = (short)(seeds - sprout);
/* aus dem gesamt Samenpool abziehen */
rsettrees(r, 0, rtrees(r, 0) - sprout);
/* zu den Sproesslinge hinzufuegen */
rsettrees(r, 1, rtrees(r, 1) + sprout);
/* Baumwachstum */
/* hier gehen wir davon aus, das Jungbaeume nicht ohne weiteres aus
* der Region entfernt werden koennen, da Jungbaeume in der gleichen
* Runde nachwachsen, wir also nicht mehr zwischen diesjaehrigen und
* 'alten' Jungbaeumen unterscheiden koennten */
sprout = rtrees(r, 1);
if (sprout > a->data.sa[1]) sprout = a->data.sa[1];
grownup_trees = 0;
@ -740,6 +704,22 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
rsettrees(r, 1, rtrees(r, 1) - grownup_trees);
/* zu den Baeumen hinzufuegen */
rsettrees(r, 2, rtrees(r, 2) + grownup_trees);
/* Samenwachstum */
seeds = rtrees(r, 0);
if (seeds > a->data.sa[0]) seeds = a->data.sa[0];
sprout = 0;
for (i = 0; i < seeds; i++) {
if (rng_int() % 10000 < growth)
sprout++;
}
/* aus dem Samenpool dieses Jahres abziehen */
a->data.sa[0] = (short)(seeds - sprout);
/* aus dem gesamt Samenpool abziehen */
rsettrees(r, 0, rtrees(r, 0) - sprout);
/* zu den Sproesslinge hinzufuegen */
rsettrees(r, 1, rtrees(r, 1) + sprout);
}
}

View File

@ -380,44 +380,6 @@ static void create_icebergs(void)
}
}
static void godcurse(void)
{
region *r;
for (r = regions; r; r = r->next) {
if (is_cursed(r->attribs, &ct_godcursezone)) {
unit *u;
for (u = r->units; u; u = u->next) {
skill *sv = u->skills;
while (sv != u->skills + u->skill_size) {
int weeks = 1 + rng_int() % 3;
reduce_skill(u, sv, weeks);
++sv;
}
}
if (fval(r->terrain, SEA_REGION)) {
ship *sh;
for (sh = r->ships; sh;) {
ship *shn = sh->next;
double dmg = config_get_flt("rules.ship.damage.godcurse", 0.1);
damage_ship(sh, dmg);
if (sh->damage >= sh->size * DAMAGE_SCALE) {
unit *uo = ship_owner(sh);
if (uo) {
ADDMSG(&uo->faction->msgs,
msg_message("godcurse_destroy_ship", "ship", sh));
}
sink_ship(sh);
remove_ship(&sh->region->ships, sh);
}
sh = shn;
}
}
}
}
}
/** handles the "orcish" curse that makes units grow like old orks
* TODO: This would probably be better handled in an age-function for the curse,
* but it's now being called by randomevents()
@ -535,7 +497,6 @@ void randomevents(void)
for (r = regions; r; r = r->next) {
drown(r);
}
godcurse();
orc_growth();
demon_skillchanges();
if (volcano_module()) {

View File

@ -22,30 +22,6 @@
#include <stdlib.h>
#include <assert.h>
/*
* godcursezone
*/
static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ,
const curse * c, int self)
{
region *r = (region *)obj;
UNUSED_ARG(typ);
UNUSED_ARG(self);
assert(typ == TYP_REGION);
if (r->terrain->flags & SEA_REGION) {
return msg_message("curseinfo::godcurseocean", "id", c->no);
}
return msg_message("curseinfo::godcurse", "id", c->no);
}
const struct curse_type ct_godcursezone = {
"godcursezone",
CURSETYP_NORM, CURSE_IMMUNE, (NO_MERGE),
cinfo_cursed_by_the_gods,
};
/* --------------------------------------------------------------------- */
/*
* C_GBDREAM
@ -299,7 +275,6 @@ void register_regioncurse(void)
ct_register(&ct_badmagicresistancezone);
ct_register(&ct_goodmagicresistancezone);
ct_register(&ct_riotzone);
ct_register(&ct_godcursezone);
ct_register(&ct_holyground);
ct_register(&ct_healing);
}

View File

@ -10,7 +10,6 @@ extern "C" {
extern const struct curse_type ct_peacezone;
extern const struct curse_type ct_drought;
extern const struct curse_type ct_blessedharvest;
extern const struct curse_type ct_godcursezone;
extern const struct curse_type ct_gbdream;
extern const struct curse_type ct_healing;
extern const struct curse_type ct_antimagiczone;