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); }
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); }