コード例 #1
0
ファイル: Stack.cs プロジェクト: longde123/grove
        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));
            }
        }
コード例 #2
0
ファイル: Combat.cs プロジェクト: longde123/grove
        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();
            }
        }
コード例 #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);
        }
コード例 #4
0
        public void EmptyManaPool()
        {
            foreach (var unit in _manaPool.Where(x => !x.HasSource))
            {
                RemovePermanently(unit);
            }

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

            RemoveAllScheduled();
        }
コード例 #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);
            }
        }
コード例 #6
0
ファイル: ManaCache.cs プロジェクト: longde123/grove
        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);
            }
        }