Пример #1
0
        public void CallOnRemoveTokenEvent(GenericToken token)
        {
            TokensChangePanel.CreateTokensChangePanel(this, token, isAssigned: false);

            OnTokenIsRemoved?.Invoke(this, token.GetType());
            OnTokenIsRemovedGlobal?.Invoke(this, token.GetType());
        }
Пример #2
0
        public void RemoveToken(GenericToken tokenToRemove, Action callback)
        {
            if (Host.CanRemoveToken(tokenToRemove))
            {
                AssignedTokens.Remove(tokenToRemove);

                if (tokenToRemove.GetType().BaseType == typeof(GenericTargetLockToken))
                {
                    ITargetLockable otherTokenOwner = (tokenToRemove as GenericTargetLockToken).OtherTargetLockTokenOwner;
                    ActionsHolder.ReleaseTargetLockLetter((tokenToRemove as GenericTargetLockToken).Letter);
                    Type oppositeType = (tokenToRemove.GetType() == typeof(BlueTargetLockToken)) ? typeof(RedTargetLockToken) : typeof(BlueTargetLockToken);

                    char         letter = (tokenToRemove as GenericTargetLockToken).Letter;
                    GenericToken otherTargetLockToken = otherTokenOwner.GetAnotherToken(oppositeType, letter);
                    if (otherTargetLockToken != null)
                    {
                        otherTokenOwner.RemoveToken(otherTargetLockToken);
                        if (otherTokenOwner is GenericShip)
                        {
                            (otherTokenOwner as GenericShip).CallOnRemoveTokenEvent(otherTargetLockToken);
                        }
                    }
                }

                tokenToRemove.WhenRemoved();
                Host.CallOnRemoveTokenEvent(tokenToRemove);
            }
            Triggers.ResolveTriggers(TriggerTypes.OnTokenIsRemoved, callback);
        }
Пример #3
0
    public static void ReassignToken(GenericToken tokenToReassign, GenericShip fromShip, GenericShip toShip, Action callBack)
    {
        List <Type> simpleTokens = new List <Type>()
        {
            typeof(FocusToken), typeof(EvadeToken)
        };

        if (simpleTokens.Contains(tokenToReassign.GetType()))
        {
            GenericToken tokenToAssign = (GenericToken)Activator.CreateInstance(tokenToReassign.GetType(), new [] { toShip });
            fromShip.Tokens.RemoveToken(
                tokenToReassign.GetType(),
                delegate {
                toShip.Tokens.AssignToken(tokenToAssign, callBack);
            });
        }
        else
        {
            ReassignTargetLockToken(
                (tokenToReassign as GenericTargetLockToken).Letter,
                fromShip,
                toShip,
                callBack
                );
        }
    }
Пример #4
0
        private void RemoveToken(GenericToken token)
        {
            Selection.ActiveShip.RemoveToken(token.GetType(), (token.GetType() == typeof(BlueTargetLockToken)) ? (token as BlueTargetLockToken).Letter : ' ');
            Selection.ActiveShip.RemoveToken(typeof(JamToken));

            Phases.FinishSubPhase(this.GetType());
            CallBack();
        }
Пример #5
0
        public void CallOnTokenIsAssigned(GenericToken token, Action callback)
        {
            TokensChangePanel.CreateTokensChangePanel(this, token, isAssigned: true);

            OnTokenIsAssigned?.Invoke(this, token.GetType());
            OnTokenIsAssignedGlobal?.Invoke(this, token.GetType());

            Tokens.TokenToAssign = null;

            Triggers.ResolveTriggers(TriggerTypes.OnTokenIsAssigned, callback);
        }
Пример #6
0
        // TOKENS

        public void CallBeforeAssignToken(GenericToken token, Action callback)
        {
            if (BeforeTokenIsAssigned != null)
            {
                BeforeTokenIsAssigned(this, token.GetType());
            }
            if (BeforeTokenIsAssignedGlobal != null)
            {
                BeforeTokenIsAssignedGlobal(this, token.GetType());
            }

            Triggers.ResolveTriggers(TriggerTypes.OnBeforeTokenIsAssigned, callback);
        }
Пример #7
0
        private void CheckAbility(GenericShip ship, GenericToken token)
        {
            if (Phases.CurrentPhase.GetType() != typeof(MainPhases.ActivationPhase) &&
                Phases.CurrentPhase.GetType() != typeof(MainPhases.CombatPhase)
                )
            {
                return;
            }

            if (token.GetType() != typeof(StressToken))
            {
                return;
            }

            if (HostShip.State.Charges == 0)
            {
                return;
            }

            if (HostShip.ShipId != ship.ShipId && //a ship is never in its own arc
                HostShip.SectorsInfo.IsShipInSector(ship, ArcType.Front) &&
                HostShip.SectorsInfo.RangeToShipBySector(ship, ArcType.Front) <= 2)
            {
                ShipWithStressToken = ship;
                RegisterAbilityTrigger(TriggerTypes.OnTokenIsAssigned, ShowDecision);
            }
        }
