oh man i fixed that status effect bug

This commit is contained in:
2025-06-07 09:11:13 +10:00
parent c44a730b59
commit 400415f8a5
40 changed files with 648 additions and 270 deletions

View File

@ -1,14 +1,29 @@
extends Node
class_name WaveManager extends Object
## A collection of static functions related to enemy wave generation
##
## Contains the algorithm for generating a wave based on a given pool of enemies
## as well as the functions for determining how much powerful a given enemy wave
## should be based on the the number of players and what number wave it is.
##
## Also contains the function for determining how much money is earned after
## completing a wave
## Takes in wave number and number of players and returns a spawn power value
## intended for passing into the generate_wave method
static func calculate_spawn_power(wave_number: int, number_of_players: int) -> int:
return (20 * number_of_players) + (5 * wave_number)
## Takes in wave number and number of players and returns the amount of coins
## that should be divided between each player after completing the wave
static func calculate_pot(wave_number: int, number_of_players: int) -> int:
return ceili((2.5 * number_of_players) + (0.5 * wave_number))
## Uses a spawn power budget to "buy" cards of enemies at random selection from
## the given spawn pool, returns the resulting wave but also assigns the cards
## among the given set of enemy spawners
static func generate_wave(spawn_power: int, spawn_pool: Array[Enemy], spawners: Array[EnemySpawner]) -> Wave:
var wave: Wave = Wave.new()
@ -18,7 +33,7 @@ static func generate_wave(spawn_power: int, spawn_pool: Array[Enemy], spawners:
var new_card: EnemyCard = EnemyCard.new()
#First, choose an enemy at random
new_card.enemy = Data.enemies.pick_random()
new_card.enemy = spawn_pool.pick_random()
#Next, we have to figure out if we can actually buy that enemy
#and, if not, then we have to pick a different enemy, repeat until
@ -45,11 +60,11 @@ static func generate_wave(spawn_power: int, spawn_pool: Array[Enemy], spawners:
else:
#Even the common rarity was too expensive, so we have to choose
#a different enemy and try this process again
var enemy_id: int = Data.enemies.find(new_card.enemy)
var enemy_id: int = spawn_pool.find(new_card.enemy)
if enemy_id <= 0:
new_card.enemy = Data.enemies[Data.enemies.size() - 1]
new_card.enemy = spawn_pool[spawn_pool.size() - 1]
else:
new_card.enemy = Data.enemies[enemy_id - 1]
new_card.enemy = spawn_pool[enemy_id - 1]
#Now that we know which rarities we could afford, lets just choose a
#random one