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

Add name to difficulty config (plbrault#80) #93

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 6 additions & 6 deletions src/difficulty_levels.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_easy_difficulty = {
'name': 'Easy',
'config': {
'name': 'Easy',
'num_cpus': 4,
'num_processes_at_startup': 14,
'num_ram_rows': 8,
Expand All @@ -10,8 +10,8 @@
}

_normal_difficulty = {
'name': 'Normal',
'config': {
'name': 'Normal',
'num_cpus': 4,
'num_processes_at_startup': 14,
'num_ram_rows': 5,
Expand All @@ -21,8 +21,8 @@
}

_hard_difficulty = {
'name': 'Hard',
'config': {
'name': 'Hard',
'num_cpus': 8,
'num_processes_at_startup': 28,
'num_ram_rows': 6,
Expand All @@ -32,8 +32,8 @@
}

_harder_difficulty = {
'name': 'Harder',
'config': {
'name': 'Harder',
'num_cpus': 12,
'num_processes_at_startup': 35,
'num_ram_rows': 6,
Expand All @@ -43,8 +43,8 @@
}

_insane_difficulty = {
'name': 'Insane',
'config': {
'name': 'Insane',
'num_cpus': 16,
'num_processes_at_startup': 42,
'num_ram_rows': 4,
Expand All @@ -62,7 +62,7 @@
]

difficulty_levels_map = {
l['name'].lower(): l
l['config']['name'].lower(): l
for l in difficulty_levels
}

Expand Down
1 change: 1 addition & 0 deletions src/game_objects/custom_settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, start_fn, cancel_fn, default_config=None):
@property
def config(self):
config = {
'name': 'Custom',
'num_cpus': int(
self._num_cpus_selector.selected_option),
'num_processes_at_startup': int(
Expand Down
3 changes: 2 additions & 1 deletion src/game_objects/game_over_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

class GameOverDialog(GameObject):
# pylint: disable=too-many-arguments
def __init__(self, uptime, score, restart_game_fn, main_menu_fn, standalone=False):
def __init__(self, uptime, difficulty, score, restart_game_fn, main_menu_fn, standalone=False):
self.uptime = uptime
self.score = score
self.difficulty = difficulty
self.standalone = standalone
super().__init__(GameOverDialogView(self))

Expand Down
11 changes: 11 additions & 0 deletions src/game_objects/views/game_over_dialog_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __init__(self, game_over_dialog):
'YOU GOT REBOOTED!', False, Color.WHITE)
self._uptime_text_surface = FONT_PRIMARY_LARGE.render(
'UPTIME: ' + game_over_dialog.uptime, False, Color.WHITE)
self._difficulty_text_surface = FONT_PRIMARY_LARGE.render(
'DIFFICULTY: ' + game_over_dialog.difficulty, False, Color.WHITE)
self._score_text_surface = FONT_PRIMARY_LARGE.render(
'SCORE: ' + str(game_over_dialog.score), False, Color.WHITE)

Expand Down Expand Up @@ -58,6 +60,15 @@ def draw(self, surface):
self._main_text_surface.get_height() +
self._image.get_height() +
80))
surface.blit(
self._difficulty_text_surface,
(self.width -
self.x / 2 +
80, # Absolute weird way to measure middle, oops :p
nonepork marked this conversation as resolved.
Show resolved Hide resolved
self.y +
self._main_text_surface.get_height() +
self._image.get_height() +
80))
surface.blit(
self._score_text_surface,
(self.x +
Expand Down
1 change: 1 addition & 0 deletions src/scenes/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def update(self, current_time, events):
if self._game_over_dialog is None:
self._game_over_dialog = GameOverDialog(
self._uptime_manager.uptime_text,
self._config['name'],
self._score_manager.score,
self.setup,
self._return_to_main_menu,
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setup(self):
self._scene_objects.append(difficulty_selection_label)

difficulty_level_names = list(
map(lambda difficulty_level: difficulty_level['name'], difficulty_levels))
map(lambda difficulty_level: difficulty_level['config']['name'], difficulty_levels))
difficulty_level_names.append('Custom')
self._difficulty_selector = OptionSelector(difficulty_level_names, 1)
self._difficulty_selector.view.set_xy(
Expand Down