コード例 #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);
        }
コード例 #2
0
        public UserRankViewModel GetRankForPoints(int points)
        {
            UserRankViewModel rank = UserCurrencyViewModel.NoRank;

            if (this.Ranks.Count > 0)
            {
                rank = this.Ranks.Where(r => r.MinimumPoints <= points).OrderByDescending(r => r.MinimumPoints).FirstOrDefault();
            }
            return(rank);
        }
コード例 #3
0
 public UserRankViewModel GetNextRankForPoints(int points)
 {
     UserRankViewModel rank = UserCurrencyViewModel.NoRank;
     if (this.Ranks.Count > 0)
     {
         rank = this.Ranks.Where(r => r.MinimumPoints > points).OrderBy(r => r.MinimumPoints).FirstOrDefault();
         if (rank == null)
         {
             rank = UserCurrencyViewModel.NoRank;
         }
     }
     return rank;
 }
コード例 #4
0
        public override string ToString()
        {
            UserRankViewModel rank = this.Currency.GetRankForPoints(this.Amount);

            return(string.Format("{0} - {1}", rank.Name, this.Amount));
        }
コード例 #5
0
 public UserCurrencyRequirementViewModel(UserCurrencyViewModel currency, UserRankViewModel rank, bool mustEqual = false)
 {
     this.CurrencyID = currency.ID;
     this.RankName   = rank.Name;
     this.MustEqual  = mustEqual;
 }