Пример #8
0
 public void RemoveCondition(GenericToken token)
 {
     if (AssignedTokens.Remove(token))
     {
         Host.CallOnConditionIsRemoved(token.GetType());
     }
 }
Пример #9
0
        public void CallOnTokenIsAssigned(GenericToken token, Action callback)
        {
            if (OnTokenIsAssigned != null)
            {
                OnTokenIsAssigned(this, token.GetType());
            }

            if (OnTokenIsAssignedGlobal != null)
            {
                OnTokenIsAssignedGlobal(this, token.GetType());
            }

            Tokens.TokenToAssign = null;

            Triggers.ResolveTriggers(TriggerTypes.OnTokenIsAssigned, callback);
        }
Пример #10
0
        public void AssignCondition(GenericToken token)
        {
            AssignedTokens.Add(token);

            token.WhenAssigned();
            Host.CallOnConditionIsAssigned(token.GetType());
        }
Пример #11
0
        private void PassToken(GenericToken tokenToPass)
        {
            var target        = tokenToPass.Host;
            var tokenToRemove = HostShip.Tokens.GetToken(tokenToPass.GetType());

            HostShip.Tokens.RemoveToken(tokenToRemove, () => target.Tokens.AssignToken(tokenToPass, DecisionSubPhase.ConfirmDecision));
        }
Пример #12
0
        private void CheckAbility(GenericShip ship, GenericToken token)
        {
            if (HostShip.State.Charges < 3)
            {
                return;
            }

            if (ship.Owner.PlayerNo == HostShip.Owner.PlayerNo)
            {
                return;
            }

            if (token.GetType() != typeof(IonToken))
            {
                return;
            }

            DistanceInfo distInfo = new DistanceInfo(HostShip, ship);

            if (distInfo.Range < 4)
            {
                IonizedShip = ship;
                RegisterAbilityTrigger(TriggerTypes.OnTokenIsAssigned, AskDaceBonearmAbility);
            }
        }
Пример #13
0
        private void UseAbility(object sender, System.EventArgs e)
        {
            DecisionSubPhase.ConfirmDecisionNoCallback();

            HostShip.Tokens.AssignToken(
                typeof(StressToken), delegate { AssignExtraToken(Token.GetType()); }
                );
        }
Пример #14
0
            public override void ActionEffect(System.Action callBack)
            {
                Combat.CurrentDiceRoll.ApplyEvade();

                GenericToken reinforceToken = (Host.Tokens.HasToken(typeof(ReinforceForeToken))) ? Host.Tokens.GetToken(typeof(ReinforceForeToken)) : Host.Tokens.GetToken(typeof(ReinforceAftToken));

                Host.Tokens.SpendToken(reinforceToken.GetType(), callBack);
            }
Пример #15
0
 private void PayCost(GenericToken token)
 {
     Combat.Attacker.Tokens.SpendToken(
         token.GetType(),
         ConfirmDecision,
         (token as BlueTargetLockToken != null) ? (token as BlueTargetLockToken).Letter : ' '
         );
 }
Пример #16
0
        public override bool IsTokenCanBeDiscardedByJam(GenericToken token)
        {
            List <Type> tokensTypesToDiscard = new List <Type> {
                typeof(FocusToken), typeof(EvadeToken), typeof(BlueTargetLockToken)
            };

            return(tokensTypesToDiscard.Contains(token.GetType()));
        }
Пример #17
0
        public void AssignCondition(Type tokenType)
        {
            GenericToken token = (GenericToken)Activator.CreateInstance(tokenType, Host);

            AssignedTokens.Add(token);

            token.WhenAssigned();
            Host.CallOnConditionIsAssigned(token.GetType());
        }
Пример #18
0
 private void KeepReinforce(GenericShip ship, GenericToken token, ref bool remove)
 {
     if (token.GetType() == TokenToKeep)
     {
         HostShip.BeforeRemovingTokenInEndPhase -= KeepReinforce;
         remove      = false;
         TokenToKeep = null;
     }
 }
Пример #19
0
        public void RemoveToken(GenericToken tokenToRemove, Action callback)
        {
            AssignedTokens.Remove(tokenToRemove);

            if (tokenToRemove.GetType().BaseType == typeof(GenericTargetLockToken))
            {
                GenericShip otherTokenOwner = (tokenToRemove as GenericTargetLockToken).OtherTokenOwner;
                Actions.ReleaseTargetLockLetter((tokenToRemove as GenericTargetLockToken).Letter);
                Type oppositeType = (tokenToRemove.GetType() == typeof(BlueTargetLockToken)) ? typeof(RedTargetLockToken) : typeof(BlueTargetLockToken);

                char         letter = (tokenToRemove as GenericTargetLockToken).Letter;
                GenericToken otherTargetLockToken = otherTokenOwner.Tokens.GetToken(oppositeType, letter);
                if (otherTargetLockToken != null)
                {
                    otherTokenOwner.Tokens.GetAllTokens().Remove(otherTargetLockToken);
                    otherTokenOwner.CallOnRemoveTokenEvent(otherTargetLockToken.GetType());
                }
            }

            Host.CallOnRemoveTokenEvent(tokenToRemove.GetType());

            Triggers.ResolveTriggers(TriggerTypes.OnTokenIsRemoved, callback);
        }
