diff --git a/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset b/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset
index 3439119..cb2746a 100644
--- a/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset
+++ b/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset
@@ -25,7 +25,7 @@ MonoBehaviour:
areaSound:
clip: {fileID: 8300000, guid: 038ff3eab9aa0034bac26ccb648ef2a1, type: 3}
volume: 0.632
- minPitch: 1.14
+ minPitch: 1.04
maxPitch: 0.96
SlowFactor: 0.5
EffectDuration: 8
diff --git a/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset
new file mode 100644
index 0000000..0465991
--- /dev/null
+++ b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset
@@ -0,0 +1,31 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 37cc60a4a6e53e24cb6d1c0be310868a, type: 3}
+ m_Name: SlowAreaUpgradedSpell
+ m_EditorClassIdentifier: Assembly-CSharp::TD.Gameplay.BuilderSpells.SlowAreaUpgradedSpellDefinition
+ DisplayName: Slow Area II
+ Description: Upgraded Slow Area. Slows for 50% longer.
+ Icon: {fileID: 0}
+ Cooldown: 10
+ TargetType: 1
+ Radius: 5
+ enemyLayerMask:
+ serializedVersion: 2
+ m_Bits: 1152
+ areaVfxPrefab: {fileID: 1462673130280185047, guid: bf2f1f2a9a54e9162b80673e3f7eeaf6, type: 3}
+ areaSound:
+ clip: {fileID: 8300000, guid: 038ff3eab9aa0034bac26ccb648ef2a1, type: 3}
+ volume: 0.632
+ minPitch: 1.04
+ maxPitch: 0.96
+ SlowFactor: 0.5
+ EffectDuration: 12
diff --git a/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset.meta b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset.meta
new file mode 100644
index 0000000..16266b6
--- /dev/null
+++ b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 364edf6abc3c31e33b53d0a01142b8ab
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset
new file mode 100644
index 0000000..743c46d
--- /dev/null
+++ b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset
@@ -0,0 +1,20 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 7b1c5b562f39c72eea3bafd0165af078, type: 3}
+ m_Name: Draft_BuilderSpellOption_SlowAreaUpgrade
+ m_EditorClassIdentifier: Assembly-CSharp::TD.Gameplay.Draft.BuilderSpellUpgradeDraftOption
+ DisplayName: Slow Area II
+ Description: Slows enemies in the area for 50% longer than the default slow area.
+ Icon: {fileID: 0}
+ Weight: 1
+ BaseKind: 1
+ UpgradedKind: 2
diff --git a/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset.meta b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset.meta
new file mode 100644
index 0000000..13ca9fd
--- /dev/null
+++ b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d180030b68a9a5e1da497bf6f83451d4
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/_Project/Scenes/Levels/9Player.unity b/Assets/_Project/Scenes/Levels/9Player.unity
index 684df64..9a4d028 100644
--- a/Assets/_Project/Scenes/Levels/9Player.unity
+++ b/Assets/_Project/Scenes/Levels/9Player.unity
@@ -13428,6 +13428,7 @@ MonoBehaviour:
spells:
- {fileID: 11400000, guid: 051c48f416e5366b59d49b0e062333ac, type: 2}
- {fileID: 11400000, guid: d893f46b037536b4ba91307e184cecfe, type: 2}
+ - {fileID: 11400000, guid: 364edf6abc3c31e33b53d0a01142b8ab, type: 2}
--- !u!4 &914832726
Transform:
m_ObjectHideFlags: 0
@@ -28786,6 +28787,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: 65ff25c1c8a89f7df8e88f71968c1c98, type: 2}
- {fileID: 11400000, guid: 5f390de69ba43b2a6a0d89cf09580320, type: 2}
- {fileID: 11400000, guid: 29b35841f7e5db454903798cb5d83434, type: 2}
+ - {fileID: 11400000, guid: d180030b68a9a5e1da497bf6f83451d4, type: 2}
--- !u!4 &2139601601
Transform:
m_ObjectHideFlags: 0
diff --git a/Assets/_Project/Scripts/Core/BuilderSpellKind.cs b/Assets/_Project/Scripts/Core/BuilderSpellKind.cs
index 58fcb5d..91c56e9 100644
--- a/Assets/_Project/Scripts/Core/BuilderSpellKind.cs
+++ b/Assets/_Project/Scripts/Core/BuilderSpellKind.cs
@@ -11,5 +11,6 @@ namespace TD.Core
{
Fireball = 0,
SlowArea = 1,
+ SlowAreaUpgraded = 2,
}
}
diff --git a/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs
new file mode 100644
index 0000000..dd339f7
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs
@@ -0,0 +1,21 @@
+// Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs
+
+using TD.Core;
+using UnityEngine;
+
+namespace TD.Gameplay.BuilderSpells
+{
+ ///
+ /// Draft upgrade for — identical behavior, just a
+ /// distinct so can replace the base spell
+ /// with this one in the player's loadout. All fields (SlowFactor, EffectDuration, etc.)
+ /// are inherited; author this asset with a longer EffectDuration than the base spell.
+ ///
+ [CreateAssetMenu(fileName = "SlowAreaUpgradedSpell",
+ menuName = "TD/Builder Spells/Slow Area (Upgraded)")]
+ public class SlowAreaUpgradedSpellDefinition : SlowAreaSpellDefinition
+ {
+ public override BuilderSpellKind Kind => BuilderSpellKind.SlowAreaUpgraded;
+ }
+}
diff --git a/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs.meta b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs.meta
new file mode 100644
index 0000000..af8991f
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 37cc60a4a6e53e24cb6d1c0be310868a
\ No newline at end of file
diff --git a/Assets/_Project/Scripts/Gameplay/BuilderUpgradeManager.cs b/Assets/_Project/Scripts/Gameplay/BuilderUpgradeManager.cs
index f11f9ec..6b81aea 100644
--- a/Assets/_Project/Scripts/Gameplay/BuilderUpgradeManager.cs
+++ b/Assets/_Project/Scripts/Gameplay/BuilderUpgradeManager.cs
@@ -20,8 +20,9 @@ namespace TD.Gameplay
/// same constraint on a struct); byte already does, for free.
///
/// Granted via draft.
- /// calls when a player picks it. Effects are permanent for
- /// the match — there is no revoke.
+ /// calls when a player picks it. Effects are otherwise
+ /// permanent for the match — the only way one leaves the granted set is
+ /// swapping it for its upgraded replacement.
///
/// Query, don't snapshot. Consumers (e.g. awarding
/// kill gold) query this manager live at the point of use rather than towers caching their
@@ -117,5 +118,24 @@ namespace TD.Gameplay
grantedKinds.Add(value);
return true;
}
+
+ ///
+ /// Server-only: replaces a previously granted effect with a different one (an upgrade
+ /// pick). No-op if the old effect isn't currently granted or the new one already is.
+ /// Returns true if the swap happened.
+ ///
+ public bool ServerUpgradeEffect(BuilderEffectKind oldKind, BuilderEffectKind newKind)
+ {
+ if (!IsServer) return false;
+
+ byte newValue = (byte)newKind;
+ if (grantedKinds.Contains(newValue)) return false;
+
+ byte oldValue = (byte)oldKind;
+ if (!grantedKinds.Remove(oldValue)) return false;
+
+ grantedKinds.Add(newValue);
+ return true;
+ }
}
}
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs b/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs
new file mode 100644
index 0000000..46022b5
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs
@@ -0,0 +1,42 @@
+// Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs
+using UnityEngine;
+using TD.Core;
+using TD.Gameplay.BuilderEffects;
+
+namespace TD.Gameplay.Draft
+{
+ ///
+ /// Draft choice — "upgrade a builder effect you already have". Replaces
+ /// with in the player's
+ /// .
+ ///
+ ///
+ /// Mirrors , but swaps rather than adds. 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 = "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);
+ }
+ }
+}
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs.meta b/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs.meta
new file mode 100644
index 0000000..393a4c1
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 717648113e8090fc6856744d898ab375
\ No newline at end of file
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs
index 7582ea2..360a566 100644
--- a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs
+++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs
@@ -15,7 +15,9 @@ namespace TD.Gameplay.Draft
/// and already key off of.
/// also checks slot capacity — once
/// is reached, no further spell options are
- /// offered.
+ /// offered. Gates on rather than
+ /// current possession, so a base spell already upgraded past (see
+ /// ) is never re-offered.
///
[CreateAssetMenu(fileName = "BuilderSpellOption", menuName = "TD/Draft/Builder Spell Option")]
public class BuilderSpellDraftOption : DraftOption
@@ -29,7 +31,7 @@ namespace TD.Gameplay.Draft
var loadout = PlayerSpellLoadout.GetForClient(clientId);
if (loadout == null) return false;
if (loadout.SlotCount >= PlayerSpellLoadout.MaxSpellSlots) return false;
- return !loadout.PlayerHasSpell(Kind);
+ return !loadout.PlayerHasEverGranted(Kind);
}
public override bool ServerApply(ulong clientId)
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs
new file mode 100644
index 0000000..a9d56bd
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs
@@ -0,0 +1,52 @@
+// 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;
+ }
+ }
+}
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs.meta b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs.meta
new file mode 100644
index 0000000..2d6304f
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 7b1c5b562f39c72eea3bafd0165af078
\ No newline at end of file
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs b/Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs
new file mode 100644
index 0000000..7746e3e
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs
@@ -0,0 +1,70 @@
+// Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs
+using UnityEngine;
+using TD.Towers;
+
+namespace TD.Gameplay.Draft
+{
+ ///
+ /// Draft choice — "upgrade a tower you already have". Replaces
+ /// with in the player's : every
+ /// tower of that type placed from now on is the upgraded version. Already-placed towers
+ /// are unaffected.
+ ///
+ ///
+ /// Mirrors , but swaps rather than adds. Only offered
+ /// while the player currently has unlocked — once taken,
+ /// is removed from the deck, which automatically makes this option
+ /// (and any sibling upgrade branching off the same base) invalid for future drafts.
+ ///
+ [CreateAssetMenu(fileName = "TowerUpgradeOption", menuName = "TD/Draft/Tower Upgrade Option")]
+ public class TowerUpgradeDraftOption : DraftOption
+ {
+ [Header("Payload")]
+ [Tooltip("The tower this option upgrades from. Must be present in the player's deck " +
+ "for this option to be offered.")]
+ public TowerDefinition BaseTower;
+
+ [Tooltip("The tower this option upgrades to. Must also be present in the " +
+ "TowerPlacementManager catalog (that's where its TowerTypeId comes from).")]
+ public TowerDefinition UpgradedTower;
+
+ public override bool IsValidFor(ulong clientId)
+ {
+ var deck = PlayerTowerDeck.GetForClient(clientId);
+ var pm = TowerPlacementManager.Instance;
+ if (deck == null || pm == null || BaseTower == null || UpgradedTower == null) return false;
+
+ if (!pm.TryGetTypeId(BaseTower, out int baseTypeId)) return false;
+
+ return deck.Contains(baseTypeId);
+ }
+
+ public override bool ServerApply(ulong clientId)
+ {
+ var deck = PlayerTowerDeck.GetForClient(clientId);
+ var pm = TowerPlacementManager.Instance;
+ if (deck == null || pm == null || BaseTower == null || UpgradedTower == null) return false;
+
+ if (!pm.TryGetTypeId(BaseTower, out int baseTypeId))
+ {
+ Debug.LogError($"[TowerUpgradeDraftOption] '{BaseTower.name}' is not in the tower " +
+ $"catalog; cannot apply. Add it to TowerPlacementManager.towerDefinitions.");
+ return false;
+ }
+
+ if (!pm.TryGetTypeId(UpgradedTower, out int upgradedTypeId))
+ {
+ Debug.LogError($"[TowerUpgradeDraftOption] '{UpgradedTower.name}' is not in the " +
+ $"tower catalog; cannot apply. Add it to " +
+ $"TowerPlacementManager.towerDefinitions.");
+ return false;
+ }
+
+ return deck.ServerUpgradeTower(baseTypeId, upgradedTypeId);
+ }
+
+ /// Inherits the upgraded tower's icon unless this option assigns an override.
+ public override Sprite ResolveIcon()
+ => Icon != null ? Icon : (UpgradedTower != null ? UpgradedTower.Icon : null);
+ }
+}
diff --git a/Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs.meta b/Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs.meta
new file mode 100644
index 0000000..a35a5d2
--- /dev/null
+++ b/Assets/_Project/Scripts/Gameplay/Draft/TowerUpgradeDraftOption.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: aeec22f152a57ef5798eae035c091543
\ No newline at end of file
diff --git a/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs b/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs
index ef994bb..4782e9f 100644
--- a/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs
+++ b/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs
@@ -60,6 +60,10 @@ namespace TD.Gameplay
private readonly NetworkList spells = new NetworkList();
+ // Every kind ever granted this match, including ones since upgraded away. Unlike
+ // `spells`, entries here are never removed — see PlayerHasEverGranted.
+ private readonly NetworkList everGrantedKinds = new NetworkList();
+
/// Fired on every peer when a spell is granted or a cooldown changes.
public event System.Action OnLoadoutChanged;
@@ -100,6 +104,14 @@ namespace TD.Gameplay
public BuilderSpellKind? GetKind(int slot)
=> (slot >= 0 && slot < spells.Count) ? spells[slot].Kind : (BuilderSpellKind?)null;
+ ///
+ /// True if this player has ever been granted the given spell this match, whether or
+ /// not it's still occupying a slot (e.g. it may have since been upgraded away). Used
+ /// by so a base spell already
+ /// upgraded past is never re-offered.
+ ///
+ public bool PlayerHasEverGranted(BuilderSpellKind kind) => everGrantedKinds.Contains((byte)kind);
+
/// True if is out of range, empty, or still cooling down.
public bool IsSlotOnCooldown(int slot)
{
@@ -136,9 +148,33 @@ namespace TD.Gameplay
if (PlayerHasSpell(kind)) return false;
spells.Add(SpellSlot.CreateReady(kind));
+ if (!everGrantedKinds.Contains((byte)kind)) everGrantedKinds.Add((byte)kind);
return true;
}
+ ///
+ /// Server-only: replaces a previously granted spell with a different one (an upgrade
+ /// pick), in place — the upgraded spell keeps the base spell's hotkey slot and starts
+ /// off cooldown. No-op if the old spell isn't currently granted or the new one already
+ /// is. Returns true if the swap happened.
+ ///
+ public bool ServerUpgradeSpell(BuilderSpellKind oldKind, BuilderSpellKind newKind)
+ {
+ if (!IsServer) return false;
+ if (PlayerHasSpell(newKind)) return false;
+
+ for (int i = 0; i < spells.Count; i++)
+ {
+ if (spells[i].Kind == oldKind)
+ {
+ spells[i] = SpellSlot.CreateReady(newKind);
+ if (!everGrantedKinds.Contains((byte)newKind)) everGrantedKinds.Add((byte)newKind);
+ return true;
+ }
+ }
+ return false;
+ }
+
// ----- Cast RPC -----------------------------------------------------
///
diff --git a/Assets/_Project/Scripts/Gameplay/PlayerTowerDeck.cs b/Assets/_Project/Scripts/Gameplay/PlayerTowerDeck.cs
index 356d459..9d7b54d 100644
--- a/Assets/_Project/Scripts/Gameplay/PlayerTowerDeck.cs
+++ b/Assets/_Project/Scripts/Gameplay/PlayerTowerDeck.cs
@@ -146,5 +146,30 @@ namespace TD.Gameplay
unlockedTypeIds.Add(towerTypeId);
return true;
}
+
+ ///
+ /// Server-only: replaces a previously unlocked tower type with a different one (an
+ /// upgrade pick) — every tower of that type placed from now on uses the new definition.
+ /// Already-placed towers keep whatever type they were placed with; this only changes
+ /// what's placeable going forward. No-op if the old type isn't currently unlocked or
+ /// the new one already is. Returns true if the swap happened.
+ ///
+ public bool ServerUpgradeTower(int oldTypeId, int newTypeId)
+ {
+ if (!IsServer) return false;
+ if (newTypeId <= 0) return false;
+ if (Contains(newTypeId)) return false;
+
+ for (int i = 0; i < unlockedTypeIds.Count; i++)
+ {
+ if (unlockedTypeIds[i] == oldTypeId)
+ {
+ unlockedTypeIds.RemoveAt(i);
+ unlockedTypeIds.Add(newTypeId);
+ return true;
+ }
+ }
+ return false;
+ }
}
}