def impl(context): observer = context.observer hp_events = [ x for x in observer.events if e_event_type(x) == 'hit points changed' ] hp_event = hp_events[0] attack_events = [ x for x in observer.events if e_event_type(x) == 'attack hit' ] if attack_events: attack_event = attack_events[0] weapon = e_attacker(attack_event).inventory.weapon expected_damage = sum(x[0] for x in weapon.weapon_data.damage) realised_damage = e_old_hit_points(hp_event) - e_new_hit_points( hp_event) else: trap_event = [ x for x in observer.events if e_event_type(x) == 'damage trap triggered' ][0] expected_damage = 2 realised_damage = e_damage(trap_event)[0] assert_that(realised_damage, is_(less_than(expected_damage)))
def impl(context, character_name): character = get_character(context, character_name) old_hit_points = get_history_value(character, "hit_points") new_hit_points = character.hit_points total_damage_suffered = old_hit_points - new_hit_points attack_hit_events = (x for x in context.observer.events if e_event_type(x) == "attack hit") matching_events = [x for x in attack_hit_events if e_target(x).name == character_name] hit_event = matching_events[0] attacker = e_attacker(hit_event) total_damage_from_weapon = sum([x[0] for x in attacker.inventory.weapon.weapon_data.damage]) assert total_damage_suffered > total_damage_from_weapon
def impl(context, character_name): character = get_character(context, character_name) old_hit_points = get_history_value(character, 'hit_points') new_hit_points = character.hit_points total_damage_suffered = old_hit_points - new_hit_points attack_hit_events = (x for x in context.observer.events if e_event_type(x) == 'attack hit') matching_events = [ x for x in attack_hit_events if e_target(x).name == character_name ] hit_event = matching_events[0] attacker = e_attacker(hit_event) total_damage_from_weapon = sum( [x[0] for x in attacker.inventory.weapon.weapon_data.damage]) assert (total_damage_suffered > total_damage_from_weapon)
def impl(context): observer = context.observer hp_events = [x for x in observer.events if e_event_type(x) == "hit points changed"] hp_event = hp_events[0] attack_events = [x for x in observer.events if e_event_type(x) == "attack hit"] if attack_events: attack_event = attack_events[0] weapon = e_attacker(attack_event).inventory.weapon expected_damage = sum(x[0] for x in weapon.weapon_data.damage) realised_damage = e_old_hit_points(hp_event) - e_new_hit_points(hp_event) else: trap_event = [x for x in observer.events if e_event_type(x) == "damage trap triggered"][0] expected_damage = 2 realised_damage = e_damage(trap_event)[0] assert_that(realised_damage, is_(less_than(expected_damage)))