add failing test for skill bonus from mine, start work

This commit is contained in:
Enno Rehling 2017-03-23 18:51:30 +01:00
parent 68e36e9252
commit ab87b1da85
3 changed files with 17 additions and 4 deletions

View File

@ -49,5 +49,11 @@ function test_adamantium2()
process_orders() process_orders()
assert_equal(1, u1:get_item("adamantium")) assert_equal(1, u1:get_item("adamantium"))
assert_equal(adamantium - 1, r:get_resource("adamantium")) assert_equal(adamantium - 1, r:get_resource("adamantium"))
-- mines give +1 to mining. mining 16 should give 2 adamantium
u1:set_skill("mining", 15)
process_orders()
assert_equal(3, u1:get_item("adamantium"))
assert_equal(adamantium - 3, r:get_resource("adamantium"))
end end

View File

@ -923,7 +923,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
allocation *al; allocation *al;
const resource_type *rring; const resource_type *rring;
int amount, skill, skill_mod = 0; int amount, skill, skill_mod = 0;
variant save_mod; variant save_mod = frac_make(1, 1);
/* momentan kann man keine ressourcen abbauen, wenn man daf<61>r /* momentan kann man keine ressourcen abbauen, wenn man daf<61>r
* Materialverbrauch hat: */ * Materialverbrauch hat: */
@ -950,9 +950,15 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
return; return;
} }
} }
else { if (u->building && u->building->type->modifiers) {
save_mod.sa[0] = 1; building *b = inside_building(u);
save_mod.sa[1] = 1; if (b) {
message *msg = get_modifiers(u, b->type->modifiers, &save_mod, &skill_mod);
if (msg) {
ADDMSG(&u->faction->msgs, msg);
return;
}
}
} }
/* Bergw<67>chter k<>nnen Abbau von Eisen/Laen durch Bewachen verhindern. /* Bergw<67>chter k<>nnen Abbau von Eisen/Laen durch Bewachen verhindern.

View File

@ -73,6 +73,7 @@ extern "C" {
void(*age) (struct building *); void(*age) (struct building *);
double(*taxes) (const struct building *, int size); double(*taxes) (const struct building *, int size);
struct attrib *attribs; struct attrib *attribs;
struct resource_mod *modifiers;
} building_type; } building_type;
extern struct selist *buildingtypes; extern struct selist *buildingtypes;