forked from github/server
Merge branch 'master' into develop
Conflicts: src/battle.test.c src/buildno.h
This commit is contained in:
commit
1d57bf527d
10 changed files with 76 additions and 11 deletions
2
critbit
2
critbit
|
@ -1 +1 @@
|
|||
Subproject commit 934c2dd94d41da19637a76a1a8b3dfeb7aa8524d
|
||||
Subproject commit dfe57a077222c6b572da61a79dc0687f81c10055
|
|
@ -30,5 +30,5 @@ fi
|
|||
echo "backup turn $TURN, game $GAME, files: $files"
|
||||
tar cjf backup/$TURN.tar.bz2 $files
|
||||
echo "uploading game-$GAME/$TURN.tar.bz2"
|
||||
curl -n -T backup/$TURN.tar.bz2 https://dav.box.com/dav/Eressea/game-$GAME/$TURN.tar.bz2
|
||||
curl -n -T eressea.db https://dav.box.com/dav/Eressea/eressea.db
|
||||
curl -s -n -T backup/$TURN.tar.bz2 https://dav.box.com/dav/Eressea/game-$GAME/$TURN.tar.bz2
|
||||
curl -s -n -T eressea.db https://dav.box.com/dav/Eressea/eressea.db
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 612a1d06b772bbd1c9b247afbda88a6aadfc5792
|
||||
Subproject commit f837dd31e5fcf13c706db1ac2c86b7de3e706578
|
|
@ -1175,7 +1175,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
|||
const weapon_type *dwtype = NULL;
|
||||
const weapon_type *awtype = NULL;
|
||||
const weapon *weapon;
|
||||
double res = 0.0;
|
||||
double res = 1.0;
|
||||
|
||||
int rda, sk = 0, sd;
|
||||
bool magic = false;
|
||||
|
@ -3946,7 +3946,7 @@ static bool start_battle(region * r, battle ** bp)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((u_race(u)->battle_flags & BF_CANATTACK) == 0) {
|
||||
if (u_race(u)->battle_flags & BF_NO_ATTACK) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_no_attack",
|
||||
"race", u_race(u)));
|
||||
continue;
|
||||
|
|
|
@ -266,6 +266,7 @@ static void test_calculate_armor(CuTest * tc)
|
|||
i_change(&du->items, ishield, 1);
|
||||
i_change(&du->items, ichain, 1);
|
||||
dt.fighter = setup_fighter(&b, du);
|
||||
rc->battle_flags &= ~BF_EQUIPMENT;
|
||||
CuAssertIntEquals_Msg(tc, "require BF_EQUIPMENT", 1, calculate_armor(dt, 0, 0, 0));
|
||||
free_battle(b);
|
||||
|
||||
|
@ -292,6 +293,67 @@ static void test_calculate_armor(CuTest * tc)
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_magic_resistance(CuTest *tc)
|
||||
{
|
||||
troop dt;
|
||||
battle *b;
|
||||
region *r;
|
||||
unit *du;
|
||||
armor_type *ashield, *achain;
|
||||
item_type *ishield, *ichain;
|
||||
race *rc;
|
||||
double magres = 0.0;
|
||||
|
||||
test_cleanup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
ishield = it_get_or_create(rt_get_or_create("shield"));
|
||||
ashield = new_armortype(ishield, 0.0, 0.5, 1, ATF_SHIELD);
|
||||
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
||||
achain = new_armortype(ichain, 0.0, 0.5, 3, ATF_NONE);
|
||||
rc = test_create_race("human");
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
dt.index = 0;
|
||||
|
||||
dt.fighter = setup_fighter(&b, du);
|
||||
calculate_armor(dt, 0, 0, &magres);
|
||||
CuAssertDblEquals_Msg(tc, "magres unmodified", 0.0, magres, 0.01);
|
||||
|
||||
magres = 1.0;
|
||||
calculate_armor(dt, 0, 0, &magres);
|
||||
CuAssertDblEquals_Msg(tc, "no magres bonus", 0.0, magic_resistance(du), 0.01);
|
||||
CuAssertDblEquals_Msg(tc, "no magres bonus", 1.0, magres, 0.01);
|
||||
|
||||
ashield->flags |= ATF_LAEN;
|
||||
ashield->magres = 0.1;
|
||||
magres = 1.0;
|
||||
calculate_armor(dt, 0, 0, &magres);
|
||||
free_battle(b);
|
||||
|
||||
i_change(&du->items, ishield, 1);
|
||||
i_change(&du->items, ichain, 1);
|
||||
achain->flags |= ATF_LAEN;
|
||||
achain->magres = 0.1;
|
||||
ashield->flags |= ATF_LAEN;
|
||||
ashield->magres = 0.1;
|
||||
dt.fighter = setup_fighter(&b, du);
|
||||
magres = 1.0;
|
||||
calculate_armor(dt, 0, 0, &magres);
|
||||
CuAssertDblEquals_Msg(tc, "laen bonus", 0.81, magres, 0.01);
|
||||
free_battle(b);
|
||||
|
||||
i_change(&du->items, ishield, -1);
|
||||
i_change(&du->items, ichain, -1);
|
||||
set_level(du, SK_MAGIC, 2);
|
||||
dt.fighter = setup_fighter(&b, du);
|
||||
magres = 1.0;
|
||||
calculate_armor(dt, 0, 0, &magres);
|
||||
CuAssertDblEquals_Msg(tc, "magic bonus", 0.1, magic_resistance(du), 0.01);
|
||||
CuAssertDblEquals_Msg(tc, "magic bonus", 0.7, magres, 0.01);
|
||||
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_projectile_armor(CuTest * tc)
|
||||
{
|
||||
troop dt;
|
||||
|
@ -340,6 +402,7 @@ CuSuite *get_battle_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_building_defence_bonus);
|
||||
SUITE_ADD_TEST(suite, test_calculate_armor);
|
||||
SUITE_ADD_TEST(suite, test_natural_armor);
|
||||
SUITE_ADD_TEST(suite, test_magic_resistance);
|
||||
SUITE_ADD_TEST(suite, test_projectile_armor);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ race *rc_get_or_create(const char *zName)
|
|||
rc->recruit_multi = 1.0F;
|
||||
rc->regaura = 1.0F;
|
||||
rc->speed = 1.0F;
|
||||
rc->battle_flags = BF_CANATTACK;
|
||||
rc->battle_flags = 0;
|
||||
if (strchr(zName, ' ') != NULL) {
|
||||
log_error("race '%s' has an invalid name. remove spaces\n", zName);
|
||||
assert(strchr(zName, ' ') == NULL);
|
||||
|
|
|
@ -232,7 +232,7 @@ extern "C" {
|
|||
#define BF_RES_CUT (1<<3) /* Halber Schaden durch CUT */
|
||||
#define BF_RES_BASH (1<<4) /* Halber Schaden durch BASH */
|
||||
#define BF_INV_NONMAGIC (1<<5) /* Immun gegen nichtmagischen Schaden */
|
||||
#define BF_CANATTACK (1<<6) /* Kann keine ATTACKIERE Befehle ausfuehren */
|
||||
#define BF_NO_ATTACK (1<<6) /* Kann keine ATTACKIERE Befehle ausfuehren */
|
||||
|
||||
int unit_old_max_hp(struct unit *u);
|
||||
const char *racename(const struct locale *lang, const struct unit *u,
|
||||
|
|
|
@ -36,6 +36,7 @@ static void test_rc_defaults(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, rc->armor);
|
||||
CuAssertIntEquals(tc, 0, rc->at_bonus);
|
||||
CuAssertIntEquals(tc, 0, rc->df_bonus);
|
||||
CuAssertIntEquals(tc, 0, rc->battle_flags);
|
||||
CuAssertIntEquals(tc, PERSON_WEIGHT, rc->weight);
|
||||
test_cleanup();
|
||||
}
|
||||
|
|
|
@ -1733,7 +1733,7 @@ static int parse_races(xmlDocPtr doc)
|
|||
rc->ec_flags |= ECF_REC_UNLIMITED;
|
||||
|
||||
if (xml_bvalue(node, "equipment", false))
|
||||
rc->battle_flags |= BF_EQUIPMENT;
|
||||
rc->battle_flags |= BF_EQUIPMENT; // TODO: invert this flag, so rc_get_or_create gets simpler
|
||||
if (xml_bvalue(node, "noblock", false))
|
||||
rc->battle_flags |= BF_NOBLOCK;
|
||||
if (xml_bvalue(node, "invinciblenonmagic", false))
|
||||
|
@ -1744,8 +1744,8 @@ static int parse_races(xmlDocPtr doc)
|
|||
rc->battle_flags |= BF_RES_CUT;
|
||||
if (xml_bvalue(node, "resistpierce", false))
|
||||
rc->battle_flags |= BF_RES_PIERCE;
|
||||
if (xml_bvalue(node, "canattack", true))
|
||||
rc->battle_flags |= BF_CANATTACK; // TODO: invert this flag, so rc_get_or_create gets simpler
|
||||
if (xml_bvalue(node, "noattack", false))
|
||||
rc->battle_flags |= BF_NO_ATTACK;
|
||||
|
||||
for (child = node->children; child; child = child->next) {
|
||||
if (strcmp((const char *)child->name, "ai") == 0) {
|
||||
|
|
|
@ -38,6 +38,7 @@ struct race *test_create_race(const char *name)
|
|||
rc->hitpoints = 20;
|
||||
rc->maxaura = 1.0;
|
||||
rc->ec_flags |= GETITEM;
|
||||
rc->battle_flags = BF_EQUIPMENT;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue