Utility static class that assigns exactly one random spell to each of a Player's spell lists (offensive, defensive, healing, special). It clears existing lists and picks entries from hardcoded string arrays using System.Random.Shared.
using System;
using System.Collections.Generic;
using Keyboard_Warriors_.Models;
namespace Keyboard_Warriors_.Managers;
public static class SpellManager
{
/// <summary>
/// Generates and assigns exactly ONE random baseline spell into a target's spell collections for the match.
/// </summary>
public static void generateSpells( ref Player target )
{
if ( target == null ) return;
// 1. Clear existing listings so we start completely fresh
target.offensiveSpells.Clear();
target.defensiveSpells.Clear();
target.healingSpells.Clear();
target.specialSpells.Clear();
// 2. Define the available spell pools
string[] poolOffensive = { "Fireball", "Lightning", "Poison Bolt" };
string[] poolDefensive = { "Shield", "Barrier", "Reflect", "Magic Wall", "Fortify" };
string[] poolHealing = { "Heal", "Regen", "Cleanse", "Divine Light", "Recovery Pulse" };
string[] poolSpecial = { "System Overdrive", "EMP Blast", "Data Corruption" };
// 3. Roll and add exactly ONE random spell per list
// (Utilizes System.Random.Shared for clean execution)
target.offensiveSpells.Add( poolOffensive[Random.Shared.Next( poolOffensive.Length )] );
target.defensiveSpells.Add( poolDefensive[Random.Shared.Next( poolDefensive.Length )] );
target.healingSpells.Add( poolHealing[Random.Shared.Next( poolHealing.Length )] );
target.specialSpells.Add( poolSpecial[Random.Shared.Next( poolSpecial.Length )] );
}
}