-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test cases
- Loading branch information
Showing
3 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
from hsr_simulation.character import Character | ||
|
||
|
||
@pytest.fixture | ||
def character(): | ||
return Character() | ||
|
||
|
||
def test_dmg_reduction_when_enemy_not_broken(character): | ||
# Set up the character with enemy not broken | ||
character.enemy_weakness_broken = False | ||
initial_toughness = character.current_enemy_toughness | ||
|
||
# Call the method | ||
dmg = character._calculate_damage(skill_multiplier=1, break_amount=10, can_crit=False) | ||
|
||
# Assert the damage is reduced | ||
assert dmg < character.atk | ||
assert character.current_enemy_toughness == initial_toughness - 10 | ||
|
||
|
||
def test_no_dmg_reduction_when_enemy_broken(character): | ||
# Set up the character with enemy broken | ||
character.enemy_weakness_broken = True | ||
initial_toughness = character.current_enemy_toughness | ||
|
||
# Call the method | ||
dmg = character._calculate_damage(skill_multiplier=1, break_amount=10, can_crit=False) | ||
|
||
# Assert the damage is not reduced | ||
assert dmg == character.atk | ||
assert character.current_enemy_toughness == initial_toughness - 10 |
42 changes: 42 additions & 0 deletions
42
tests/test_character/test_check_if_enemy_weakness_broken.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
from hsr_simulation.character import Character | ||
|
||
@pytest.fixture | ||
def character(): | ||
return Character() | ||
|
||
def test_enemy_weakness_broken(character): | ||
# Set up the character with enemy toughness <= 0 and weakness not broken | ||
character.current_enemy_toughness = 0 | ||
character.enemy_weakness_broken = False | ||
|
||
# Call the method | ||
character.check_if_enemy_weakness_broken() | ||
|
||
# Assert the enemy weakness is broken and turn delayed duration is set | ||
assert character.enemy_weakness_broken is True | ||
assert character.enemy_turn_delayed_duration_weakness_broken == 1 | ||
|
||
def test_enemy_weakness_not_broken(character): | ||
# Set up the character with enemy toughness > 0 | ||
character.current_enemy_toughness = 10 | ||
character.enemy_weakness_broken = False | ||
|
||
# Call the method | ||
character.check_if_enemy_weakness_broken() | ||
|
||
# Assert the enemy weakness is not broken | ||
assert character.enemy_weakness_broken is False | ||
assert character.enemy_turn_delayed_duration_weakness_broken == 0 | ||
|
||
def test_enemy_already_weakness_broken(character): | ||
# Set up the character with enemy weakness already broken | ||
character.current_enemy_toughness = 0 | ||
character.enemy_weakness_broken = True | ||
|
||
# Call the method | ||
character.check_if_enemy_weakness_broken() | ||
|
||
# Assert the enemy weakness remains broken and turn delayed duration is unchanged | ||
assert character.enemy_weakness_broken is True | ||
assert character.enemy_turn_delayed_duration_weakness_broken == 0 |
45 changes: 45 additions & 0 deletions
45
tests/test_character/test_simulate_enemy_weakness_broken.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
from hsr_simulation.character import Character | ||
|
||
|
||
@pytest.fixture | ||
def character(): | ||
return Character() | ||
|
||
|
||
def test_enemy_weakness_broken(character): | ||
# Set up the character with enemy weakness broken | ||
character.enemy_weakness_broken = True | ||
character.enemy_turn_delayed_duration_weakness_broken = 1 | ||
|
||
# Call the method | ||
character._simulate_enemy_weakness_broken() | ||
|
||
# Assert the enemy turn delayed duration is decreased | ||
assert character.enemy_turn_delayed_duration_weakness_broken == 0 | ||
|
||
|
||
def test_enemy_weakness_broken_regenerate(character): | ||
# Set up the character with enemy weakness broken and no delay duration | ||
character.enemy_weakness_broken = True | ||
character.enemy_turn_delayed_duration_weakness_broken = 0 | ||
|
||
# Call the method | ||
character._simulate_enemy_weakness_broken() | ||
|
||
# Assert the enemy toughness is regenerated and weakness is not broken | ||
assert character.current_enemy_toughness == character.enemy_toughness | ||
assert not character.enemy_weakness_broken | ||
|
||
|
||
def test_enemy_not_weakness_broken(character): | ||
# Set up the character with enemy not weakness broken | ||
character.enemy_weakness_broken = False | ||
|
||
# Call the method | ||
character._simulate_enemy_weakness_broken() | ||
|
||
# Assert nothing changes | ||
assert character.enemy_turn_delayed_duration_weakness_broken == 0 | ||
assert character.current_enemy_toughness == character.enemy_toughness | ||
assert not character.enemy_weakness_broken |