protected virtual Pair ProcessRatings(IRating firstRating, IRating secondRating) { var pair = null as Pair; if (firstRating.Subject.Id == secondRating.Subject.Id) { pair = new Pair() { FirstRating = firstRating, SecondRating = secondRating }; ++IndexFirst; ++IndexSecond; } else if (firstRating.Subject.Id < secondRating.Subject.Id) { ++IndexFirst; } else { ++IndexSecond; } return(pair); }
public void SetRating(IRating rating) { if (myRating == null) { myRating = rating; } }
public override void AddRating(IRating rating) { _algorithm.AddRating(rating); base.AddRating(rating); _notCachedWeights[rating.Rater.Id] = true; _notCachedMeanVotes[rating.Rater.Id] = true; }
protected override Pair ProcessRatings(IRating firstRating, IRating secondRating) { var pair = new Pair() { FirstRating = firstRating, SecondRating = secondRating }; if (firstRating.Subject.Id == secondRating.Subject.Id) { ++IndexFirst; ++IndexSecond; } else if (firstRating.Subject.Id < secondRating.Subject.Id) { var rating = new SimpleRating(firstRating.Rater, firstRating.Subject, _defaultValue); pair.FirstRating = rating; ++IndexFirst; } else { var rating = new SimpleRating(secondRating.Rater, secondRating.Subject, _defaultValue); pair.SecondRating = rating; ++IndexSecond; } return(pair); }
public void UpdatePadDivergent(IRating rating) { MySqlParameter[] parameters = new MySqlParameter[2]; parameters[0] = new MySqlParameter("@videoID ", rating.VideoIdentity); parameters[1] = new MySqlParameter("@userID ", rating.UserID); context.ExecuteStoredProcedure("UpdatePadDivergent", parameters); }
public static Rating CreateRating(IRating data) { return(new Rating { RatingUid = data.RatingUid, Name = data.Name }); }
public ActionResult DeleteConfirmed(int id) { IRating iRating = db.IRatings.Find(id); db.IRatings.Remove(iRating); db.SaveChanges(); return(RedirectToAction("Index")); }
public RatingLink(Rating2ArticleType2Category entity, IRating rating) { this.ArticleTypeId = entity.ArticleTypeId; this.CategoryId = entity.CategoryId; this.RatingIds = new Dictionary <int, IRating> { { entity.Ordinal, rating } }; }
public void AddRating(IRating rating) { var key = CreateCacheKey(rating.Rater, rating.Subject); var value = 0D; _cache.TryRemove(key, out value); _algorithm.AddRating(rating); }
private void SetSeriesStats() { IRating currPlayer = _context.SeriesRatingDbSet.FirstOrDefault(x => x.Nick == PlayerNick); if (currPlayer != null) { SetStats(currPlayer); } _currDb = "Series"; }
/// <summary> /// Determines whether the specified <see cref="rateitlib.IRating"/> is equal to the current <see cref="rateitlib.Rating"/>. /// </summary> /// <param name="other">The <see cref="rateitlib.IRating"/> to compare with the current <see cref="rateitlib.Rating"/>.</param> /// <returns><c>true</c> if the specified <see cref="rateitlib.IRating"/> is equal to the current /// <see cref="rateitlib.Rating"/>; otherwise, <c>false</c>.</returns> public bool Equals(IRating other) { if (other.NormalisedValue == null) return false; if (other.NormalisedValue != this.NormalisedValue) return false; return true; }
private void SetWeekStats() { IRating currPlayer = _context.WeekRatingDbSet.FirstOrDefault(x => x.Nick == PlayerNick); if (currPlayer != null) { SetStats(currPlayer); } _currDb = "Week"; }
private void SetAllTimeStats() { IRating currPlayer = _context.AllTimeRatingDbSet.FirstOrDefault(x => x.Nick == PlayerNick); if (currPlayer != null) { SetStats(currPlayer); } _currDb = "AllTime"; }
public static Rating FromRating(IRating rating) { Rating r = new Rating { UserName = rating.UserName, Value = rating.Value, CreatedOn = rating.CreatedOn, }; return r; }
public IRating UpdateRating(IRating data) { var db = new TooksCmsDAL(); var r = db.Ratings.First(r_ => r_.RatingId == data.RatingId); r.Update(data); db.SaveChanges(); return(r); }
public IRating InsertRating(IRating data) { var db = new TooksCmsDAL(); var r = Rating.CreateRating(data); db.Ratings.Add(r); db.SaveChanges(); return(r); }
public static Rating FromRating(IRating rating) { Rating r = new Rating { UserName = rating.UserName, Value = rating.Value, CreatedOn = rating.CreatedOn, }; return(r); }
public ActionResult Edit([Bind(Include = "IRatingID,SubCriteria1,SubCriteria2,SubCriteria3,SubCriteria4,SubCriteria5,SubCriteria6,SubCriteria7,SubCriteria8,SubCriteria9,SubCriteria10,SubCriteria11,SubCriteria12,SubCriteria13,SubCriteria14,SubCriteria15,SubCriteria16,SubCriteria17,SubCriteria18,SubCriteria19,SubCriteria20,Review,StudentID,InstructorID")] IRating iRating) { if (ModelState.IsValid) { db.Entry(iRating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", iRating.InstructorID); ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name", iRating.StudentID); return(View(iRating)); }
public ApplicationRateEventArgs(int appId, IRating overallRating,IRating userRating) { if (overallRating == null) throw new ArgumentNullException("overallRating"); if (userRating == null) throw new ArgumentNullException("userRating"); this.ApplicationId = appId; this.OverallRating = overallRating; this.UserRating = userRating; }
// GET: IRating/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IRating iRating = db.IRatings.Find(id); if (iRating == null) { return(HttpNotFound()); } return(View(iRating)); }
// GET: IRating/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IRating iRating = db.IRatings.Find(id); if (iRating == null) { return(HttpNotFound()); } ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", iRating.InstructorID); ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name", iRating.StudentID); return(View(iRating)); }
public void UpdateRatings(IRating winner, IRating loser) { var drawMargin = GetDrawMargin(); var c = Math.Sqrt((2 * Beta.Squared()) + winner.StandardDeviation + loser.StandardDeviation); var skillDiff = winner.Mean - loser.Mean; // The dynamics is added to ensure the sd and mean never stagnate. var dynamicsVariance = winner.StandardDeviation.Squared() + DynamicsFactor.Squared(); var meanMult = dynamicsVariance / c; var sdMult = dynamicsVariance / c.Squared(); var v = VExceedsMargin(skillDiff, drawMargin, c); var w = WExceedsMargin(skillDiff, drawMargin, c); winner.Mean += meanMult * v; winner.StandardDeviation = Math.Sqrt(dynamicsVariance * (1 - (sdMult * w))); loser.Mean -= meanMult * v; loser.StandardDeviation = Math.Sqrt(dynamicsVariance * (1 - (sdMult * w))); }
public bool PostRating(IRating rating) { var ratingDbo = db.Ratings.FirstOrDefault(x => x.MovieId == rating.MovieId && x.UserId == rating.UserId); if (ratingDbo != null) { ratingDbo.Score = rating.Score; db.Entry(ratingDbo).State = EntityState.Modified; } else { db.Ratings.Add(new Rating { MovieId = rating.MovieId, UserId = rating.UserId, Score = rating.Score }); } db.SaveChanges(); return(true); }
public bool PutRating(int id, IRating rating) { db.Entry(rating).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RatingExists(id)) { return(false); } else { throw; } } return(true); }
private void SetStats(IRating currPlayer) { GamesCount = currPlayer.Games; Score = currPlayer.Score ?? 0; Rating = currPlayer.Rating ?? 0; BestPlayer = currPlayer.BestPlayer != null && currPlayer.Games != 0 ? (Extensions.DoubleDivide(currPlayer.BestPlayer, currPlayer.Games) * 100).RoundTwo() : 0; BanRatio = currPlayer.Ban != null ? (Extensions.DoubleDivide(currPlayer.Ban, currPlayer.Games) * 100).RoundTwo() : 0; FirstNightRatio = currPlayer.KilledAtFirstDay != null ? (Extensions.DoubleDivide(currPlayer.KilledAtFirstDay, currPlayer.Games) * 100).RoundTwo() : 0; FoulsRatio = currPlayer.Fouls != null ? (Extensions.DoubleDivide(currPlayer.Fouls, currPlayer.Games)).RoundTwo() : 0; CheckRatio = currPlayer.CheckedFirst != null ? (Extensions.DoubleDivide(currPlayer.CheckedFirst, currPlayer.Games) * 100).RoundTwo() : 0; WinDon = currPlayer.WinDon != null ? (Extensions.DoubleDivide(currPlayer.WinDon, currPlayer.WinDon + (currPlayer.LoseDon ?? 0)) * 100).RoundTwo() : 0; WinSheriff = currPlayer.WinSheriff != null ? (Extensions.DoubleDivide(currPlayer.WinSheriff, currPlayer.WinSheriff + (currPlayer.LoseSheriff ?? 0)) * 100).RoundTwo() : 0; WinRed = currPlayer.WinRed != null ? (Extensions.DoubleDivide(currPlayer.WinRed, currPlayer.WinRed + (currPlayer.LoseRed ?? 0)) * 100).RoundTwo() : 0; WinBlack = currPlayer.WinBlack != null ? (Extensions.DoubleDivide(currPlayer.WinBlack, currPlayer.WinBlack + (currPlayer.LoseBlack ?? 0)) * 100).RoundTwo() : 0; FalseComRatio = currPlayer.FalseComWin != null ? (Extensions.DoubleDivide(currPlayer.FalseComWin, currPlayer.FalseCom) * 100).RoundTwo() : 0; TechRed = currPlayer.TechRed ?? 0; TechBlack = currPlayer.TechBlack ?? 0; RedUgad = currPlayer.RedUgadayka ?? 0; BlackUgad = currPlayer.BlackUgadayka ?? 0; WinLose = WinLoseSet(currPlayer); RolesStat = RolesStatSet(currPlayer); }
private static PlotModel WinLoseSet(IRating player) { var win = player?.Win ?? 0; var lose = player?.Lose ?? 0; var plot = new PlotModel { Title = null, IsLegendVisible = false }; var ps = new PieSeries { InsideLabelPosition = 0.5, Stroke = OxyColors.Transparent, StartAngle = 0, AngleSpan = 360, InsideLabelColor = OxyColors.White, FontSize = 10, TextColor = OxyColors.White, }; var redslice = new PieSlice { Label = GetLocalized("InfoWinLabel"), Value = win, Fill = OxyColors.Red }; var blackslice = new PieSlice { Label = GetLocalized("InfoLoseLabel"), Value = lose, Fill = OxyColors.Black, }; ps.Slices.Add(redslice); ps.Slices.Add(blackslice); plot.Series.Add(ps); return(plot); }
public int CompareTo(IRating other) { var thisPieces = ToString().Split('.'); var otherPieces = other.ToString().Split('.'); if (thisPieces.Length != otherPieces.Length) { throw new Exception($"Can't compare Rating: '{this}' with '{other}'!"); } for (var i = 0; i < thisPieces.Length; i++) { var thisNumber = int.Parse(thisPieces[i]); var otherNumber = int.Parse(otherPieces[i]); var comp = thisNumber.CompareTo(otherNumber); if (comp != 0) { return(comp); } } return(0); }
public static void GeneralDbUpdate(PlayerEntry player, IRating currentPlayer, ObservableCollection <PlayerEntry> players, bool isBestWay, bool redWin, bool blackWin, bool techRedWin, bool techBlackWin, ObservableCollection <int?> ugadaykaContainer, bool ugadaykaOn, bool threeZv, int prohBal, bool writeAcchievements, bool falseCom) { var path = $@"{Directory.GetCurrentDirectory()}\Rating Acchievements.txt"; currentPlayer.Games += 1; currentPlayer.Score += player.Result; if (player.Reflection != null && player.Reflection > 0) { currentPlayer.BestPlayer = currentPlayer.BestPlayer.Increment(); } if (isBestWay && player.PositionInKillQueue == 1) { currentPlayer.BestChoice = currentPlayer.BestChoice.Increment(); } if (falseCom) { currentPlayer.FalseCom = currentPlayer.FalseCom.Increment(); } if (redWin && player.IsRedTeam() || blackWin && player.IsBlackTeam()) { currentPlayer.Win = currentPlayer.Win.Increment(); currentPlayer.WinRow = currentPlayer.WinRow.Increment(); if (falseCom) { currentPlayer.FalseComWin = currentPlayer.FalseComWin.Increment(); } } if (techRedWin && player.IsRedTeam()) { currentPlayer.TechRed = currentPlayer.TechRed.Increment(); } if (techBlackWin && player.IsBlackTeam()) { currentPlayer.TechBlack = currentPlayer.TechBlack.Increment(); } if (redWin && player.IsBlackTeam() || blackWin && player.IsRedTeam()) { currentPlayer.Lose = currentPlayer.Lose.Increment(); currentPlayer.WinRow = 0; if (falseCom) { currentPlayer.FalseComLose = currentPlayer.FalseComLose.Increment(); } } if (ugadaykaContainer.Contains(players.IndexOf(player) + 1) && player.IsRedTeam() && redWin && ugadaykaOn) { currentPlayer.RedUgadayka = currentPlayer.RedUgadayka.Increment(); } if (ugadaykaContainer.Contains(players.IndexOf(player) + 1) && player.IsBlackTeam() && blackWin && ugadaykaOn) { currentPlayer.BlackUgadayka = currentPlayer.BlackUgadayka.Increment(); } if (blackWin && player.Role == GetLocalized("Don")) { currentPlayer.WinDon = currentPlayer.WinDon.Increment(); } if (redWin && player.Role == GetLocalized("Sheriff")) { currentPlayer.WinSheriff = currentPlayer.WinSheriff.Increment(); } if (redWin && player.Role == GetLocalized("Red")) { currentPlayer.WinRed = currentPlayer.WinRed.Increment(); } if (blackWin && player.Role == GetLocalized("Black")) { currentPlayer.WinBlack = currentPlayer.WinBlack.Increment(); } if (redWin && player.Role == GetLocalized("Don")) { currentPlayer.LoseDon = currentPlayer.LoseDon.Increment(); } if (blackWin && player.Role == GetLocalized("Sheriff")) { currentPlayer.LoseSheriff = currentPlayer.LoseSheriff.Increment(); } if (redWin && player.Role == GetLocalized("Black")) { currentPlayer.LoseBlack = currentPlayer.LoseBlack.Increment(); } if (blackWin && player.Role == GetLocalized("Red")) { currentPlayer.LoseRed = currentPlayer.LoseRed.Increment(); } if (player.Foul != null && player.Foul != 0) { currentPlayer.Fouls = currentPlayer.Fouls == null ? player.Foul : currentPlayer.Fouls += player.Foul; currentPlayer.WithoutFouls = 0; } else { currentPlayer.WithoutFouls = currentPlayer.WithoutFouls.Increment(); } if (player.PositionInKillQueue == 1) { currentPlayer.KilledAtFirstDay = currentPlayer.KilledAtFirstDay.Increment(); } if (player.CheckedAtNight == 1) { currentPlayer.CheckedFirst = currentPlayer.CheckedFirst.Increment(); } if (player.CheckedAtNight == 2) { currentPlayer.CheckedSecond = currentPlayer.CheckedSecond.Increment(); } if (threeZv && player.Role == GetLocalized("Sheriff")) { currentPlayer.ThreeZv = currentPlayer.ThreeZv.Increment(); } if (player.Foul == 4) { currentPlayer.Ban = currentPlayer.Ban.Increment(); } if (currentPlayer.WinRow == 5) { currentPlayer.Score += 1; if (writeAcchievements) { using (var sw = new StreamWriter(path, true)) { sw.WriteLine($"{DateTime.Now.ToShortDateString()}. {currentPlayer.Nick} - Combo Win"); sw.Close(); } } } if (currentPlayer.WinRow == 10) { if (currentPlayer.Score != null) { currentPlayer.Score += 3; } if (writeAcchievements) { using (var sw = new StreamWriter(path, true)) { sw.WriteLine($"{DateTime.Now.ToShortDateString()}. {currentPlayer.Nick} - Epic Win"); sw.Close(); } } } if (currentPlayer.WinRow > 10) { if (currentPlayer.Score != null) { currentPlayer.Score += (double)currentPlayer.WinRow / 20; } if (writeAcchievements) { using (var sw = new StreamWriter(path, true)) { sw.WriteLine($"{DateTime.Now.ToShortDateString()}. {currentPlayer.Nick} - Win series {currentPlayer.WinRow}"); sw.Close(); } } } if (currentPlayer.WithoutFouls == 10 && writeAcchievements) { using (var sw = new StreamWriter(path, true)) { sw.WriteLine($"{DateTime.Now.ToShortDateString()}. {currentPlayer.Nick} - Epic Without Fouls"); sw.Close(); } } if (currentPlayer.Games >= prohBal) { currentPlayer.Rating = currentPlayer.Score / currentPlayer.Games * 100; if (currentPlayer.Rating != null) { currentPlayer.Rating = Math.Round((double)currentPlayer.Rating, 3); } } else { currentPlayer.Rating = null; } }
public RatingSubmitBuilder(IRating submit) { this.submit = submit; }
public EntityTemplate(IFaction f, IRating r) { m_faction = f; m_rating = r; }
public int GetThreat(IRating other) { return((Rating as GroupRating).GetThreat(other)); }
public int GetThreat(IRating other) { return(m_EntityTemplates.Sum(e => e.Rating.GetThreat(other))); }
public int GetThreat(IRating other) { return(m_rating); }
private static PlotModel RolesStatSet(IRating player) { var red = player != null?player.WinRed.GetValueOrDefault() + player.LoseRed.GetValueOrDefault() : 0; var black = player != null?player.WinBlack.GetValueOrDefault() + player.LoseBlack.GetValueOrDefault() : 0; var sheriff = player != null?player.WinSheriff.GetValueOrDefault() + player.LoseSheriff.GetValueOrDefault() : 0; var don = player != null?player.WinDon.GetValueOrDefault() + player.LoseDon.GetValueOrDefault() : 0; var plot = new PlotModel { Title = null, IsLegendVisible = false }; var ps = new PieSeries { InsideLabelPosition = 0.6, Stroke = OxyColors.Transparent, StartAngle = 0, AngleSpan = 360, InsideLabelColor = OxyColors.White, FontSize = 8, TextColor = OxyColors.White, }; var redslice = new PieSlice { Label = GetLocalized("InfoRedSlice"), Value = red, Fill = OxyColors.Red }; var blackslice = new PieSlice { Label = GetLocalized("InfoBlackSlice"), Value = black, Fill = OxyColors.Black, }; var sheriffslice = new PieSlice { Label = GetLocalized("InfoSheriffSlice"), Value = sheriff, Fill = OxyColor.FromRgb(255, 100, 100) }; var donslice = new PieSlice { Label = GetLocalized("InfoDonSlice"), Value = don, Fill = OxyColor.FromRgb(50, 50, 50) }; if (red != 0) { ps.Slices.Add(redslice); } if (black != 0) { ps.Slices.Add(blackslice); } if (don != 0) { ps.Slices.Add(donslice); } if (sheriff != 0) { ps.Slices.Add(sheriffslice); } plot.Series.Add(ps); return(plot); }
public GeneticAlgorithm(IRating ratingCallback) { this.ratingCallback = ratingCallback; }