Beispiel #1
0
    private static void FinishAcquireTargetLock(GenericShip thisShip, GenericShip targetShip, Action callback)
    {
        BlueTargetLockToken tokenBlue = new BlueTargetLockToken(thisShip);
        RedTargetLockToken  tokenRed  = new RedTargetLockToken(targetShip);

        char letter = GetFreeTargetLockLetter();

        tokenBlue.Letter          = letter;
        tokenBlue.OtherTokenOwner = targetShip;

        tokenRed.Letter          = letter;
        tokenRed.OtherTokenOwner = thisShip;

        TakeTargetLockLetter(letter);

        targetShip.Tokens.AssignToken(
            tokenRed,
            delegate
        {
            thisShip.Tokens.AssignToken(tokenBlue, delegate
            {
                thisShip.CallOnTargetLockIsAcquiredEvent(targetShip, callback);
            });
        }
            );
    }
Beispiel #2
0
        private void UseZertikStromAbility()
        {
            BlueTargetLockToken tlock = HostShip.Tokens.GetToken(typeof(BlueTargetLockToken), '*') as BlueTargetLockToken;

            // Do we have a target lock?
            if (tlock != null)
            {
                GenericShip tlocked = tlock.OtherTokenOwner;

                if (!tlocked.Damage.HasFacedownCards)
                {
                    return;
                }

                Triggers.RegisterTrigger(
                    new Trigger()
                {
                    Name         = "Zertik Strom's Ability",
                    TriggerOwner = HostShip.Owner.PlayerNo,
                    TriggerType  = TriggerTypes.OnEndPhaseStart,
                    EventHandler = delegate
                    {
                        AskToUseAbility(AlwaysUseByDefault, RemoveTargetLock);
                    }
                }
                    );
            }
        }
Beispiel #3
0
        private void RemoveTargetLock(System.Object sender, EventArgs e)
        {
            BlueTargetLockToken tlock   = HostShip.Tokens.GetToken(typeof(BlueTargetLockToken), '*') as BlueTargetLockToken;
            GenericShip         tlocked = tlock.OtherTokenOwner;

            HostShip.Tokens.RemoveToken(tlock, delegate { tlocked.Damage.ExposeRandomFacedownCard(DecisionSubPhase.ConfirmDecision); });
        }
Beispiel #4
0
        public void RemoveTargetLocksOnDestruction(GenericShip ship)
        {
            while (true)
            {
                BlueTargetLockToken token = ship.GetToken(typeof(BlueTargetLockToken), '*') as BlueTargetLockToken;
                if (token != null)
                {
                    ship.RemoveToken(token.GetType(), token.Letter);
                }
                else
                {
                    break;
                }
            }

            while (true)
            {
                RedTargetLockToken token = ship.GetToken(typeof(RedTargetLockToken), '*') as RedTargetLockToken;
                if (token != null)
                {
                    ship.RemoveToken(token.GetType(), token.Letter);
                }
                else
                {
                    break;
                }
            }
        }
        private void AgreeToUseAbility(object sender, EventArgs e)
        {
            DecisionSubPhase.ConfirmDecisionNoCallback();

            BlueTargetLockToken lockToken  = HostShip.Tokens.GetToken <BlueTargetLockToken>('*');
            GenericShip         targetShip = lockToken.OtherTargetLockTokenOwner as GenericShip;

            HostShip.Tokens.RemoveToken(lockToken, delegate { SeeDial(targetShip); });
        }
Beispiel #6
0
        private void UseAbility(object sender, System.EventArgs e)
        {
            DecisionSubPhase.ConfirmDecisionNoCallback();

            IsAbilityUsed = true;

            BlueTargetLockToken existingToken    = HostShip.Tokens.GetToken <BlueTargetLockToken>('*');
            GenericShip         TargetLockTarget = existingToken.OtherTokenOwner;

            ActionsHolder.AcquireTargetLock(HostShip, TargetLockTarget, FinishAbility, FinishAbility);
        }
Beispiel #7
0
        private void SetTargetLockCanBeUsed(GenericShip ship)
        {
            BlueTargetLockToken ownTargetLockToken = (BlueTargetLockToken)Combat.Attacker.Tokens.GetToken(typeof(BlueTargetLockToken), targetLockLetter);

            if (ownTargetLockToken != null)
            {
                ownTargetLockToken.CanBeUsed = true;
            }

            Combat.Attacker.OnAttackFinish -= SetTargetLockCanBeUsed;
        }
Beispiel #8
0
        private GenericShip GetLockedShip()
        {
            GenericShip result = null;

            BlueTargetLockToken blueTargetLock = HostShip.Tokens.GetToken <BlueTargetLockToken>(letter: '*');

            if (blueTargetLock != null)
            {
                result = blueTargetLock.OtherTokenOwner;
            }

            return(result);
        }
Beispiel #9
0
        private void SetTargetLockCanBeUsed(GenericShip ship)
        {
            foreach (char targetLockLetter in targetLockLetters)
            {
                BlueTargetLockToken ownTargetLockToken = (BlueTargetLockToken)HostShip.Tokens.GetToken(typeof(BlueTargetLockToken), targetLockLetter);
                if (ownTargetLockToken != null)
                {
                    ownTargetLockToken.CanBeUsed = true;
                }
            }

            HostShip.OnAttackFinish -= SetTargetLockCanBeUsed;
        }
Beispiel #10
0
        private void CheckRemoveAbility(GenericShip ship, GenericToken token, ref bool data)
        {
            BlueTargetLockToken lockToken = token as BlueTargetLockToken;

            if (lockToken != null)
            {
                GenericObstacle lockedObstacle = lockToken.OtherTargetLockTokenOwner as GenericObstacle;
                if (lockedObstacle != null)
                {
                    if (HostShip.Tokens.GetTargetLockLetterPairsOn(lockedObstacle).Count == 1)
                    {
                        Messages.ShowInfo("Qi'Ra: You don't ignore obstacle anymore");
                        HostShip.IgnoreObstaclesList.Remove(lockedObstacle);
                    }
                }
            }
        }
Beispiel #11
0
        private void UseZertikStromAbility()
        {
            BlueTargetLockToken tlock = HostShip.Tokens.GetToken(typeof(BlueTargetLockToken), '*') as BlueTargetLockToken;

            // Do we have a target lock?
            if (tlock != null)
            {
                ITargetLockable tlocked = tlock.OtherTargetLockTokenOwner;

                if (tlocked is GenericShip)
                {
                    if (!(tlocked as GenericShip).Damage.HasFacedownCards)
                    {
                        return;
                    }

                    Triggers.RegisterTrigger(
                        new Trigger()
                    {
                        Name         = "Zertik Strom's Ability",
                        TriggerOwner = HostShip.Owner.PlayerNo,
                        TriggerType  = TriggerTypes.OnEndPhaseStart,
                        EventHandler = delegate
                        {
                            AskToUseAbility(
                                HostShip.PilotInfo.PilotName,
                                AlwaysUseByDefault,
                                RemoveTargetLock,
                                descriptionLong: "Do you want to spend a lock you have on an enemy ship to expose 1 of that ship's damage cards?",
                                imageHolder: HostShip
                                );
                        }
                    }
                        );
                }
            }
        }
        private void RegisterMultiSpectralCamouflageAbility(GenericShip ship, Type tokenType)
        {
            // Trigger only when a ship receives a BlueTargetLockToken
            if (tokenType != 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 token in HostShip.Tokens.GetAllTokens())
            {
                if (token is RedTargetLockToken)
                {
                    redTargetLockCount += 1;
                }
            }

            TargetingShip = ship;

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