Exemplo n.º 1
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));
        }