forked from github/server
test that mistletoe users survive attacks.
This commit is contained in:
parent
1eaa1e6d84
commit
0b036557c0
|
@ -15,7 +15,6 @@ function test_use_mistletoe()
|
|||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r, 1)
|
||||
u.name = 'Miraculix'
|
||||
u:add_item('mistletoe', 3)
|
||||
u:add_order("BENUTZEN 2 Mistelzweig")
|
||||
process_orders()
|
||||
|
@ -24,6 +23,20 @@ function test_use_mistletoe()
|
|||
assert_equal(1, f:count_msg_type('use_item'))
|
||||
end
|
||||
|
||||
function test_mistletoe_survive()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local u = unit.create(faction.create("human"), r, 1)
|
||||
local u2 = unit.create(faction.create("human"), r, 1)
|
||||
local uno = u.id
|
||||
u:add_item('mistletoe', 2)
|
||||
u:add_order("BENUTZEN 2 Mistelzweig")
|
||||
u2:add_order('ATTACKIERE ' .. itoa36(uno))
|
||||
process_orders()
|
||||
u = get_unit(uno)
|
||||
assert_not_nil(u)
|
||||
assert_equal(1, u:effect('mistletoe'))
|
||||
end
|
||||
|
||||
function test_dreameye()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("human")
|
||||
|
|
10
src/battle.c
10
src/battle.c
|
@ -142,11 +142,14 @@ static int rule_tactics_formula;
|
|||
static int rule_nat_armor;
|
||||
static int rule_cavalry_mode;
|
||||
static int rule_vampire;
|
||||
static const item_type *it_mistletoe;
|
||||
|
||||
/** initialize rules from configuration.
|
||||
*/
|
||||
static void init_rules(void)
|
||||
{
|
||||
it_mistletoe = it_find("mistletoe");
|
||||
|
||||
rule_nat_armor = config_get_int("rules.combat.nat_armor", 0);
|
||||
rule_tactics_formula = config_get_int("rules.tactics.formula", 0);
|
||||
rule_goblin_bonus = config_get_int("rules.combat.goblinbonus", 10);
|
||||
|
@ -3354,11 +3357,10 @@ static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
|
|||
fighter *fc = NULL;
|
||||
|
||||
if (!attack && u->attribs) {
|
||||
const item_type *itype = it_find("mistletoe");
|
||||
if (itype) {
|
||||
int effect = get_effect(u, itype);
|
||||
if (it_mistletoe) {
|
||||
int effect = get_effect(u, it_mistletoe);
|
||||
if (effect >= u->number) {
|
||||
change_effect(u, itype, -u->number);
|
||||
change_effect(u, it_mistletoe, -u->number);
|
||||
*cp = NULL;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue