diff --git a/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java b/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java index f14f4df9..f68a5b41 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java @@ -229,7 +229,7 @@ public class Facade { } return new PlayerDTO(playerCache.get(steamid)); } - + public Collection getleaderBoard(int iterator) { int playerAddiditionCap = 99; Collection playerAvatarsCaching = new ArrayList(); @@ -418,8 +418,7 @@ public class Facade { for (MapBoard mapboard : mapboards) { //System.out.println("mapName: " + mapboard.getMapName()); List mapvalues = new ArrayList(); - for (MapValues mv : mapboard.getMapvalues()) - { + for (MapValues mv : mapboard.getMapvalues()) { mapvalues.add(mv); } mapvalues.sort(Comparator.comparing(MapValues::getTime)); @@ -431,28 +430,43 @@ public class Facade { for (MapBoard mapboard : mapBoardCache.values()) { List mapvalues = mapboard.getMapvalues(); int playerCount = mapvalues.size(); - //2024 edit, its been a damn long time ago this all was made - //editing so top 5% and top 1% of finisher each get an extra boost. + //2024 edit, its been a damn long time ago this all was made + //editing so top 5% and top 1% of finisher each get an extra boost. int FivePercent = 0; int OnePercent = 0; - if (playerCount >= 100){ + if (playerCount >= 100) { FivePercent = (int) Math.floor(playerCount * 0.05); OnePercent = (int) Math.floor(playerCount * 0.01); } int position = 1; + + //suggested by roko. cause in rare cases a guy in top 1% or 5% has the same time as a guy right behind him not getting the percentage boost. + //if rank 10 and rank 11 both have a time of 10.546 maybe only rank 10 gets the 1% boost but not rank 11. this is meant to give rank 11 the boost too. + float previousTimeOnePercent = 0.0f; + float previousTimeFivePercent = 0.0f; for (MapValues mapvalue : mapvalues) { mapvalue.setPosition(position); int Points = playerCount - position; - if (playerCount <= 250) - { + if (playerCount <= 250) { //if less than 250 people finished a time i also want to give them each an additional 2500 points. //that is to make up hard timers that not many people actually finish so they are considered worth more. //for example race mode in mako and race timers in jump king should be rewarded a lot more due to their difficulties. Points += 2500; } - if (position <= OnePercent){ + if (position <= OnePercent) { Points *= 4; - } else if (position <= FivePercent){ + previousTimeOnePercent = mapvalue.getTime(); //eventually is set for the last guy getting 1% boost. + } else if (position <= FivePercent) { + previousTimeFivePercent = mapvalue.getTime(); //eventually is set for the last guy getting 5% boost. + if (previousTimeFivePercent == previousTimeOnePercent) { + //if a guy is listed as part of 5% boost but has the exact same time as the last guy getting 1% boost give him the 1% boost benefit too. + Points *= 4; + } else { + Points *= 2; + } + } + else if (previousTimeFivePercent == mapvalue.getTime()) { + //if the last guy getting 5% boost has a time of 10.654 and the next guy also has a time of 10.654 give him the boost too. Points *= 2; } mapvalue.setMapPoints(Points);