Exemplo n.º 1
0
    void IFlipEffect.OnFlip(bool flippedFaceUp, System.Action callback)
    {
        if (flippedFaceUp)
        {
            MasqueradePlayer owner = Card.LastOwner;


            List <byte> allCards = new List <byte>();
            foreach (MasqueradePlayer p in Card.Networking.MasqueradePlayers)
            {
                allCards.AddRange(p.Hand.CardsOwned);
            }

            for (int i = 0; i < allCards.Count; i++)
            {
                Card c = Card.Networking.TheCardIndex.GetCard(allCards[i]);
                if (!c.IsFaceUp && c.CardClass == CardClass.ASSASSIN)
                {
                    Card.Networking.GiveControl(Card.LastOwner.PlayerIndex, allCards[i]);
                }
            }
        }
        if (callback != null)
        {
            callback();
        }
    }
Exemplo n.º 2
0
    IEnumerator triggerCOR(System.Action callback)
    {
        MasqueradePlayer owner = Card.LastOwner;

        if (Card.IsAlive)
        {
            Card.Kill();
        }


        List <byte> allCards = new List <byte>();

        foreach (MasqueradePlayer p in Card.Networking.MasqueradePlayers)
        {
            allCards.AddRange(p.Hand.CardsOwned);
        }

        for (int i = 0; i < allCards.Count; i++)
        {
            //If we had flip-down triggers, this would not stack them properly. We do not.
            bool flipDone = false;

            Card.StartCoroutine(Card.Networking.TheCardIndex.GetCard(allCards[i]).Flip(false, ((a) => flipDone = true)));
            while (!flipDone)
            {
                yield return(null);
            }
        }

        List <byte> shuffledCards = new List <byte>();


        while (allCards.Count > 0)
        {
            int randomIndex = Random.Range(0, allCards.Count);
            shuffledCards.Add(allCards[randomIndex]);
            allCards.RemoveAt(randomIndex);
        }

        byte dealIndex = owner.PlayerIndex;

        for (int i = 0; i < shuffledCards.Count; i++)
        {
            Card.Networking.GiveControl(dealIndex, shuffledCards[i]);
            dealIndex++;
            if (dealIndex >= Card.Networking.MasqueradePlayers.Count)
            {
                dealIndex = 0;
            }
        }

        if (callback != null)
        {
            callback();
        }
    }
Exemplo n.º 3
0
 void IStartPhase.OnStartPhase(MasqueradePlayer turn, System.Action callback)
 {
     if (Card.IsAlive && Card.IsFaceUp && turn == Card.Owner)
     {
         Card.StartCoroutine(triggerCOR(callback));
     }
     else
     {
         callback();
     }
 }
Exemplo n.º 4
0
 void IStartPhase.OnStartPhase(MasqueradePlayer currentPlayer, System.Action callback)
 {
     if (currentPlayer == Card.Owner && Card.IsFaceUp && Card.IsAlive)
     {
         Card.Networking.StartCoroutine(Card.Networking.DrawCardCOR(currentPlayer.PlayerIndex, 1, delegate
         {
             callback();
         }));
         CustomConsole.Log("It's his owner's start phase, and Sir Olaf the Glutton is drawing a card.", UnityEngine.Color.green);
     }
     callback();
 }
Exemplo n.º 5
0
 public void OnStartPhase(MasqueradePlayer turn, Action callback)
 {
     if (turn == Card.LastOwner)
     {
         Card.AddBuff(2, 0, false, true, this);
     }
     else
     {
         Card.AddBuff(0, 2, false, true, this);
     }
     callback();
 }
Exemplo n.º 6
0
 void IEndPhase.OnEndPhase(MasqueradePlayer turn, System.Action callback)
 {
     if (Card.IsFaceUp)
     {
         int cardsToDraw = 3 - turn.Hand.CardsOwned.Count;
         if (cardsToDraw > 0)
         {
             Networking.DrawCardFacing(turn.PlayerIndex, cardsToDraw, true);
         }
         callback();
     }
     else
     {
         callback();
     }
 }
Exemplo n.º 7
0
    void IFlipEffect.OnFlip(bool flippedFaceUp, System.Action callback)
    {
        if (flippedFaceUp)
        {
            MasqueradePlayer owner = Card.LastOwner;


            foreach (Card c in Networking.GetCardsInPlay())
            {
                if (c.IsFaceUp && c.CardClass == CardClass.SOLDIER && c.Owner != owner)
                {
                    Card.Networking.GiveControl(owner.PlayerIndex, (byte)c.Index);
                }
            }
        }
        if (callback != null)
        {
            callback();
        }
    }
Exemplo n.º 8
0
    void IEndPhase.OnEndPhase(MasqueradePlayer turn, System.Action callback)
    {
        if (Card.Networking.TheDeck.CardsRemaining == 0)
        {
            CustomConsole.LogNetworked("The deck has run out of cards. " + Card.Owner.Identity.Name + " controls the King! They win!", UnityEngine.Color.yellow);
            Card.Networking.EndGame(Card.Owner);
        }

        if (Card.IsFaceUp)
        {
            foreach (byte b in Card.Owner.Hand.CardsOwned)
            {
                Card c = Card.Networking.TheCardIndex.GetCard(b);

                if (c.CardClass == CardClass.QUEEN && c.IsFaceUp)
                {
                    CustomConsole.LogNetworked(Card.Owner.Identity.Name + " controls the King and Queen! They win!", UnityEngine.Color.yellow);
                    Card.Networking.EndGame(Card.Owner);
                }
            }
        }
        callback();
    }
Exemplo n.º 9
0
 public override bool TriggerIsPlausible(MasqueradePlayer currentPlayer)
 {
     return(currentPlayer == Card.Owner && Card.IsFaceUp && Card.IsAlive);
 }
Exemplo n.º 10
0
    IEnumerator triggerCOR(Card defender, System.Action callback)
    {
        //For each player in apnap order
        MasqueradePlayer currentPlayer = Networking.CurrentPlayer;

        for (int i = 0; i < Networking.MasqueradePlayers.Count; i++)
        {
            bool currentPlayerIsActive = currentPlayer == Networking.CurrentPlayer;

            if (!currentPlayerIsActive)
            {
                //Start Subtimer
                Timer.StartSubTimer(15, () => { });
            }
            List <byte> targets = new List <byte>();
            targets.AddRange(currentPlayer.Hand.CardsThatCanBeDiscarded);

            bool choiceMade = false;
            Card.StartCoroutine(Networking.PickACardCOR(currentPlayer.PlayerIndex, targets.ToArray(),
                                                        (choice) =>
            {
                if (targets.Contains(choice))
                {
                    //Discard it
                    Card foundCard = Networking.TheCardIndex.GetCard(choice);

                    foundCard.StartCoroutine(foundCard.Flip(true,
                                                            (b) =>
                    {
                        choiceMade = true;
                        foundCard.Kill();
                    }));
                }
                else
                {
                    //If we failed the sanity check choose at random;
                    int randomChoice = Random.Range(0, targets.Count);
                    Card foundCard   = Networking.TheCardIndex.GetCard(targets[randomChoice]);

                    foundCard.StartCoroutine(foundCard.Flip(true,
                                                            (b) =>
                    {
                        choiceMade = true;
                        foundCard.Kill();
                    }));
                }
            },
                                                        null,
                                                        new Color(0, .5f, .6f),
                                                        currentPlayerIsActive
                                                        ));

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

            //Get rid of whatever timers we have
            if (currentPlayerIsActive)
            {
                Timer.PauseMainTimer();
            }
            else
            {
                Timer.CancelSubTimer();
            }

            currentPlayer = Networking.NextPlayer(currentPlayer);
        }



        Timer.ResumeMainTimer();

        callback();
    }
Exemplo n.º 11
0
 public virtual bool TriggerIsPlausible(MasqueradePlayer currentPlayer)
 {
     return(true);
 }
Exemplo n.º 12
0
    void IStartPhase.OnStartPhase(MasqueradePlayer currentPlayer, System.Action callback)
    {
        if (currentPlayer == Card.Owner && Card.IsFaceUp && Card.IsAlive)
        {
            if (!Card.HasBuff(buff))
            {
                buff = Card.AddBuff(0, 0, true, true, this);
            }


            List <byte> targets = new List <byte>();

            foreach (byte b in Card.Owner.Hand.CardsOwned)
            {
                Card c = Card.Networking.TheCardIndex.GetCard(b);
                if (!c.HasKeyword(Keyword.CANT_BE_DISCARDED))
                {
                    targets.Add(b);
                }
            }
            Card.Networking.StartCoroutine(Card.Networking.PickACardCOR(
                                               Card.Owner.PlayerIndex,
                                               targets.ToArray(),
                                               delegate(byte choice)
            {
                if (targets.Contains(choice))
                {
                    //Kill the card and give Whitemane +5
                    buff.Attack  = 5;
                    buff.Defense = 5;

                    Card.Networking.SyncCard(Card);


                    Card foundCard = Networking.TheCardIndex.GetCard(choice);

                    foundCard.StartCoroutine(foundCard.Flip(true,
                                                            (b) =>
                    {
                        foundCard.Kill();
                        callback();
                    }));
                }
                else
                {
                    //If somebody failed the sanity check they're probably cheating
                    //The most reasonable thing to do is still just cancel


                    buff.Attack  = 0;
                    buff.Defense = 0;
                    Card.Networking.SyncCard(Card);
                    callback();
                }
            },
                                               delegate
            {
                //Don't kill anybody

                buff.Attack  = 0;
                buff.Defense = 0;

                Card.Networking.SyncCard(Card);

                callback();
            },
                                               new Color(0, .5f, 0)
                                               ));

            CustomConsole.Log("It's his owner's start phase, and Sorceror Theodoric Whitemane is choosing someone to sacrifice.", UnityEngine.Color.green);
        }
    }