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)); } }
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(); } }
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); }
public void EmptyManaPool() { foreach (var unit in _manaPool.Where(x => !x.HasSource)) { RemovePermanently(unit); } lock (_manaPoolCountLock) { _manaPool.Clear(); } RemoveAllScheduled(); }
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); } }
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); } }