コード例 #1
0
        private void RemovePermanently(ManaUnit unit)
        {
            foreach (var colorIndex in unit.Color.Indices)
            {
                _groups[colorIndex].Remove(unit);
            }

            _units.Remove(unit);
        }
コード例 #2
0
        public void Remove(ManaUnit unit)
        {
            if (_manaPool.Contains(unit))
            {
                _removeList.Add(unit);
                return;
            }

            RemovePermanently(unit);
        }
コード例 #3
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
        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);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
                    }
                }
            }
        }
コード例 #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);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 private int GetManaUnitAllocationOrder(ManaUnit x)
 {
     return(_manaPool.Contains(x) ? 0 : x.Rank *10 + x.Color.Indices.Count);
 }
コード例 #9
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
        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);
              }
            }
              }
        }
コード例 #10
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
        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);
              }
        }
コード例 #11
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
        private void RemovePermanently(ManaUnit unit)
        {
            foreach (var colorIndex in unit.Color.Indices)
              {
            _groups[colorIndex].Remove(unit);
              }

              _units.Remove(unit);
        }
コード例 #12
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
        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;
        }
コード例 #13
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
 private int GetManaUnitAllocationOrder(ManaUnit x)
 {
     return _manaPool.Contains(x) ? 0 : x.Rank*10 + x.Color.Indices.Count;
 }
コード例 #14
0
ファイル: ManaCache.cs プロジェクト: leloulight/magicgrove
        public void Remove(ManaUnit unit)
        {
            if (_manaPool.Contains(unit))
              {
            _removeList.Add(unit);
            return;
              }

              RemovePermanently(unit);
        }