start of draft option upgrades
This commit is contained in:
parent
e78ae0cda1
commit
db9c828e63
7 changed files with 235 additions and 2 deletions
|
|
@ -20,8 +20,9 @@ namespace TD.Gameplay
|
|||
/// same constraint on a struct); <c>byte</c> already does, for free.</para>
|
||||
///
|
||||
/// <para><b>Granted via draft.</b> <see cref="TD.Gameplay.Draft.BuilderEffectDraftOption"/>
|
||||
/// calls <see cref="ServerGrantEffect"/> when a player picks it. Effects are permanent for
|
||||
/// the match — there is no revoke.</para>
|
||||
/// calls <see cref="ServerGrantEffect"/> when a player picks it. Effects are otherwise
|
||||
/// permanent for the match — the only way one leaves the granted set is
|
||||
/// <see cref="ServerUpgradeEffect"/> swapping it for its upgraded replacement.</para>
|
||||
///
|
||||
/// <para><b>Query, don't snapshot.</b> Consumers (e.g. <see cref="WaveManager"/> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue