Merge branch 'develop' of github.com:ennorehling/eressea into develop

This commit is contained in:
Enno Rehling 2020-01-18 21:07:17 +01:00
commit af50fe65a3
3 changed files with 60 additions and 42 deletions

View File

@ -1245,7 +1245,7 @@ msgid "error184"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit does not move.\"" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit does not move.\""
msgid "income_entertainment" msgid "income_entertainment"
msgstr "\"$unit($unit) earns $int($amount) in $region($region) with entertainment.\"" msgstr "\"$unit($unit) earns $int($amount) in $region($region) from entertainment.\""
msgid "error180" msgid "error180"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The spell fails.\"" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The spell fails.\""
@ -1614,7 +1614,7 @@ msgid "curseinfo::deathcloud"
msgstr "\"A poison elemental is spreading pestilence and death. ($int36($id))\"" msgstr "\"A poison elemental is spreading pestilence and death. ($int36($id))\""
msgid "income" msgid "income"
msgstr "\"$unit($unit) earns $int($amount)$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") in $region($region) $if($eq($mode,1),\" by entertainment\",$if($eq($mode,2),\" by taxes\",$if($eq($mode,3),\" by trade\",$if($eq($mode,5),\" by stealing\",$if($eq($mode,6),\" by magic\",$if($eq($mode,7),\" by pillaging\",\"\")))))).\"" msgstr "\"$unit($unit) in $region($region) earns $int($amount)$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") silver.\""
msgid "researchherb" msgid "researchherb"
msgstr "\"$unit($unit) discovers that $localize($amount) $resource($herb,0) grow in $region($region).\"" msgstr "\"$unit($unit) discovers that $localize($amount) $resource($herb,0) grow in $region($region).\""
@ -2109,7 +2109,7 @@ msgid "deathcloud_effect"
msgstr "\"$unit($mage) summons a poison elemental in $region($region).\"" msgstr "\"$unit($mage) summons a poison elemental in $region($region).\""
msgid "nr_population" msgid "nr_population"
msgstr "\"Your faction has $int($population) people in $int($units) of $int($limit) possible units.\"" msgstr "\"Your faction has $int($population) $if($eq($population,1), \"person\", \"persons\") in $int($units) of $int($limit) possible units.\""
msgid "curseinfo::shipdisorientation" msgid "curseinfo::shipdisorientation"
msgstr "This ship has lost its path. ($int36($id))" msgstr "This ship has lost its path. ($int36($id))"
@ -2217,7 +2217,7 @@ msgid "curseinfo::healingzone"
msgstr "Healing in this region is affected by magic. ($int36($id))" msgstr "Healing in this region is affected by magic. ($int36($id))"
msgid "income_entertainment_reduced" msgid "income_entertainment_reduced"
msgstr "\"In $region($region), $unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),\"\",\" of$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") \") with entertainment.\"" msgstr "\"In $region($region), $unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),\"\",\" of$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") \") from entertainment.\""
msgid "errusingpotion" msgid "errusingpotion"
msgstr "\"$unit($unit): '$order($command)' - The unit already uses $resource($using,0).\"" msgstr "\"$unit($unit): '$order($command)' - The unit already uses $resource($using,0).\""

View File

