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); }
public bool TryTakeTokensFormBoard(TokenCollection tokensToGetFromBoard) => _boardTokensInternal.TryTake(tokensToGetFromBoard);