start of draft option upgrades

This commit is contained in:
Ian Woods 2026-07-22 00:00:05 -07:00
parent e78ae0cda1
commit db9c828e63
7 changed files with 235 additions and 2 deletions

View file

@ -146,5 +146,30 @@ namespace TD.Gameplay
unlockedTypeIds.Add(towerTypeId);
return true;
}
/// <summary>
/// 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.
/// </summary>
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;
}
}
}