@ -5,10 +5,13 @@ module("tests.e2.trees", package.seeall, lunit.testcase )
function setup() function setup()
eressea.game.reset() eressea.game.reset()
eressea.settings.set("rules.food.flags", "4") -- food is free eressea.settings.set("rules.food.flags", "4") -- food is free
eressea.settings.set("rules.treeseeds.chance", "0.0") -- trees make no seeds
eressea.settings.set("rules.grow.formula", "0") -- no tree or seed growth
eressea.settings.set("NewbieImmunity", "0") eressea.settings.set("NewbieImmunity", "0")
end end
function test_no_growth() function test_no_growth()
eressea.settings.set("rules.grow.formula", "2") -- E2 growth rules
set_turn(204) set_turn(204)
assert_equal('spring', get_season()) assert_equal('spring', get_season())
local r = region.create(0, 0, 'plain') local r = region.create(0, 0, 'plain')
@ -21,6 +24,20 @@ function test_no_growth()
assert_equal(0, r:get_resource('tree')) assert_equal(0, r:get_resource('tree'))
end end
function test_spring_growth()
eressea.settings.set("rules.grow.formula", "2") -- E2 growth rules
set_turn(204)
assert_equal('spring', get_season())
local r = region.create(0, 0, 'plain')
r:set_resource('seed', 6)
r:set_resource('sapling', 17)
r:set_resource('tree', 0)
process_orders()
assert_equal(5, r:get_resource('seed'))
assert_equal(16, r:get_resource('sapling'))
assert_equal(2, r:get_resource('tree'))
end
-- hebalism < T6 cannot plant -- hebalism < T6 cannot plant
function test_plant_fail() function test_plant_fail()
set_turn(184) set_turn(184)
@ -63,14 +80,22 @@ end
-- in spring, herbalism >= T12 plants saplings at 10:1 rate -- in spring, herbalism >= T12 plants saplings at 10:1 rate
function test_plant_spring_saplings() function test_plant_spring_saplings()
set_turn(204) set_turn(203)
assert_equal('spring', get_season()) assert_equal('spring', get_season())
local f = faction.create('goblin') local f = faction.create('goblin')
local r = region.create(0, 0, 'plain') local r = region.create(0, 0, 'plain')
local u = unit.create(f, r)
r:set_resource('seed', 0) r:set_resource('seed', 0)
r:set_resource('sapling', 0) r:set_resource('sapling', 0)
r:set_resource('tree', 0) r:set_resource('tree', 0)
local u = unit.create(f, r)
assert_equal('spring', get_season())
process_orders() -- to initialize at_germs
assert_equal(0, r:get_resource('sapling'))
assert_equal(0, r:get_resource('seed'))
assert_equal(0, r:get_resource('tree'))
assert_equal('spring', get_season())
u:set_skill('herbalism', 12) u:set_skill('herbalism', 12)
u:add_item('seed', 20) u:add_item('seed', 20)
u:add_order("PFLANZE 20 Samen") -- limited by herbalism u:add_order("PFLANZE 20 Samen") -- limited by herbalism
@ -84,13 +109,20 @@ end
-- herbalism < T12 means we are still planting seeds at 1:1 -- herbalism < T12 means we are still planting seeds at 1:1
function test_plant_spring_seeds() function test_plant_spring_seeds()
set_turn(204) set_turn(204)
assert_equal('spring', get_season())
local f = faction.create('goblin') local f = faction.create('goblin')
local r = region.create(0, 0, 'plain') local r = region.create(0, 0, 'plain')
local u = unit.create(f, r)
r:set_resource('seed', 0) r:set_resource('seed', 0)
r:set_resource('sapling', 0) r:set_resource('sapling', 0)
r:set_resource('tree', 0) r:set_resource('tree', 0)
local u = unit.create(f, r)
assert_equal('spring', get_season())
process_orders() -- to initialize at_germs
assert_equal(0, r:get_resource('sapling'))
assert_equal(0, r:get_resource('seed'))
assert_equal(0, r:get_resource('tree'))
assert_equal('spring', get_season())
u:set_skill('herbalism', 10) u:set_skill('herbalism', 10)
u:add_item('seed', 40) u:add_item('seed', 40)
u:add_order("PFLANZE 10 Samen") u:add_order("PFLANZE 10 Samen")

View File

