forked from github/server
parent
0a3e3de5a3
commit
aee68fbd0f
|
@ -1036,6 +1036,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
|
||||||
static int required(int want, variant save)
|
static int required(int want, variant save)
|
||||||
{
|
{
|
||||||
int req = (int)(want * save.sa[0] / save.sa[1]);
|
int req = (int)(want * save.sa[0] / save.sa[1]);
|
||||||
|
int r = want * save.sa[0] % save.sa[1];
|
||||||
|
if (r>0) ++req;
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -405,6 +405,11 @@ static void test_make_item(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 21, get_item(u, itype));
|
CuAssertIntEquals(tc, 21, get_item(u, itype));
|
||||||
CuAssertIntEquals(tc, 284, u->region->resources->amount); /* 60% saving = 6 stones make 10 stones */
|
CuAssertIntEquals(tc, 284, u->region->resources->amount); /* 60% saving = 6 stones make 10 stones */
|
||||||
|
|
||||||
|
make_item(u, itype, 1);
|
||||||
|
split_allocations(u->region);
|
||||||
|
CuAssertIntEquals(tc, 22, get_item(u, itype));
|
||||||
|
CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */
|
||||||
|
|
||||||
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