Пример #20
0
 private void PayCost(GenericToken token)
 {
     if (Weapon.SpendsTargetLockOnTargetToShoot || token is ForceToken)
     {
         Combat.Attacker.Tokens.SpendToken(
             token.GetType(),
             ConfirmDecision,
             (token as BlueTargetLockToken != null) ? (token as BlueTargetLockToken).Letter : ' '
             );
     }
     else
     {
         ConfirmDecision();
     }
 }
Пример #21
0
 private void CheckJam(GenericShip ship, GenericToken token)
 {
     if (token is JamToken)
     {
         if (ship.Tokens.HasGreenTokens || ship.Tokens.HasToken(typeof(BlueTargetLockToken), '*'))
         {
             RegisterJammedDecisionTrigger(ship);
         }
     }
     else
     {
         if (ship.Tokens.HasToken(typeof(JamToken)) && IsJammableToken(token.GetType()))
         {
             RegisterJammedDecisionTrigger(ship);
         }
     }
 }
Пример #22
0
        private void PettyOfficerThanissonEffect(GenericShip ship, GenericToken token)
        {
            TokenColors tokenColor = token.TokenColor;

            //During the Activation or Engagement Phase, after an enemy ship in your "arc standard
            //front" at range 0-1 gains a red or orange token, if you are not stressed, you may gain 1 stress
            //token. If you do, that ship gains 1 additional token of the type that it gained.
            if ((Phases.CurrentPhase is MainPhases.ActivationPhase || Phases.CurrentPhase is MainPhases.CombatPhase) &&
                (tokenColor == TokenColors.Red || tokenColor == TokenColors.Orange) &&
                token.GetType() != typeof(RedTargetLockToken) &&
                !HostShip.Tokens.HasToken(typeof(StressToken)) &&
                ship.Owner.PlayerNo != HostShip.Owner.PlayerNo &&
                HostShip.SectorsInfo.IsShipInSector(ship, ArcType.Front) &&
                HostShip.SectorsInfo.RangeToShipBySector(ship, ArcType.Front) <= 1)
            {
                ShipWithToken = ship;
                Token         = token;
                RegisterAbilityTrigger(TriggerTypes.OnTokenIsAssigned, ShowDecision);
            }
        }
Пример #23
0
        private void AssignToken(GenericToken token)
        {
            Selection.DeselectAnotherShip();
            DecisionSubPhase.ConfirmDecisionNoCallback();

            if (token == null)
            {
                Triggers.FinishTrigger();
            }
            else if (token is JamToken)
            {
                ReadyTokens.Remove(token);
                UpdateName();

                BombEffectTargetShip.Tokens.AssignToken(
                    new JamToken(BombEffectTargetShip, HostShip.Owner),
                    Triggers.FinishTrigger
                    );
            }
            else if (token is TractorBeamToken)
            {
                ReadyTokens.Remove(token);
                UpdateName();

                BombEffectTargetShip.Tokens.AssignToken(
                    new TractorBeamToken(BombEffectTargetShip, HostShip.Owner),
                    Triggers.FinishTrigger
                    );
            }
            else
            {
                ReadyTokens.Remove(token);
                UpdateName();

                BombEffectTargetShip.Tokens.AssignToken(
                    token.GetType(),
                    Triggers.FinishTrigger
                    );
            }
        }
Пример #24
0
        private void RegisterMultiSpectralCamouflageAbility(GenericShip ship, GenericToken token)
        {
            // Trigger only when a ship receives a BlueTargetLockToken
            if (token.GetType() != typeof(BlueTargetLockToken))
            {
                return;
            }

            BlueTargetLockToken assignedBlueLock = (BlueTargetLockToken)ship.Tokens.GetToken(typeof(BlueTargetLockToken), '*');

            TargetLockLetter = assignedBlueLock.Letter;

            // Make sure the targeted ship is the HostShip
            if (HostShip.Tokens.GetToken(typeof(RedTargetLockToken), TargetLockLetter) == null)
            {
                return;
            }

            // Make sure Host Ship only has one red target lock
            int redTargetLockCount = 0;

            foreach (GenericToken anotherToken in HostShip.Tokens.GetAllTokens())
            {
                if (anotherToken is RedTargetLockToken)
                {
                    redTargetLockCount += 1;
                }
            }

            TargetingShip = ship;

            if (redTargetLockCount == 1)
            {
                RegisterAbilityTrigger(TriggerTypes.OnTokenIsAssigned, AskToUseMultiSpectralCamouflageAbility);
            }
        }