forked from github/server
- GIVE is again 1:1 in E3
- added a test for fishing (and fixed a bug in testing) - added a test for unit limits - fixed a missing assert when too many units are working
This commit is contained in:
parent
e6d8c0df33
commit
0f59c840c1
6 changed files with 108 additions and 24 deletions
|
@ -3263,16 +3263,18 @@ tax_cmd(unit * u, struct order * ord, request ** taxorders)
|
|||
return;
|
||||
}
|
||||
|
||||
#define MAX_WORKERS 2048
|
||||
void
|
||||
auto_work(region * r)
|
||||
{
|
||||
request workers[1024];
|
||||
request workers[MAX_WORKERS];
|
||||
request * nextworker = workers;
|
||||
unit * u;
|
||||
|
||||
for (u=r->units;u;u=u->next) {
|
||||
if (!(u->flags & UFL_LONGACTION) && !is_monsters(u->faction)) {
|
||||
if (do_work(u, NULL, nextworker)==0) {
|
||||
assert(nextworker-workers<MAX_WORKERS);
|
||||
++nextworker;
|
||||
}
|
||||
}
|
||||
|
@ -3322,13 +3324,14 @@ peasant_taxes(region * r)
|
|||
void
|
||||
produce(struct region *r)
|
||||
{
|
||||
request workers[1024];
|
||||
request workers[MAX_WORKERS];
|
||||
request *taxorders, *sellorders, *stealorders, *buyorders;
|
||||
unit *u;
|
||||
int todo;
|
||||
static int rule_autowork = -1;
|
||||
boolean limited = true;
|
||||
request * nextworker = workers;
|
||||
assert(r);
|
||||
|
||||
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
|
||||
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
|
||||
|
@ -3415,6 +3418,7 @@ produce(struct region *r)
|
|||
|
||||
case K_WORK:
|
||||
if (!rule_autowork && do_work(u, u->thisorder, nextworker)==0) {
|
||||
assert(nextworker-workers<MAX_WORKERS);
|
||||
++nextworker;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -247,6 +247,7 @@ get_food(region *r)
|
|||
c -= v->number;
|
||||
}
|
||||
}
|
||||
u->ship->flags -= SF_FISHING;
|
||||
}
|
||||
|
||||
if (food_rules&1) {
|
||||
|
|
|
@ -383,26 +383,29 @@ tolua_region_create(lua_State* L)
|
|||
int x = (int)tolua_tonumber(L, 1, 0);
|
||||
int y = (int)tolua_tonumber(L, 2, 0);
|
||||
const char * tname = tolua_tostring(L, 3, 0);
|
||||
plane * pl = findplane(x, y);
|
||||
const terrain_type * terrain = get_terrain(tname);
|
||||
region * r, * result;
|
||||
if (tname) {
|
||||
plane * pl = findplane(x, y);
|
||||
const terrain_type * terrain = get_terrain(tname);
|
||||
region * r, * result;
|
||||
|
||||
assert(!pnormalize(&x, &y, pl));
|
||||
r = result = findregion(x, y);
|
||||
assert(!pnormalize(&x, &y, pl));
|
||||
r = result = findregion(x, y);
|
||||
|
||||
if (terrain==NULL && r!=NULL && r->units!=NULL) {
|
||||
/* TODO: error message */
|
||||
result = NULL;
|
||||
} else if (r==NULL) {
|
||||
result = new_region(x, y, pl, 0);
|
||||
if (terrain==NULL && r!=NULL && r->units!=NULL) {
|
||||
/* TODO: error message */
|
||||
result = NULL;
|
||||
} else if (r==NULL) {
|
||||
result = new_region(x, y, pl, 0);
|
||||
}
|
||||
if (result) {
|
||||
terraform_region(result, terrain);
|
||||
}
|
||||
fix_demand(result);
|
||||
|
||||
tolua_pushusertype(L, result, TOLUA_CAST "region");
|
||||
return 1;
|
||||
}
|
||||
if (result) {
|
||||
terraform_region(result, terrain);
|
||||
}
|
||||
fix_demand(result);
|
||||
|
||||
tolua_pushusertype(L, result, TOLUA_CAST "region");
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_region_get_units(lua_State* L)
|
||||
|
|
|
@ -148,9 +148,9 @@
|
|||
<param name="rules.combat.herospeed" value="3"/>
|
||||
<param name="rules.combat.demon_vampire" value="5"/> <!-- regen 1 hp per X points of damage done -->
|
||||
<param name="rules.combat.skill_bonus" value="0"/>
|
||||
<param name="rules.combat.loot" value="5"/> <!-- only self + others - keeploot -->
|
||||
<param name="rules.items.loot_divisor" value="4"/> <!-- damage skims off 3/4 of goods transfers -->
|
||||
<param name="rules.items.give_divisor" value="3"/> <!-- corruption skims off 2/3 of goods transfers -->
|
||||
<!--param name="rules.combat.loot" value="5"/--> <!-- only self + others - keeploot -->
|
||||
<param name="rules.items.loot_divisor" value="2"/> <!-- damage skims off 1/2 of goods transfers -->
|
||||
<!--param name="rules.items.give_divisor" value="3"/--> <!-- corruption skims off 2/3 of goods transfers -->
|
||||
<param name="rules.move.owner_leave" value="1"/> <!-- owner must leave before moving -->
|
||||
<param name="rules.cavalry.skill" value="2"/>
|
||||
<param name="rules.cavalry.mode" value="1"/>
|
||||
|
@ -162,7 +162,7 @@
|
|||
<param name="rules.magic.common" value="tybied"/> <!-- tybied spells can be cast by anyone -->
|
||||
<param name="rules.magic.elfpower" value="1"/> <!-- elves get ring-of-power bonus in a forest -->
|
||||
<param name="rules.magic.playerschools" value="gwyrrd illaun draig cerddor"/>
|
||||
<param name="rules.build.other_buildings" value="0"/>
|
||||
<param name="rules.build.other_buildings" value="1"/>
|
||||
<param name="rules.economy.taxation" value="1"/>
|
||||
<param name="rules.economy.food" value="2"/>
|
||||
<param name="rules.economy.wages" value="1"/>
|
||||
|
|
|
@ -36,6 +36,30 @@ function test_xmastree()
|
|||
assert_equal(10, r:get_resource("tree"))
|
||||
end
|
||||
|
||||
function test_fishing()
|
||||
local r = region.create(0,0, "ocean")
|
||||
local r2 = region.create(1,0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local s1 = ship.create(r, "cutter")
|
||||
local u1 = unit.create(f, r, 3)
|
||||
u1.ship = s1
|
||||
u1:set_skill("sailing", 10)
|
||||
u1:add_item("money", 100)
|
||||
u1:clear_orders()
|
||||
u1:add_order("NACH O")
|
||||
update_owners()
|
||||
|
||||
process_orders()
|
||||
assert_equal(r2.id, u1.region.id)
|
||||
assert_equal(90, u1:get_item("money"))
|
||||
|
||||
u1:clear_orders()
|
||||
u1:add_order("NACH W")
|
||||
|
||||
process_orders()
|
||||
assert_equal(60, u1:get_item("money"))
|
||||
end
|
||||
|
||||
function test_capacity()
|
||||
local r = region.create(0,0, "ocean")
|
||||
region.create(1,0, "ocean")
|
||||
|
@ -352,7 +376,7 @@ function test_canoe_passes_through_land()
|
|||
assert_equal(u2.region.id, dst.id, "canoe could not leave coast")
|
||||
end
|
||||
|
||||
function test_give_only_a_third_of_items()
|
||||
function pull_give_only_a_third_of_items()
|
||||
free_game()
|
||||
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
|
||||
local r = u2.region
|
||||
|
@ -381,3 +405,33 @@ function test_give_only_a_third_of_items()
|
|||
assert_equal(m1-332-10*u1.number, u1:get_item("money"))
|
||||
assert_equal(m2+110-10*u2.number, u2:get_item("money"))
|
||||
end
|
||||
|
||||
function test_give_100_percent_of_items()
|
||||
free_game()
|
||||
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
|
||||
local r = u2.region
|
||||
u1.faction.age = 10
|
||||
u2.faction.age = 10
|
||||
u1:add_item("money", 500)
|
||||
local m1, m2 = u1:get_item("money"), u2:get_item("money")
|
||||
u1:clear_orders()
|
||||
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Silber")
|
||||
u2:clear_orders()
|
||||
u2:add_order("LERNEN Hiebwaffen")
|
||||
process_orders()
|
||||
assert(u1:get_item("money")==m1-10*u1.number)
|
||||
assert(u2:get_item("money")==m2-10*u2.number)
|
||||
|
||||
m1, m2 = u1:get_item("money"), u2:get_item("money")
|
||||
u1:clear_orders()
|
||||
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Silber")
|
||||
u2:clear_orders()
|
||||
u2:add_order("HELFE " .. itoa36(u1.faction.id) .. " GIB")
|
||||
u2:add_item("horse", 100)
|
||||
u2:add_order("GIB 0 ALLES PFERD")
|
||||
local h = r:get_resource("horse")
|
||||
process_orders()
|
||||
assert(r:get_resource("horse")>=h+100)
|
||||
assert_equal(m1-332-10*u1.number, u1:get_item("money"))
|
||||
assert_equal(m2+332-10*u2.number, u2:get_item("money"))
|
||||
end
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
require "lunit"
|
||||
|
||||
module( "e2", package.seeall, lunit.testcase )
|
||||
|
||||
function setup()
|
||||
free_game()
|
||||
end
|
||||
|
||||
function test_unit_limit_is_1500()
|
||||
free_game()
|
||||
local r = region.create(0,0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
for i = 1,1500 do
|
||||
unit.create(f, r, 1)
|
||||
end
|
||||
local u = unit.create(f, r, 0)
|
||||
u:add_item("money", 20000)
|
||||
u:clear_orders()
|
||||
u:add_order("REKRUTIEREN 1")
|
||||
process_orders()
|
||||
assert_equal(1, u.number)
|
||||
end
|
Loading…
Reference in a new issue