File tree Expand file tree Collapse file tree
src/main/java/com/github/elic0de/thejpspit/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import static java .lang .Math .round ;
44
5+ import com .github .elic0de .thejpspit .player .OfflinePitPlayer ;
56import com .github .elic0de .thejpspit .player .PitPlayer ;
67
78public class KillRatingHelper {
@@ -18,6 +19,10 @@ public void initRating(PitPlayer player) {
1819 player .setRating (calculateKillingRatio (player ));
1920 }
2021
22+ public void initRating (OfflinePitPlayer player ) {
23+ player .setRating (calculateKillingRatio (player ));
24+ }
25+
2126 private double calculateKillingRatio (PitPlayer player ) {
2227 long deaths = player .getDeaths ();
2328 long kills = player .getKills ();
@@ -28,4 +33,15 @@ private double calculateKillingRatio(PitPlayer player) {
2833 return defaultRating ;
2934 }
3035 }
36+
37+ private double calculateKillingRatio (OfflinePitPlayer player ) {
38+ long deaths = player .getDeaths ();
39+ long kills = player .getKills ();
40+ long total = deaths + kills ;
41+ if (deaths >= 0 && kills >= 0 && total > 0 ) {
42+ return round ((double ) kills / deaths * roundingFactor ) / roundingFactor ;
43+ } else {
44+ return defaultRating ;
45+ }
46+ }
3147}
You can’t perform that action at this time.
0 commit comments