Пример #1
0
    void OnPerformDrawCards(object sender, object args)
    {
        var action       = args as DrawCardsAction;
        int deckCount    = action.player[Zones.Deck].Count;
        int fatigueCount = Mathf.Max(action.amount - deckCount, 0);

        for (int i = 0; i < fatigueCount; ++i)
        {
            var fatigueAction = new FatigueAction(action.player);
            container.AddReaction(fatigueAction);
        }
        int roomInHand = Player.maxHand - action.player[Zones.Hand].Count;
        int overDraw   = Mathf.Max((action.amount - fatigueCount) - roomInHand, 0);

        if (overDraw > 0)
        {
            var overDrawAction = new OverdrawAction(action.player, overDraw);
            container.AddReaction(overDrawAction);
        }
        int drawCount = action.amount - fatigueCount - overDraw;

        action.cards = action.player[Zones.Deck].Draw(drawCount);
        foreach (Card card in action.cards)
        {
            ChangeZone(card, Zones.Hand);
        }
    }
Пример #2
0
    //En robar cartas
    void OnPerformDrawCards(object sender, object args)
    {
        var action = args as DrawCardsAction;

        //Si el mazo tiene 0 cartas se aplica fatiga
        int deckCount    = action.player [Zones.Deck].Count;
        int fatigueCount = Mathf.Max(action.amount - deckCount, 0);

        for (int i = 0; i < fatigueCount; ++i)
        {
            var fatigueAction = new FatigueAction(action.player);
            container.AddReaction(fatigueAction);
        }

        //Si la mano no tiene espacio para mas cartas se queman las extra
        int roomInHand = Player.maxHand - action.player [Zones.Hand].Count;
        int overDraw   = Mathf.Max((action.amount - fatigueCount) - roomInHand, 0);

        if (overDraw > 0)
        {
            var overDrawAction = new OverdrawAction(action.player, overDraw);
            container.AddReaction(overDrawAction);
        }

        //Se cambia la zona de las cartas del mazo a la mano
        int drawCount = action.amount - fatigueCount - overDraw;

        action.cards = action.player [Zones.Deck].Draw(drawCount);
        foreach (Card card in action.cards)
        {
            ChangeZone(card, Zones.Hand);
        }
    }
Пример #3
0
        private void OnPerformDrawCards(object sender, object args)
        {
            var drawAction = args as DrawCardsAction;

            int deckCount    = drawAction.Player.Deck.Count;
            int fatigueCount = Mathf.Max(drawAction.Amount - deckCount, 0);

            for (int i = 0; i < fatigueCount; i++)
            {
                var fatigueAction = new FatigueAction(drawAction.Player);
                Container.AddReaction(fatigueAction);
            }

            int roomInHand = Player.MaxHand - drawAction.Player.Hand.Count;
            int overdraw   = Mathf.Max((drawAction.Amount - fatigueCount) - roomInHand, 0);

            if (overdraw > 0)
            {
                var overdrawAction = new OverdrawAction(drawAction.Player, overdraw);
                Container.AddReaction(overdrawAction);
            }

            int drawCount = drawAction.Amount - fatigueCount - overdraw;

            drawAction.Cards = drawAction.Player.Deck.Draw(drawCount);
            drawAction.Player.Hand.AddRange(drawAction.Cards);

            int[] cardIndices = new int[drawAction.Cards.Count];
            for (int i = 0; i < drawAction.Cards.Count; i++)
            {
                cardIndices[i] = drawAction.Cards[i].Id;
            }

            byte targetPlayerIndex = drawAction.Player.Index;
            var  raiseEventoptions = new Photon.Realtime.RaiseEventOptions {
                Receivers = Photon.Realtime.ReceiverGroup.Others
            };
            var sendOptions = new SendOptions {
                Reliability = true
            };

            PhotonNetwork.RaiseEvent(EventCodes.OnCardsDraw, new object[] { targetPlayerIndex, drawAction.Player.Deck.Count, cardIndices }, raiseEventoptions, sendOptions);
        }
Пример #4
0
        IEnumerator DrawCards(DrawCardsAction action)
        {
            var player    = action.Player as Player;
            int deckCount = player[Zones.Deck].Count;

            action.cards = new List <Card>();
            for (int i = 0; i < action.amount; i++)
            {
                if (player.hand.Count < player.maxHand)  //Has space in hand
                {
                    if (player.deck.Count == 0)          //Deck is empty
                    {
                        if (player.graveyard.Count == 0) //Graveyard empty, draw fatigue
                        {
                            var fatigueAction = new FatigueAction(player);
                            Container.AddReaction(fatigueAction);
                        }
                        else //Shuffle graveyard into deck
                        {
                            for (int j = player.graveyard.Count - 1; j >= 0; j--)
                            {
                                ChangeZone(player.graveyard[j], Zones.Deck);
                            }
                            this.PostNotification(DeckShuffledNotification, player);
                        }
                    }
                    if (player.deck.Count > 0) //Draw
                    {
                        var draw = player[Zones.Deck].Draw(1)[0];
                        action.cards.Add(draw);
                        ChangeZone(draw, Zones.Hand);
                        this.PostNotification(DeckChangedNotification, player);
                    }
                }
                else //Overdraw
                {
                    var overDrawAction = new OverdrawAction(player, 1);
                    Container.AddReaction(overDrawAction);
                }
                yield return(null);
            }
        }