Skip to content

Commit

Permalink
Fix issue with game win event
Browse files Browse the repository at this point in the history
There was a problem where if player picked 80/120 waves, during last
\ wave the final boss would spawn but next wave timer could still
\ run until the final boss is killed (autospawn for example).
This resulted in start_next_wave() getting called when there are no
\ more waves, which caused a non-harmful error print from godot
\ but also caused _do_game_win() to fail to work properly
Remove started_next_wave check in _on_player_wave_spawned() - it's not
\ needed now that start_next_wave() checks for it
  • Loading branch information
Kvel2D committed Nov 20, 2024
1 parent de4e0ad commit 8272dc8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/player/team.gd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ func start_first_wave():


func start_next_wave():
var reached_last_wave: bool = _level == Globals.get_wave_count()
var game_is_neverending: bool = Globals.game_is_neverending()

if reached_last_wave && !game_is_neverending:
return

_level += 1
level_changed.emit()
_start_wave()
Expand Down Expand Up @@ -333,7 +339,6 @@ func _on_player_wave_spawned(level: int):
if wave_is_in_progress:
return

var started_last_wave: bool = level == Globals.get_wave_count()
var difficulty_is_extreme: bool = Globals.get_difficulty() == Difficulty.enm.EXTREME
var game_is_neverending: bool = Globals.game_is_neverending()
var bonus_waves_in_progress: bool = Utils.wave_is_bonus(level)
Expand All @@ -345,7 +350,7 @@ func _on_player_wave_spawned(level: int):
var autospawn_time_list: Array[float] = []
if autospawn_time_is_defined:
autospawn_time_list.append(_player_defined_autospawn_time)
if difficulty_is_extreme && !started_last_wave:
if difficulty_is_extreme:
autospawn_time_list.append(extreme_autospawn_time)
if game_is_neverending && bonus_waves_in_progress:
var bonus_wave_autospawn_time: float = _get_bonus_wave_autospawn_time(level)
Expand Down Expand Up @@ -374,7 +379,7 @@ func _on_player_wave_finished(level: int):
for player in _player_list:
if !player.current_wave_is_finished():
all_players_finished = false

var player_finished_last_level: bool = level == Utils.get_max_level()
var team_achieved_victory: bool = player_finished_last_level && all_players_finished

Expand Down

0 comments on commit 8272dc8

Please sign in to comment.