75 lines
1.9 KiB
Python
75 lines
1.9 KiB
Python
from src.stats.combat_stats import CombatStats
|
|
|
|
|
|
class VisibleAll:
|
|
def test(self, _name):
|
|
return True
|
|
|
|
|
|
class VisibleNone:
|
|
def test(self, _name):
|
|
return False
|
|
|
|
|
|
def test_self_healing_counts_while_in_combat():
|
|
stats = CombatStats(VisibleAll())
|
|
stats.on_player_appeared(0, 'Healer')
|
|
stats.on_enter_combat(0)
|
|
|
|
stats.on_health_received(0, 0, 100.0)
|
|
|
|
combat_healing = stats.players_healing()
|
|
total_healing = stats.players_total_healing()
|
|
|
|
assert combat_healing[0].name == 'Healer'
|
|
assert combat_healing[0].value == 100.0
|
|
assert total_healing[0].value == 100.0
|
|
|
|
|
|
def test_total_healing_includes_post_combat_healing():
|
|
stats = CombatStats(VisibleAll())
|
|
stats.on_player_appeared(0, 'Healer')
|
|
stats.on_enter_combat(0)
|
|
stats.on_health_received(0, 0, 100.0)
|
|
stats.on_leave_combat(0)
|
|
|
|
stats.on_health_received(0, 0, 50.0)
|
|
|
|
combat_healing = stats.players_healing()
|
|
total_healing = stats.players_total_healing()
|
|
|
|
assert combat_healing[0].value == 100.0
|
|
assert total_healing[0].value == 150.0
|
|
|
|
|
|
def test_damage_taken_accumulates_per_player():
|
|
stats = CombatStats(VisibleAll())
|
|
stats.on_player_appeared(0, 'Tank')
|
|
|
|
stats.on_damage_taken(0, 250.0)
|
|
stats.on_damage_taken(0, 150.0)
|
|
|
|
damage_taken = stats.players_damage_taken()
|
|
|
|
assert damage_taken[0].name == 'Tank'
|
|
assert damage_taken[0].value == 400.0
|
|
assert damage_taken[0].value_per_second == 0.0
|
|
|
|
|
|
def test_damage_taken_counts_out_of_combat():
|
|
stats = CombatStats(VisibleAll())
|
|
stats.on_player_appeared(0, 'Tank')
|
|
|
|
stats.on_damage_taken(0, 75.0)
|
|
|
|
assert stats.players_damage_taken()[0].value == 75.0
|
|
|
|
|
|
def test_damage_taken_excludes_non_visible_players():
|
|
stats = CombatStats(VisibleNone())
|
|
stats.on_player_appeared(0, 'Enemy')
|
|
|
|
stats.on_damage_taken(0, 300.0)
|
|
|
|
assert stats.players_damage_taken() == []
|