// Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs
using UnityEngine;
using TD.Core;
using TD.Gameplay.BuilderSpells;
namespace TD.Gameplay.Draft
{
///
/// Draft choice — "upgrade a builder spell you already have". Replaces
/// with in the player's
/// , in place — the upgraded spell keeps the same hotkey
/// slot the base spell occupied.
///
///
/// Mirrors , but swaps rather than adds (so it doesn't
/// consume a slot). Only offered while the player currently has
/// granted — once taken, is removed, which automatically makes this
/// option (and any sibling upgrade branching off the same base) invalid for future drafts.
///
[CreateAssetMenu(fileName = "BuilderSpellUpgradeOption",
menuName = "TD/Draft/Builder Spell Upgrade Option")]
public class BuilderSpellUpgradeDraftOption : DraftOption
{
[Header("Payload")]
[Tooltip("The builder spell this option upgrades from.")]
public BuilderSpellKind BaseKind;
[Tooltip("The builder spell this option upgrades to.")]
public BuilderSpellKind UpgradedKind;
public override bool IsValidFor(ulong clientId)
{
var loadout = PlayerSpellLoadout.GetForClient(clientId);
return loadout != null && loadout.PlayerHasSpell(BaseKind);
}
public override bool ServerApply(ulong clientId)
{
var loadout = PlayerSpellLoadout.GetForClient(clientId);
return loadout != null && loadout.ServerUpgradeSpell(BaseKind, UpgradedKind);
}
/// Inherits the upgraded spell's icon (resolved from the pool by
/// ) unless this option assigns an override.
public override Sprite ResolveIcon()
{
if (Icon != null) return Icon;
var def = BuilderSpellPool.Instance != null ? BuilderSpellPool.Instance.Get(UpgradedKind) : null;
return def != null ? def.Icon : null;
}
}
}