forked from github/server
bug 2290: sawmill bonus was broken.
not pleased with the test, which is in lua only. https://bugs.eressea.de/view.php?id=2290
This commit is contained in:
parent
4502141c5b
commit
b0baba4405
|
@ -1,5 +1,3 @@
|
||||||
require 'tests.economy'
|
|
||||||
|
|
||||||
require 'tests.e2.undead'
|
require 'tests.e2.undead'
|
||||||
require 'tests.e2.shiplanding'
|
require 'tests.e2.shiplanding'
|
||||||
require 'tests.e2.e2features'
|
require 'tests.e2.e2features'
|
||||||
|
@ -8,6 +6,7 @@ require 'tests.e2.destroy'
|
||||||
require 'tests.e2.guard'
|
require 'tests.e2.guard'
|
||||||
require 'tests.e2.spells'
|
require 'tests.e2.spells'
|
||||||
require 'tests.e2.stealth'
|
require 'tests.e2.stealth'
|
||||||
|
require 'tests.economy'
|
||||||
require 'tests.orders'
|
require 'tests.orders'
|
||||||
require 'tests.common'
|
require 'tests.common'
|
||||||
require 'tests.report'
|
require 'tests.report'
|
||||||
|
|
|
@ -4,6 +4,7 @@ require 'tests.e3.spells'
|
||||||
require 'tests.e3.rules'
|
require 'tests.e3.rules'
|
||||||
require 'tests.e3.parser'
|
require 'tests.e3.parser'
|
||||||
require 'tests.e3.morale'
|
require 'tests.e3.morale'
|
||||||
|
require 'tests.economy'
|
||||||
require 'tests.orders'
|
require 'tests.orders'
|
||||||
require 'tests.common'
|
require 'tests.common'
|
||||||
-- require 'tests.report'
|
-- require 'tests.report'
|
||||||
|
|
|
@ -127,6 +127,20 @@ function test_ironkeeper_guards_iron()
|
||||||
assert_equal(level, u:get_item("iron"))
|
assert_equal(level, u:get_item("iron"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_sawmill()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
r:set_resource("tree", 100)
|
||||||
|
local u = unit.create(faction.create("human"), r)
|
||||||
|
u:add_item("money", 250) -- sawmill maintenance
|
||||||
|
u:set_skill("forestry", 6)
|
||||||
|
u.building = building.create(r, "sawmill")
|
||||||
|
u.building.size = 1
|
||||||
|
u:add_order("MACHE 6 HOLZ")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(6, u:get_item("log"))
|
||||||
|
assert_equal(97, r:get_resource("tree"))
|
||||||
|
end
|
||||||
|
|
||||||
function test_ent_guards_trees()
|
function test_ent_guards_trees()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
r:set_resource("tree", 100)
|
r:set_resource("tree", 100)
|
||||||
|
|
|
@ -1123,7 +1123,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
allocation *al;
|
allocation *al;
|
||||||
int nreq = 0;
|
int nreq = 0;
|
||||||
resource_limit *rdata = get_resourcelimit(rtype);
|
resource_limit *rdata = get_resourcelimit(rtype);
|
||||||
int avail = 0;
|
int avail = INT_MAX;
|
||||||
|
|
||||||
for (al = alist; al; al = al->next) {
|
for (al = alist; al; al = al->next) {
|
||||||
nreq += required(al->want, al->save);
|
nreq += required(al->want, al->save);
|
||||||
|
@ -1145,7 +1145,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
if (rx>0 && rng_int() % nreq < rx) ++x;
|
if (rx>0 && rng_int() % nreq < rx) ++x;
|
||||||
avail -= x;
|
avail -= x;
|
||||||
nreq -= want;
|
nreq -= want;
|
||||||
al->get = x * al->save.sa[0] / al->save.sa[1];
|
al->get = x * al->save.sa[1] / al->save.sa[0];
|
||||||
al->get = MIN(al->want, al->get);
|
al->get = MIN(al->want, al->get);
|
||||||
if (rdata->produce) {
|
if (rdata->produce) {
|
||||||
int use = required(al->get, al->save);
|
int use = required(al->get, al->save);
|
||||||
|
|
|
@ -407,6 +407,12 @@ static void test_make_item(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 22, get_item(u, itype));
|
CuAssertIntEquals(tc, 22, get_item(u, itype));
|
||||||
CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */
|
CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */
|
||||||
|
|
||||||
|
rdata->modifiers[0].value = frac_make(1, 2);
|
||||||
|
make_item(u, itype, 6);
|
||||||
|
split_allocations(u->region);
|
||||||
|
CuAssertIntEquals(tc, 28, get_item(u, itype));
|
||||||
|
CuAssertIntEquals(tc, 280, u->region->resources->amount); /* 50% saving = 3 stones make 6 stones */
|
||||||
|
|
||||||
rdata->modifiers[0].flags = RMF_REQUIREDBUILDING;
|
rdata->modifiers[0].flags = RMF_REQUIREDBUILDING;
|
||||||
rdata->modifiers[0].race = NULL;
|
rdata->modifiers[0].race = NULL;
|
||||||
rdata->modifiers[0].btype = bt_get_or_create("mine");
|
rdata->modifiers[0].btype = bt_get_or_create("mine");
|
||||||
|
|
Loading…
Reference in New Issue