Example #1
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);
            }
        }
Example #2
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));
        }