Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct number of difficulties in th13 #495

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class GameConstants:
th13 = GameConstants(
id="th13",
has_replays=True,
num_difficulties=5,
num_difficulties=6,
shots=["Reimu", "Marisa", "Sanae", "Youmu"],
routes=[],
)
Expand Down
4 changes: 2 additions & 2 deletions project/thscoreboard/replays/views/replay_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def game_scoreboard(
game_id: str,
):
game: Game = get_object_or_404(Game, game_id=game_id)
filter_options = _get_filter_options(game)
filter_options = get_filter_options(game)
show_route = game_id in [
game_ids.GameIDs.TH01,
game_ids.GameIDs.TH08,
Expand All @@ -66,7 +66,7 @@ def game_scoreboard(
)


def _get_filter_options(game: Game) -> dict[str, list[str]]:
def get_filter_options(game: Game) -> dict[str, list[str]]:
if game.game_id == game_ids.GameIDs.TH01 or game.game_id == game_ids.GameIDs.TH128:
return _get_filter_options_th01_th128(game)
elif game.game_id == game_ids.GameIDs.TH08:
Expand Down
52 changes: 52 additions & 0 deletions project/thscoreboard/replays/views/test_replay_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import test as django_test
from django import urls
from replays import models

from replays import game_ids
from replays.views import replay_list
Expand Down Expand Up @@ -35,3 +36,54 @@ def testRedirectsWithoutShot(self):
response.url,
urls.reverse("Replays/GameScoreboard", args=[game_ids.GameIDs.TH07]),
)


class GetFilterOptionsTestCase(test_case.ReplayTestCase):
def test_default(self):
game = models.Game.objects.get(game_id=game_ids.GameIDs.TH06)
filter_options = replay_list.get_filter_options(game)
self.assertCountEqual(filter_options.keys(), ("Difficulty", "Shot"))
self.assertEqual(len(filter_options["Difficulty"]), 5)
self.assertEqual(len(filter_options["Shot"]), 4)

def test_th01(self):
game = models.Game.objects.get(game_id=game_ids.GameIDs.TH01)
filter_options = replay_list.get_filter_options(game)
self.assertCountEqual(filter_options.keys(), ("Difficulty", "Route"))
self.assertEqual(len(filter_options["Difficulty"]), 4)
self.assertEqual(len(filter_options["Route"]), 2)

def test_th08(self):
game = models.Game.objects.get(game_id=game_ids.GameIDs.TH08)
filter_options = replay_list.get_filter_options(game)
self.assertCountEqual(filter_options.keys(), ("Difficulty", "Route", "Shot"))
self.assertEqual(len(filter_options["Difficulty"]), 5)
self.assertEqual(len(filter_options["Route"]), 2)
self.assertEqual(len(filter_options["Shot"]), 12)

def test_th13(self):
game = models.Game.objects.get(game_id=game_ids.GameIDs.TH13)
filter_options = replay_list.get_filter_options(game)
self.assertCountEqual(filter_options.keys(), ("Difficulty", "Shot"))
self.assertEqual(len(filter_options["Difficulty"]), 5)
self.assertEqual(len(filter_options["Shot"]), 4)

def test_th16(self):
game = models.Game.objects.get(game_id=game_ids.GameIDs.TH16)
filter_options = replay_list.get_filter_options(game)
self.assertCountEqual(
filter_options.keys(), ("Difficulty", "Character", "Season")
)
self.assertEqual(len(filter_options["Difficulty"]), 5)
self.assertEqual(len(filter_options["Season"]), 4)
self.assertEqual(len(filter_options["Season"]), 4)

def test_th17(self):
game = models.Game.objects.get(game_id=game_ids.GameIDs.TH17)
filter_options = replay_list.get_filter_options(game)
self.assertCountEqual(
filter_options.keys(), ("Difficulty", "Character", "Goast")
)
self.assertEqual(len(filter_options["Difficulty"]), 5)
self.assertEqual(len(filter_options["Character"]), 3)
self.assertEqual(len(filter_options["Goast"]), 3)
Loading