Ejemplo n.º 1
0
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)))
Ejemplo n.º 2
0
def impl(context, damage_amount):
    observer = context.observer
    damage = int(damage_amount)

    hp_events = [x for x in observer.events if e_event_type(x) == "hit points changed"]
    hp_event = hp_events[0]

    realised_damage = e_old_hit_points(hp_event) - e_new_hit_points(hp_event)

    assert_that(realised_damage, is_(equal_to(damage)))
Ejemplo n.º 3
0
def impl(context, damage_amount):
    observer = context.observer
    damage = int(damage_amount)

    hp_events = [
        x for x in observer.events if e_event_type(x) == 'hit points changed'
    ]
    hp_event = hp_events[0]

    realised_damage = e_old_hit_points(hp_event) - e_new_hit_points(hp_event)

    assert_that(realised_damage, is_(equal_to(damage)))
Ejemplo n.º 4
0
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)))