forked from SteamWar/SteamWar
Fix UserElo.getEloFromDb
This commit is contained in:
@@ -46,14 +46,14 @@ public class Season {
|
||||
if (season == -1) return "";
|
||||
int yearSeason = season % 3;
|
||||
int year = (season - yearSeason) / 3;
|
||||
return String.format("%d-%d", year, yearSeason);
|
||||
return String.format("%d-%d", year, yearSeason + 1);
|
||||
}
|
||||
|
||||
public static int convertSeasonToNumber(String season){
|
||||
if (season.isEmpty()) return -1;
|
||||
String[] split = season.split("-");
|
||||
try {
|
||||
return Integer.parseInt(split[0]) * 3 + Integer.parseInt(split[1]);
|
||||
return Integer.parseInt(split[0]) * 3 + Integer.parseInt(split[1]) - 1;
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class UserElo(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
||||
.getOrPut(userId) { getEloFromDb(userId, gameMode)?.elo }
|
||||
|
||||
private fun getEloFromDb(userId: Int, gameMode: String) = useDb {
|
||||
find { (UserEloTable.userId eq userId) and (UserEloTable.gameMode eq gameMode) }.firstOrNull()
|
||||
find { (UserEloTable.userId eq userId) and (UserEloTable.gameMode eq gameMode) and (UserEloTable.season eq Season.getSeason()) }.firstOrNull()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -677,7 +677,8 @@ ARENA_NOT_FOUND=§cThe specified arena could not be found
|
||||
#Rank
|
||||
RANK_PLAYER_NOT_FOUND=§cPlayer not found
|
||||
RANK_PLAYER_FOUND=§eRank §7of §e{0}
|
||||
RANK_HEADER={0} §e{1} {2}
|
||||
RANK_HEADER=§eRank Season {0}
|
||||
RANK_DATA={0} §e{1} {2}
|
||||
RANK_UNPLACED=§7unranked
|
||||
RANK_PLACED=§e{0}§8. §7with §e{1} §7Elo§8.
|
||||
|
||||
|
||||
@@ -644,7 +644,8 @@ ARENA_NOT_FOUND=§cDie angegebene Arena konnte nicht gefunden werden
|
||||
#Rank
|
||||
RANK_PLAYER_NOT_FOUND=§cSpieler nicht gefunden
|
||||
RANK_PLAYER_FOUND=§eRang §7von §e{0}
|
||||
RANK_HEADER={0} §e{1} {2}
|
||||
RANK_HEADER=§eRang Saison {0}
|
||||
RANK_DATA={0} §e{1} {2}
|
||||
RANK_UNPLACED=§7unplatziert
|
||||
RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8.
|
||||
|
||||
|
||||
@@ -24,13 +24,11 @@ import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.Season;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Linked
|
||||
public class RankCommand extends SWCommand {
|
||||
|
||||
@@ -45,6 +43,7 @@ public class RankCommand extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void rank(Chatter sender, @ErrorMessage("RANK_PLAYER_NOT_FOUND") SteamwarUser user) {
|
||||
sender.prefixless("RANK_HEADER", Season.convertSeasonToString(Season.getSeason()));
|
||||
if (!sender.user().equals(user))
|
||||
sender.prefixless("RANK_PLAYER_FOUND", user);
|
||||
|
||||
@@ -61,7 +60,7 @@ public class RankCommand extends SWCommand {
|
||||
eloMsg = new Message("RANK_UNPLACED");
|
||||
}
|
||||
|
||||
sender.prefixless("RANK_HEADER", UserElo.getEmblemProgression(mode.getChatName(), user.getId()), mode.getChatName(), eloMsg);
|
||||
sender.prefixless("RANK_DATA", UserElo.getEmblemProgression(mode.getChatName(), user.getId()), mode.getChatName(), eloMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user