Пример #1
0
    IEnumerator triggerCOR(System.Action callback)
    {
        List <byte> cardsInHand = new List <byte>();

        cardsInHand.AddRange(Card.Owner.Hand.CardsThatCanBeDiscarded);

        bool cancelled            = false;
        byte cardIndexToSac       = CardIndex.EMPTY_SLOT;
        byte cardIndexToReanimate = CardIndex.EMPTY_SLOT;


        Card.StartCoroutine(Networking.PickACardCOR(Card.Owner.PlayerIndex,
                                                    cardsInHand.ToArray(),
                                                    (choice) =>
        {
            if (cardsInHand.Contains(choice))
            {
                cardIndexToSac = choice;
            }
            else
            {
                cancelled = true;
            }
        },
                                                    () =>
        {
            cancelled = true;
            Networking.RefundAction();
            Card.IsTapped = false;
            Card.Sync();
        },
                                                    Color.green,
                                                    true));



        while (!cancelled && cardIndexToSac == CardIndex.EMPTY_SLOT)
        {
            yield return(null);
        }

        CustomConsole.Log("Anathema is past the sac. Cancelled = " + cancelled);


        if (!cancelled)
        {
            Card cardToSac = Networking.TheCardIndex.GetCard(cardIndexToSac);

            bool flipDone = false;

            cardToSac.StartCoroutine(cardToSac.Flip(true, (b) => flipDone = true));

            while (!flipDone)
            {
                yield return(null);
            }

            CustomConsole.Log("Anathema is past the flip. Cancelled = " + cancelled);

            cardToSac.Kill();


            List <byte> cardsInGraveyard = new List <byte>();
            cardsInGraveyard.AddRange(Networking.TheDiscardPile.Contents);
            cardsInGraveyard.Remove(cardIndexToSac);

            if (cardsInGraveyard.Count < 1)
            {
                cancelled = true;
            }
            else
            {
                Card.StartCoroutine(Networking.PickACardCOR(Card.Owner.PlayerIndex,
                                                            cardsInGraveyard.ToArray(),
                                                            (choice) =>
                {
                    if (cardsInGraveyard.Contains(choice))
                    {
                        cardIndexToReanimate = choice;
                    }
                    else
                    {
                        cancelled = true;
                    }
                },

                                                            () =>
                {
                    cancelled = true;
                },
                                                            Color.green,
                                                            true));

                while (!cancelled && cardIndexToReanimate == CardIndex.EMPTY_SLOT)
                {
                    yield return(null);
                }


                CustomConsole.Log("Anathema is past the reanimate choice. Cancelled = " + cancelled);
            }
        }


        if (!cancelled)
        {
            Networking.TheDiscardPile.RemoveIndex(cardIndexToReanimate);

            Networking.TheCardIndex.GetCard(cardIndexToReanimate).Owner = Card.Owner;

            Networking.TheCardIndex.GetCard(cardIndexToReanimate).IsAlive = true;

            bool facingPickedDone = false;
            Card.StartCoroutine(Networking.ChooseFacingCOR(cardIndexToReanimate, Card.Owner.PlayerIndex, (facingChoice) =>
            {
                facingPickedDone = true;
            },
                                                           true));
            while (!facingPickedDone)
            {
                yield return(null);
            }
        }


        callback();
    }
Пример #2
0
    IEnumerator triggerCOR(System.Action callback)
    {
        //Look at the to 2 cards
        List <byte> targets = Networking.TheDeck.TopCards(2);

        bool choiceMade = false;
        Card toGiveAway = null;
        Card toKeep     = null;

        System.Action cancel = () =>
        {
            choiceMade = true;
            //Otherwise, discard the top 2 cards
            foreach (byte b in targets)
            {
                Networking.TheDeck.PullCard(b);
                Networking.SendToDiscard(Networking.TheCardIndex.GetCard(b));
            }
        };

        foreach (byte b in targets)
        {
            Card c = Networking.TheCardIndex.GetCard(b);
            if (c.HasKeyword(Keyword.CANT_BE_DISCARDED))
            {
                cancel = null;
            }
        }



        Card.StartCoroutine(Networking.PickACardCOR(
                                Card.Owner.PlayerIndex,
                                targets.ToArray(),
                                (choice) =>
        {
            //You may choose 1 and give it to another player face-up

            Networking.TheDeck.PullCard(choice);
            toGiveAway = Networking.TheCardIndex.GetCard(choice);
            targets.Remove(choice);

            byte other = targets[0];

            Networking.TheDeck.PullCard(other);
            toKeep = Networking.TheCardIndex.GetCard(other);

            choiceMade = true;
        },
                                cancel,
                                Color.black,
                                true));

        while (!choiceMade)
        {
            yield return(null);
        }


        if (toGiveAway != null)
        {
            List <byte> playerTargets = new List <byte>();
            foreach (MasqueradePlayer m in Networking.MasqueradePlayers)
            {
                playerTargets.Add(m.Identity.Index);
            }
            playerTargets.Remove(Card.Owner.Identity.Index);
            bool playerChoiceMade = false;
            byte chosenPlayer     = 205;

            Card.StartCoroutine(Networking.PickAPlayerCOR(
                                    Card.Owner.PlayerIndex,
                                    playerTargets.ToArray(),
                                    (choice) =>
            {
                chosenPlayer     = choice;
                playerChoiceMade = true;
            },
                                    null,
                                    Color.black,
                                    true));

            while (!playerChoiceMade)
            {
                yield return(null);
            }


            toGiveAway.IsAlive  = true;
            toGiveAway.IsFaceUp = true;
            toGiveAway.Owner    = Networking.MasqueradePlayers[chosenPlayer];
            Networking.AddCardToBoards(chosenPlayer, (byte)toGiveAway.Index);

            toKeep.IsAlive = true;
            toKeep.Owner   = Card.Owner;
            bool facingPicked = false;
            Card.StartCoroutine(Networking.ChooseFacingCOR(
                                    (byte)toKeep.Index,
                                    Card.Owner.PlayerIndex,
                                    (choice) =>
            {
                facingPicked = true;
            }));

            while (!facingPicked)
            {
                yield return(null);
            }
        }



        callback();
    }