forked from github/server
a working stone circle boosts magic resistance of people inside.
This commit is contained in:
parent
721442584c
commit
58c310de29
3 changed files with 19 additions and 12 deletions
|
@ -1116,12 +1116,11 @@ variant magic_resistance(const unit * target)
|
|||
/* Bonus durch Gebaeude */
|
||||
{
|
||||
struct building *b = inside_building(target);
|
||||
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
||||
|
||||
/* gesegneter Steinkreis gibt 30% dazu */
|
||||
if (btype) {
|
||||
if (b && b->type->magresbonus && building_is_active(b)) {
|
||||
/* TODO: legacy. building-bonus is an integer-percentage */
|
||||
prob = frac_add(prob, frac_make(btype->magresbonus, 100));
|
||||
prob = frac_add(prob, frac_make(b->type->magresbonus, 100));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -507,24 +507,25 @@ static void test_resist_chance(CuTest *tc) {
|
|||
static void test_magic_resistance(CuTest *tc) {
|
||||
unit *u;
|
||||
race *rc;
|
||||
building_type *btype;
|
||||
|
||||
test_setup();
|
||||
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
|
||||
btype = test_create_buildingtype("stonecircle");
|
||||
btype->magresbonus = 20; /* this building gives +20% magic resistance */
|
||||
u->building = test_create_building(u->region, btype);
|
||||
u->building->flags = BLD_MAINTAINED;
|
||||
CuAssertTrue(tc, frac_equal(frac_make(1, 5), magic_resistance(u)));
|
||||
u->building = NULL;
|
||||
|
||||
/* 5% bonus in magic resistance for each magic level */
|
||||
set_level(u, SK_MAGIC, 4); /* makes for 20% */
|
||||
CuAssertTrue(tc, frac_equal(frac_make(1, 5), magic_resistance(u)));
|
||||
set_level(u, SK_MAGIC, 0);
|
||||
|
||||
/* TODO:
|
||||
* - ct_magicresistance
|
||||
* - ct_badmagicresistancezone
|
||||
* - ct_goodmagicresistancezone
|
||||
* - alliedunit
|
||||
* - stone circles
|
||||
*/
|
||||
|
||||
CuAssertTrue(tc, frac_equal(rc->magres, magic_resistance(u)));
|
||||
rc->magres = frac_one;
|
||||
CuAssert(tc, "magic resistance is capped at 0.9", frac_equal(magic_resistance(u), frac_make(9, 10)));
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* TODO:
|
||||
* - ct_magicresistance on buildings
|
||||
* - stone circles
|
||||
*/
|
||||
|
||||
static void test_magicresistance_curse_effects(CuTest *tc) {
|
||||
struct region *r;
|
||||
|
@ -114,6 +118,9 @@ static void test_magicresistance_unit(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for spell "Heimstein"
|
||||
*/
|
||||
static void test_magicresistance_building(CuTest *tc) {
|
||||
struct region *r;
|
||||
struct faction *f1;
|
||||
|
@ -130,7 +137,7 @@ static void test_magicresistance_building(CuTest *tc) {
|
|||
u1 = test_create_unit(f1, r);
|
||||
|
||||
b1 = test_create_building(r, NULL);
|
||||
|
||||
u1->building = b1;
|
||||
c = create_curse(u1, &b1->attribs, &ct_magicresistance, 10, 20, 30, 0);
|
||||
CuAssertPtrNotNull(tc, b1->attribs);
|
||||
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)b1->attribs->type);
|
||||
|
|
Loading…
Reference in a new issue