private void RemovePermanently(ManaUnit unit) { foreach (var colorIndex in unit.Color.Indices) { _groups[colorIndex].Remove(unit); } _units.Remove(unit); }
public void Remove(ManaUnit unit) { if (_manaPool.Contains(unit)) { _removeList.Add(unit); return; } RemovePermanently(unit); }
public void Add(ManaUnit unit) { foreach (var colorIndex in unit.Color.Indices) { _groups[colorIndex].Add(unit); } // Every mana can be used as colorless. // True colorless mana was already added, so we don't add it again. if (unit.Color.IsColorless == false) _units.Add(unit); }
public void Add(ManaUnit unit) { foreach (var colorIndex in unit.Color.Indices) { _groups[colorIndex].Add(unit); } // Every mana can be used as colorless. // True colorless mana was already added, so we don't add it again. if (unit.Color.IsColorless == false) { _units.Add(unit); } }
public void AddManaToPool(ManaAmount amount, ManaUsage usage) { lock (_manaPoolCountLock) { foreach (var mana in amount) { for (var i = 0; i < mana.Count; i++) { var unit = new ManaUnit(mana.Color, 0, usageRestriction: usage); Add(unit); _manaPool.Add(unit); } } } }
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); } }
private bool IsAvailable(ManaUnit unit, HashSet <ManaUnit> restricted, ManaUsage usage) { if (restricted.Contains(unit)) { return(false); } if (unit.CanActivateSource() == false && _manaPool.Contains(unit) == false) { return(false); } if (unit.CanBeUsed(usage) == false) { return(false); } return(true); }
private int GetManaUnitAllocationOrder(ManaUnit x) { return(_manaPool.Contains(x) ? 0 : x.Rank *10 + x.Color.Indices.Count); }
public void AddManaToPool(IManaAmount amount, ManaUsage usage) { lock (_manaPoolCountLock) { foreach (var mana in amount) { for (var i = 0; i < mana.Count; i++) { var unit = new ManaUnit(mana.Color, 0, usageRestriction: usage); Add(unit); _manaPool.Add(unit); } } } }
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); } }
private bool IsAvailable(ManaUnit unit, HashSet<ManaUnit> restricted, ManaUsage usage) { if (restricted.Contains(unit)) return false; if (unit.CanActivateSource() == false && _manaPool.Contains(unit) == false) return false; if (unit.CanBeUsed(usage) == false) return false; return true; }
private int GetManaUnitAllocationOrder(ManaUnit x) { return _manaPool.Contains(x) ? 0 : x.Rank*10 + x.Color.Indices.Count; }