Skip to content

Commit

Permalink
Fenn Rau (Rebel, Fang Fighter) - finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandrem committed Sep 10, 2021
1 parent a89ccc5 commit 6f6dbff
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using Ship;
using SubPhases;
using System;
using System.Collections.Generic;
using System.Linq;
using Upgrade;

namespace Ship
Expand All @@ -10,8 +13,6 @@ public class FennRauRebel : FangFighter
{
public FennRauRebel() : base()
{
IsWIP = true;

RequiredMods = new List<Type>() { typeof(Mods.ModsList.UnreleasedContentMod) };

PilotInfo = new PilotCardInfo
Expand Down Expand Up @@ -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<FennRauRebelRemoveRedTokenAbilityDecisionSubPhase>(
"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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public virtual void PrepareCustomDecisions()

public class RemoveRedTokenDecisionSubPhase : DecisionSubPhase
{
public bool RemoveOnlyNonLocks = false;

public override void PrepareDecision(Action callBack)
{
Dictionary<string, GenericToken> tokens = new Dictionary<string, GenericToken>();

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 + "\"";
Expand All @@ -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();
Expand Down

0 comments on commit 6f6dbff

Please sign in to comment.