Exemplo n.º 1
0
 public void setCards(SCards cards, List <int> indices)
 {
     for (int i = 0; i < indices.Count; ++i)
     {
         _cards[indices[i]] = cards.cards[i];
     }
 }
Exemplo n.º 2
0
        public SPlay(SPlayers players, params SCards[] startedDecks)
        {
            _random = new Random();

            _players     = players;
            _playerCount = startedDecks.Count();
            _logger      = new SLogger(_playerCount);
            _cards       = new SCards();
            // unite all started decks and host for it
            // and change its place to StartedDeck
            // then make default copy of it and then
            // place them to Deck
            int player = -1;

            foreach (SCards startedDeck in startedDecks)
            {
                ++player;
                startedDeck.setGame(this);
                startedDeck.setHost(player);
                startedDeck.setLocation(SPlace.startingdeck);
                _cards.addCards(startedDeck);

                SCards deck = startedDeck.defaultCopy();
                deck.setLocation(SPlace.deck);
                _cards.addCards(deck);
                shuffleDeck(player);
            }
        }
Exemplo n.º 3
0
 public SRequestAbstractSelectCard(string requestQestion, SCards cards, int adressPlayer) : base(requestQestion, adressPlayer)
 {
     _cardIds = new List <int>(); foreach (SCard card in cards.cards)
     {
         _cardIds.Add(card.id);
     }
 }
Exemplo n.º 4
0
        public SCards range(List <int> indices)
        {
            SCards rangeCards = new SCards(); for (int i = 0; i < indices.Count; ++i)

            {
                rangeCards.addCard(_cards[indices[i]]);
            }
            return(rangeCards);
        }
Exemplo n.º 5
0
 public static CardPredicat otherThen(SCards scards)
 {
     return((c) => { foreach (SCard card in scards.cards)
                     {
                         if (c.Equals(card))
                         {
                             return false;
                         }
                     }
                     return true; });
 }
Exemplo n.º 6
0
        // returns list of
        // ticked cards
        public SCards tick(int X = 1)
        {
            SCards finished = new SCards();

            foreachCard((c) => { if (c.timer.tick(X))
                                 {
                                     finished.addCard(c);
                                 }
                        });
            return(finished);
        }
Exemplo n.º 7
0
        // damage all selected units by specified X
        // returns count of units died this way
        public SCards damage(int X, SCard source = null)
        {
            SCards     banish    = new SCards();
            SCards     dead      = new SCards();
            SCards     armorLost = new SCards();
            List <int> recived   = new List <int>();

            foreachCard((c) =>
            {
                SHitResult hitResult = c.power.damage(X);
                recived.Add(hitResult.healthLost);
                if (hitResult.shouldBeDead)
                {
                    (c.containsTag(STag.doomed)? banish : dead).addCard(c);
                }
                else if (hitResult.armorWasBroken)
                {
                    armorLost.addCard(c);
                }
            });
            // (using foreachCard of daed/armorLost)
            // move dead group to graveyard
            // trigger their deathwishes
            // if dead, but has doomed
            // move it to banish instead
            // and do not trigger deathwish
            // trigger all armorLost units
            // on armorlost triggers
            // rest non-dead and non-banished
            // trigger for damaged
            // then return all killed cards
            // killed = banished + dead
            foreachCard((c) =>
            {
                int damagedFor = recived[_cards.IndexOf(c)];
                if (!dead.contains(c) && !banish.contains(c) && damagedFor > 0)
                {
                    c.trigger(STType.onDamaged, source, damagedFor);
                }
                if (armorLost.contains(c))
                {
                    c.trigger(STType.onArmorLost);
                }
            });
            dead.move(SPlace.graveyard);
            banish.move(SPlace.banish);
            return(dead.addCards(banish));
        }
Exemplo n.º 8
0
 public SRequestSelectOneCard(string requestQestion, SCards cards, SCard source) : base(requestQestion, cards, source.host)
 {
     sourceId = source.id;
 }
Exemplo n.º 9
0
 public SCards defaultCopy()
 {
     SCards res = new SCards(); foreachCard((c) => { res.addCard(c.defaultCopy()); }); return(res);
 }
Exemplo n.º 10
0
 public SCards unite(SCards[] scards)
 {
     SCards res = new SCards(); foreachCard((c) => { res.addCard(c); }); return(res);
 }
Exemplo n.º 11
0
 public SCards addCards(SCards cards)
 {
     _cards.AddRange(cards.cards); return(this);
 }