1919 */
2020public class Rating {
2121
22+ private final double advantage ;
2223 private double rating ;
2324 private double ratingDeviation ;
2425 private double volatility ;
@@ -31,17 +32,35 @@ public class Rating {
3132 private double workingVolatility ;
3233
3334 public Rating (double initRating , double initRatingDeviation , double initVolatility , int nbResults ) {
34- this (initRating , initRatingDeviation , initVolatility , nbResults , null );
35+ this (0.0d , initRating , initRatingDeviation , initVolatility , nbResults , null );
3536 }
3637
3738 public Rating (double initRating , double initRatingDeviation , double initVolatility , int nbResults , DateTime lastRatingPeriodEndDate ) {
39+ this (0.0d , initRating , initRatingDeviation , initVolatility , nbResults , lastRatingPeriodEndDate );
40+ }
41+
42+ public Rating (double advantage , double initRating , double initRatingDeviation , double initVolatility , int nbResults , DateTime lastRatingPeriodEndDate ) {
43+ this .advantage = advantage ;
3844 this .rating = initRating ;
3945 this .ratingDeviation = initRatingDeviation ;
4046 this .volatility = initVolatility ;
4147 this .numberOfResults = nbResults ;
4248 this .lastRatingPeriodEndDate = lastRatingPeriodEndDate ;
4349 }
4450
51+ public Rating withAdvantage (double advantage ) {
52+ return new Rating (advantage , rating , ratingDeviation , volatility , numberOfResults , lastRatingPeriodEndDate );
53+ }
54+
55+ /**
56+ * Return the skill advantage (first-player handicap) value.
57+ *
58+ * @return double
59+ */
60+ public double getAdvantage () {
61+ return this .advantage ;
62+ }
63+
4564 /**
4665 * Return the average skill value of the player.
4766 *
@@ -55,6 +74,16 @@ public void setRating(double rating) {
5574 this .rating = rating ;
5675 }
5776
77+ /**
78+ * Return the average skill value of the player scaled down
79+ * to the scale used by the algorithm's internal workings.
80+ *
81+ * @return double
82+ */
83+ public double getGlicko2RatingWithAdvantage () {
84+ return RatingCalculator .convertRatingToGlicko2Scale (this .rating + advantage );
85+ }
86+
5887 /**
5988 * Return the average skill value of the player scaled down
6089 * to the scale used by the algorithm's internal workings.
@@ -70,7 +99,7 @@ public double getGlicko2Rating() {
7099 *
71100 * @param double
72101 */
73- public void setGlicko2Rating (double rating ) {
102+ private void setGlicko2Rating (double rating ) {
74103 this .rating = RatingCalculator .convertRatingToOriginalGlickoScale (rating );
75104 }
76105
0 commit comments