42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
// Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs
|
|
using UnityEngine;
|
|
using TD.Core;
|
|
using TD.Gameplay.BuilderEffects;
|
|
|
|
namespace TD.Gameplay.Draft
|
|
{
|
|
/// <summary>
|
|
/// Draft choice — "upgrade a builder effect you already have". Replaces
|
|
/// <see cref="BaseKind"/> with <see cref="UpgradedKind"/> in the player's
|
|
/// <see cref="BuilderUpgradeManager"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Mirrors <see cref="BuilderEffectDraftOption"/>, but swaps rather than adds. Only offered
|
|
/// while the player currently has <see cref="BaseKind"/> granted — once taken,
|
|
/// <see cref="BaseKind"/> is removed, which automatically makes this option (and any sibling
|
|
/// upgrade branching off the same base) invalid for future drafts.
|
|
/// </remarks>
|
|
[CreateAssetMenu(fileName = "BuilderEffectUpgradeOption",
|
|
menuName = "TD/Draft/Builder Effect Upgrade Option")]
|
|
public class BuilderEffectUpgradeDraftOption : DraftOption
|
|
{
|
|
[Header("Payload")]
|
|
[Tooltip("The builder effect this option upgrades from.")]
|
|
public BuilderEffectKind BaseKind;
|
|
|
|
[Tooltip("The builder effect this option upgrades to.")]
|
|
public BuilderEffectKind UpgradedKind;
|
|
|
|
public override bool IsValidFor(ulong clientId)
|
|
{
|
|
var upgrades = BuilderUpgradeManager.GetForClient(clientId);
|
|
return upgrades != null && upgrades.PlayerHasEffect(BaseKind);
|
|
}
|
|
|
|
public override bool ServerApply(ulong clientId)
|
|
{
|
|
var upgrades = BuilderUpgradeManager.GetForClient(clientId);
|
|
return upgrades != null && upgrades.ServerUpgradeEffect(BaseKind, UpgradedKind);
|
|
}
|
|
}
|
|
}
|