mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Add "minimum rating" option to matches and tournaments
This commit is contained in:
parent
6e26719367
commit
81c2a62250
9 changed files with 126 additions and 19 deletions
|
|
@ -227,6 +227,20 @@ public class MageServerImpl implements MageServer {
|
|||
user.showUserMessage("Create tournament", message);
|
||||
throw new MageException("No message");
|
||||
}
|
||||
// check if the user satisfies the minimumRating requirement.
|
||||
int minimumRating = options.getMinimumRating();
|
||||
int userRating;
|
||||
if (options.getMatchOptions().isLimited()) {
|
||||
userRating = user.getUserData().getLimitedRating();
|
||||
} else {
|
||||
userRating = user.getUserData().getConstructedRating();
|
||||
}
|
||||
if (userRating < minimumRating) {
|
||||
String message = new StringBuilder("Your rating ").append(userRating)
|
||||
.append(" is lower than the table requirement ").append(minimumRating).toString();
|
||||
user.showUserMessage("Create tournament", message);
|
||||
throw new MageException("No message");
|
||||
}
|
||||
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||
if (!room.isPresent()) {
|
||||
|
||||
|
|
@ -1386,7 +1400,19 @@ public class MageServerImpl implements MageServer {
|
|||
user.showUserMessage("Create table", "Your quit ratio " + user.getMatchQuitRatio() + "% is higher than the table requirement " + quitRatio + '%');
|
||||
throw new MageException("No message");
|
||||
}
|
||||
|
||||
// check if the user satisfies the minimumRating requirement.
|
||||
int minimumRating = options.getMinimumRating();
|
||||
int userRating;
|
||||
if (options.isLimited()) {
|
||||
userRating = user.getUserData().getLimitedRating();
|
||||
} else {
|
||||
userRating = user.getUserData().getConstructedRating();
|
||||
}
|
||||
if (userRating < minimumRating) {
|
||||
String message = new StringBuilder("Your rating ").append(userRating).append(" is lower than the table requirement ").append(minimumRating).toString();
|
||||
user.showUserMessage("Create table", message);
|
||||
throw new MageException("No message");
|
||||
}
|
||||
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||
if (room.isPresent()) {
|
||||
TableView table = room.get().createTable(userId, options);
|
||||
|
|
|
|||
|
|
@ -172,6 +172,21 @@ public class TableController {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check minimum rating.
|
||||
int minimumRating = table.getTournament().getOptions().getMinimumRating();
|
||||
int userRating;
|
||||
if (table.getTournament().getOptions().getMatchOptions().isLimited()) {
|
||||
userRating = user.getUserData().getLimitedRating();
|
||||
} else {
|
||||
userRating = user.getUserData().getConstructedRating();
|
||||
}
|
||||
if (userRating < minimumRating) {
|
||||
String message = new StringBuilder("Your rating ").append(userRating)
|
||||
.append(" is lower than the table requirement ").append(minimumRating).toString();
|
||||
user.showUserMessage("Join Table", message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<Player> playerOptional = createPlayer(name, seat.getPlayerType(), skill);
|
||||
if (playerOptional.isPresent()) {
|
||||
Player player = playerOptional.get();
|
||||
|
|
@ -272,6 +287,21 @@ public class TableController {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check minimum rating.
|
||||
int minimumRating = table.getMatch().getOptions().getMinimumRating();
|
||||
int userRating;
|
||||
if (table.getMatch().getOptions().isLimited()) {
|
||||
userRating = user.getUserData().getLimitedRating();
|
||||
} else {
|
||||
userRating = user.getUserData().getConstructedRating();
|
||||
}
|
||||
if (userRating < minimumRating) {
|
||||
String message = new StringBuilder("Your rating ").append(userRating)
|
||||
.append(" is lower than the table requirement ").append(minimumRating).toString();
|
||||
user.showUserMessage("Join Table", message);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check power level for table (currently only used for EDH/Commander table)
|
||||
int edhPowerLevel = table.getMatch().getOptions().getEdhPowerLevel();
|
||||
if (edhPowerLevel > 0 && table.getValidator().getName().toLowerCase(Locale.ENGLISH).equals("commander")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue