diff --git a/Assets/Scripts/Model/Content/SecondEdition/Pilots/FangFighter/FennRauRebel.cs b/Assets/Scripts/Model/Content/SecondEdition/Pilots/FangFighter/FennRauRebel.cs index c1939139ad..5aaa4cb3eb 100644 --- a/Assets/Scripts/Model/Content/SecondEdition/Pilots/FangFighter/FennRauRebel.cs +++ b/Assets/Scripts/Model/Content/SecondEdition/Pilots/FangFighter/FennRauRebel.cs @@ -1,5 +1,8 @@ -using System; +using Ship; +using SubPhases; +using System; using System.Collections.Generic; +using System.Linq; using Upgrade; namespace Ship @@ -10,8 +13,6 @@ public class FennRauRebel : FangFighter { public FennRauRebel() : base() { - IsWIP = true; - RequiredMods = new List() { typeof(Mods.ModsList.UnreleasedContentMod) }; PilotInfo = new PilotCardInfo @@ -39,12 +40,58 @@ public class FennRauRebelFangAbility : GenericAbility { public override void ActivateAbility() { - + GenericShip.OnCombatActivationGlobal += CheckAbility; } public override void DeactivateAbility() { - + GenericShip.OnCombatActivationGlobal -= CheckAbility; + } + + private void CheckAbility(GenericShip ship) + { + if (Tools.IsSameTeam(HostShip, ship) + && BoardState.IsInRange(HostShip, ship, 1, 2) + && HasEnemyInFrontAtR1(ship)) + { + RegisterAbilityTrigger(TriggerTypes.OnCombatActivation, AskToRemoveRedNonLockToken); + } + } + + private bool HasEnemyInFrontAtR1(GenericShip ship) + { + foreach (GenericShip enemyShip in ship.Owner.EnemyShips.Values) + { + if (ship.SectorsInfo.RangeToShipBySector(enemyShip, Arcs.ArcType.Front) == 1) return true; + } + + return false; + } + + private void AskToRemoveRedNonLockToken(object sender, EventArgs e) + { + FennRauRebelRemoveRedTokenAbilityDecisionSubPhase subphase = Phases.StartTemporarySubPhaseNew( + "Fenn Rau: You may remove 1 non-lock red token", + Triggers.FinishTrigger + ); + subphase.ImageSource = HostShip; + subphase.AbilityHostShip = HostShip; + subphase.RemoveOnlyNonLocks = true; + subphase.Start(); + } + + private class FennRauRebelRemoveRedTokenAbilityDecisionSubPhase : RemoveRedTokenDecisionSubPhase + { + public GenericShip AbilityHostShip; + + public override void PrepareCustomDecisions() + { + DescriptionShort = AbilityHostShip.PilotInfo.PilotName; + DescriptionLong = "You may remove 1 non-lock red token"; + + DecisionOwner = Selection.ThisShip.Owner; + DefaultDecisionName = decisions.First().Name; + } } } } \ No newline at end of file diff --git a/Assets/Scripts/Model/Phases/SubPhases/Temporary/RemoveBadTokenDecisionSubPhase.cs b/Assets/Scripts/Model/Phases/SubPhases/Temporary/RemoveBadTokenDecisionSubPhase.cs index 19ad364e68..1bcbe43745 100644 --- a/Assets/Scripts/Model/Phases/SubPhases/Temporary/RemoveBadTokenDecisionSubPhase.cs +++ b/Assets/Scripts/Model/Phases/SubPhases/Temporary/RemoveBadTokenDecisionSubPhase.cs @@ -40,13 +40,15 @@ public virtual void PrepareCustomDecisions() public class RemoveRedTokenDecisionSubPhase : DecisionSubPhase { + public bool RemoveOnlyNonLocks = false; + public override void PrepareDecision(Action callBack) { Dictionary tokens = new Dictionary(); foreach (GenericToken token in Selection.ThisShip.Tokens.GetAllTokens()) { - if (token.TokenColor == TokenColors.Red) + if (token.TokenColor == TokenColors.Red && CanRemoveLockTokens(token)) { string tokenName = token.Name; if (token is RedTargetLockToken) tokenName += " \"" + (token as RedTargetLockToken).Letter + "\""; @@ -73,6 +75,11 @@ public override void PrepareDecision(Action callBack) callBack(); } + private bool CanRemoveLockTokens(GenericToken token) + { + return !RemoveOnlyNonLocks || !(token is RedTargetLockToken); + } + public virtual void DoCustomFinishDecision() { DecisionSubPhase.ConfirmDecision();