Exemplo n.º 1
0
def test_attack():
    unit1 = Unit('SoLdIeR', 100, 100, 10)
    unit2 = Unit('SoLdIeR', 100, 100, 10)
    assert unit1.hp == 100
    assert unit2.hp == 100
    unit1.attack(unit2)
    assert unit1.hp == 95
    assert unit2.hp == 90
Exemplo n.º 2
0
def test_unit_attack():
    soldier = Unit('Soldier', 100, 20)
    warrior = Unit('Warrior', 100, 20)

    assert soldier.hp == 100
    assert warrior.hp == 100

    soldier.attack(warrior)

    assert soldier.hp == 90
    assert warrior.hp == 80
Exemplo n.º 3
0
def test_unit_attack_exception():
    soldier = Unit('Soldier', 0, 20)
    warrior = Unit('Warrior', 100, 20)

    with pytest.raises(UnitIsDeadException):
        soldier.attack(warrior)

    with pytest.raises(UnitIsDeadException):
        soldier.counter_attack(warrior)

    with pytest.raises(UnitIsDeadException):
        soldier.take_damage(warrior.damage)
Exemplo n.º 4
0
def test_counter_attack_exception():
    unit1 = Unit('SoLdIeR', 100, 100, 50)
    unit2 = Unit('SoLdIeR', 100, 100, 210)
    with pytest.raises(UnitIsDeadException):
        unit1.attack(unit2)