Exemplo n.º 1
0
        public void PushTriggered()
        {
            if (_triggeredEffects.Count == 0)
            {
                return;
            }

            var active = _triggeredEffects
                         .Where(x => x.Controller == Players.Active)
                         .ToList();

            var passive = _triggeredEffects
                          .Where(x => x.Controller == Players.Passive)
                          .ToList();

            _triggeredEffects.Clear();

            if (active.Count > 0)
            {
                Enqueue(new PushTriggeredEffects(
                            Players.Active,
                            active));
            }

            if (passive.Count > 0)
            {
                Enqueue(new PushTriggeredEffects(
                            Players.Passive,
                            passive));
            }
        }
Exemplo n.º 2
0
        public void AssignCombatDamage(bool firstStrike = false)
        {
            var blockers = firstStrike
        ? _blockers.Where(x => x.Card.HasFirstStrike)
        : _blockers.Where(x => x.Card.HasNormalStrike);

            var attackers = firstStrike
        ? _attackers.Where(x => x.Card.HasFirstStrike)
        : _attackers.Where(x => x.Card.HasNormalStrike);

            foreach (var blocker in blockers)
            {
                blocker.DistributeDamageToAttacker();
            }

            foreach (var attacker in attackers)
            {
                attacker.DistributeDamageToBlockers();
            }
        }
Exemplo n.º 3
0
        public bool Remove(Static ability)
        {
            var matches = _all
                          .Where(x => x.Value == ability)
                          .OrderBy(x => x.IsEnabled ? 0 : 1)
                          .ToList();

            if (matches.Count == 0)
            {
                return(false);
            }

            _all.Remove(matches.First());

            if (matches.Count(x => x.IsEnabled) == 1)
            {
                _active.Remove(ability);
            }
            return(true);
        }
Exemplo n.º 4
0
        public void EmptyManaPool()
        {
            foreach (var unit in _manaPool.Where(x => !x.HasSource))
            {
                RemovePermanently(unit);
            }

            lock (_manaPoolCountLock)
            {
                _manaPool.Clear();
            }

            RemoveAllScheduled();
        }
Exemplo n.º 5
0
        public void Remove(CounterType counterType, int?count = null)
        {
            var counters = _counters.Where(x => x.Type == counterType);

            if (count != null)
            {
                counters = counters.Take(count.Value);
            }

            foreach (var counter in counters.ToArray())
            {
                Remove(counter);
            }
        }
Exemplo n.º 6
0
        private void RestrictUsingDifferentSourcesFromSameCard(ManaUnit allocated, HashSet <ManaUnit> restricted)
        {
            // Same card cannot be tapped twice, therefore multiple sources
            // from same card cannot be used simultaniously.

            // Add to restricted all units produced by another source
            // of the same card.
            var unitsProducedByAnotherSourceOnSameCard = _units.Where(
                unit => unit.HasSource && allocated.HasSource &&
                unit.Source.OwningCard == allocated.Source.OwningCard &&
                unit.Source != allocated.Source);

            foreach (var unit in unitsProducedByAnotherSourceOnSameCard)
            {
                restricted.Add(unit);
            }
        }