示例#1
0
        public bool TryPay(IReadOnlyTokenCollection price)
        {
            if (!CanPay(price))
            {
                return(false);
            }

            foreach (TokenColor key in TokenUtils.AllTokens)
            {
                var discountedPrice = price.GetCount(key) - Discount(key);

                if (discountedPrice < 1)
                {
                    continue;
                }

                uint goldDiff = (uint)(discountedPrice - TokenCount(key));

                if (goldDiff > 0)
                {
                    _tokensInternal.TryTake(TokenColor.Yellow, goldDiff);
                    _tokensInternal.AddTokens(key, goldDiff);
                }
                else
                {
                    return(false);
                }
            }

            _tokensInternal.TryTake(price);
            return(true);
        }
示例#2
0
 public bool TryTakeTokensFormBoard(TokenCollection tokensToGetFromBoard) => _boardTokensInternal.TryTake(tokensToGetFromBoard);