UnityTowerDefense/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs

41 lines
1.7 KiB
C#

// Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs
using UnityEngine;
using TD.Core;
using TD.Gameplay.BuilderSpells;
namespace TD.Gameplay.Draft
{
/// <summary>
/// Draft choice — "gain a builder spell". Grants the player a key-triggered active ability,
/// adding it to their <see cref="PlayerSpellLoadout"/>.
/// </summary>
/// <remarks>
/// Mirrors <see cref="BuilderEffectDraftOption"/>: carries the <see cref="BuilderSpellKind"/>
/// directly rather than an asset reference, since the enum value is the stable identifier
/// <see cref="PlayerSpellLoadout"/> and <see cref="BuilderSpellPool"/> already key off of.
/// <see cref="IsValidFor"/> also checks slot capacity — once
/// <see cref="PlayerSpellLoadout.MaxSpellSlots"/> is reached, no further spell options are
/// offered.
/// </remarks>
[CreateAssetMenu(fileName = "BuilderSpellOption", menuName = "TD/Draft/Builder Spell Option")]
public class BuilderSpellDraftOption : DraftOption
{
[Header("Payload")]
[Tooltip("The builder spell this option grants.")]
public BuilderSpellKind Kind;
public override bool IsValidFor(ulong clientId)
{
var loadout = PlayerSpellLoadout.GetForClient(clientId);
if (loadout == null) return false;
if (loadout.SlotCount >= PlayerSpellLoadout.MaxSpellSlots) return false;
return !loadout.PlayerHasSpell(Kind);
}
public override bool ServerApply(ulong clientId)
{
var loadout = PlayerSpellLoadout.GetForClient(clientId);
return loadout != null && loadout.ServerGrantSpell(Kind);
}
}
}