Example #1
0
        public bool DoesMeetRankRequirement(UserDataViewModel userData)
        {
            UserCurrencyViewModel currency = this.GetCurrency();

            if (currency == null)
            {
                return(false);
            }

            UserRankViewModel rank = this.RequiredRank;

            if (rank == null)
            {
                return(false);
            }

            UserCurrencyDataViewModel userCurrencyData = userData.GetCurrency(currency);

            if (userCurrencyData.Amount < rank.MinimumPoints)
            {
                return(false);
            }

            if (this.MustEqual && userCurrencyData.GetRank() != rank)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
 public void SetCurrencyAmount(UserCurrencyViewModel currency, int amount)
 {
     if (!this.IsCurrencyRankExempt)
     {
         UserCurrencyDataViewModel currencyData = this.GetCurrency(currency);
         currencyData.Amount = Math.Min(amount, currencyData.Currency.MaxAmount);
     }
 }
Example #3
0
        public void ResetCurrency(UserCurrencyViewModel currency)
        {
            UserCurrencyDataViewModel currencyData = this.CurrencyAmounts.Values.FirstOrDefault(c => c.Currency.Equals(currency));

            if (currencyData != null)
            {
                currencyData.Amount = 0;
            }
        }
Example #4
0
        public bool TrySubtractAmount(UserDataViewModel userData, int amount)
        {
            if (this.DoesMeetCurrencyRequirement(amount))
            {
                UserCurrencyViewModel currency = this.GetCurrency();
                if (currency == null)
                {
                    return(false);
                }

                UserCurrencyDataViewModel userCurrencyData = userData.GetCurrency(currency);
                if (userCurrencyData.Amount < amount)
                {
                    return(false);
                }

                userCurrencyData.Amount -= amount;
                return(true);
            }
            return(false);
        }