@ -603,9 +603,9 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
{ {
int grownup_trees, i, seeds, sprout; int grownup_trees, i, seeds, sprout;
attrib *a; attrib *a;
double seedchance = config_get_flt("rules.treeseeds.chance", 0.01F) * RESOURCE_QUANTITY;
if (current_season == SEASON_SUMMER || current_season == SEASON_AUTUMN) { if (current_season == SEASON_SUMMER || current_season == SEASON_AUTUMN) {
double seedchance = 0.01F * RESOURCE_QUANTITY;
int mp, elves = count_race(r, get_race(RC_ELF)); int mp, elves = count_race(r, get_race(RC_ELF));
direction_t d; direction_t d;
@ -653,29 +653,28 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
/* Gesamtzahl der Samen: /* Gesamtzahl der Samen:
* bis zu 6% (FORESTGROWTH*3) der Baeume samen in die Nachbarregionen */ * bis zu 6% (FORESTGROWTH*3) der Baeume samen in die Nachbarregionen */
seeds = (rtrees(r, 2) * FORESTGROWTH * 3) / 1000000; if (seedchance > 0) {
for (d = 0; d != MAXDIRECTIONS; ++d) { seeds = (rtrees(r, 2) * FORESTGROWTH * 3) / 1000000;
region *r2 = rconnect(r, d); for (d = 0; d != MAXDIRECTIONS; ++d) {
if (r2 && fval(r2->terrain, LAND_REGION) && r2->terrain->size) { region *r2 = rconnect(r, d);
/* Eine Landregion, wir versuchen Samen zu verteilen: if (r2 && fval(r2->terrain, LAND_REGION) && r2->terrain->size) {
* Die Chance, das Samen ein Stueck Boden finden, in dem sie /* Eine Landregion, wir versuchen Samen zu verteilen:
* keimen koennen, haengt von der Bewuchsdichte und der * Die Chance, das Samen ein Stueck Boden finden, in dem sie
* verfuegbaren Flaeche ab. In Gletschern gibt es weniger * keimen koennen, haengt von der Bewuchsdichte und der
* Moeglichkeiten als in Ebenen. */ * verfuegbaren Flaeche ab. In Gletschern gibt es weniger
sprout = 0; * Moeglichkeiten als in Ebenen. */
seedchance = (1000.0 * region_maxworkers(r2)) / r2->terrain->size; sprout = 0;
for (i = 0; i < seeds / MAXDIRECTIONS; i++) { seedchance = (1000.0 * region_maxworkers(r2)) / r2->terrain->size;
if (rng_int() % 10000 < seedchance) for (i = 0; i < seeds / MAXDIRECTIONS; i++) {
sprout++; if (rng_int() % 10000 < seedchance)
sprout++;
}
rsettrees(r2, 0, rtrees(r2, 0) + sprout);
} }
rsettrees(r2, 0, rtrees(r2, 0) + sprout);
} }
} }
} }
else if (current_season == SEASON_SPRING) { else if (current_season == SEASON_SPRING) {
int growth;
/* in at_germs merken uns die Zahl der Samen und Sproesslinge, die /* in at_germs merken uns die Zahl der Samen und Sproesslinge, die
* dieses Jahr aelter werden duerfen, damit nicht ein Same im selben * dieses Jahr aelter werden duerfen, damit nicht ein Same im selben
* Zyklus zum Baum werden kann */ * Zyklus zum Baum werden kann */
@ -685,19 +684,11 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
a->data.sa[0] = cap_short(rtrees(r, 0)); a->data.sa[0] = cap_short(rtrees(r, 0));
a->data.sa[1] = cap_short(rtrees(r, 1)); a->data.sa[1] = cap_short(rtrees(r, 1));
} }
/* wir haben 6 Wochen zum wachsen, jeder Same/Spross hat 18% Chance
* zu wachsen, damit sollten nach 5-6 Wochen alle gewachsen sein */
growth = 1800;
/* Baumwachstum */ /* Baumwachstum */
sprout = rtrees(r, 1); sprout = rtrees(r, 1);
if (sprout > a->data.sa[1]) sprout = a->data.sa[1]; if (sprout > a->data.sa[1]) sprout = a->data.sa[1];
grownup_trees = 0; grownup_trees = sprout / 6;
for (i = 0; i < sprout; i++) {
if (rng_int() % 10000 < growth)
grownup_trees++;
}
/* aus dem Sproesslingepool dieses Jahres abziehen */ /* aus dem Sproesslingepool dieses Jahres abziehen */
a->data.sa[1] = (short)(sprout - grownup_trees); a->data.sa[1] = (short)(sprout - grownup_trees);
/* aus dem gesamt Sproesslingepool abziehen */ /* aus dem gesamt Sproesslingepool abziehen */
@ -708,12 +699,7 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
/* Samenwachstum */ /* Samenwachstum */
seeds = rtrees(r, 0); seeds = rtrees(r, 0);
if (seeds > a->data.sa[0]) seeds = a->data.sa[0]; if (seeds > a->data.sa[0]) seeds = a->data.sa[0];
sprout = 0; sprout = seeds / 6;
for (i = 0; i < seeds; i++) {
if (rng_int() % 10000 < growth)
sprout++;
}
/* aus dem Samenpool dieses Jahres abziehen */ /* aus dem Samenpool dieses Jahres abziehen */
a->data.sa[0] = (short)(seeds - sprout); a->data.sa[0] = (short)(seeds - sprout);
/* aus dem gesamt Samenpool abziehen */ /* aus dem gesamt Samenpool abziehen */