@Override public void startGame() throws GameException { TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), 20); // Sets a start message about the match score game.setStartMessage(this.createGameStartMessage()); initGame(game); games.add(game); }
@Override public void startGame() throws GameException { int startLife = 40; boolean alsoHand = true; if (options.getDeckType().equals("Variant Magic - Duel Commander")) { startLife = 30; alsoHand = true; // commander going to hand allowed to go to command zone effective July 17, 2015 } CommanderFreeForAll game = new CommanderFreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife); game.setStartMessage(this.createGameStartMessage()); game.setAlsoHand(alsoHand); game.setAlsoLibrary(true); initGame(game); games.add(game); }
public TableController(UUID roomId, UUID userId, MatchOptions options) { this.userId = userId; this.options = options; match = GameFactory.instance.createMatch(options.getGameType(), options); if (userId != null) { Optional<User> user = UserManager.instance.getUser(userId); // TODO: Handle if user == null controllerName = user.map(User::getName).orElse("undefined"); } else { controllerName = "System"; } table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, match, options.getBannedUsers(), options.isPlaneChase()); chatId = ChatManager.instance.createChatSession("Match Table " + table.getId()); init(); }
versionStr = "2"; PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, options.getName()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, options.getPassword()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE + versionStr, options.getDeckType()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT + versionStr, Integer.toString(options.getPriorityTime())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE + versionStr, options.getGameType()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, Integer.toString(options.getWinsNeeded())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, options.isRollbackTurnsAllowed() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, options.isRated() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(options.getFreeMulligans())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, deckFile); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS + versionStr, spnNumPlayers.getValue().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, options.isPlaneChase() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_MINIMUM_RATING + versionStr, Integer.toString(options.getMinimumRating())); StringBuilder playerTypesString = new StringBuilder(); for (Object player : players) {
if (table.getMatch().getGames().isEmpty()) { addInfo.append("Wins:").append(table.getMatch().getWinsNeeded()); addInfo.append(" Time: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString()); if (table.getMatch().getFreeMulligans() > 0) { addInfo.append(" Free Mul.: ").append(table.getMatch().getFreeMulligans()); addInfo.append(" Rng: ").append(table.getMatch().getOptions().getRange().toString()); this.skillLevel = table.getMatch().getOptions().getSkillLevel(); this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio()); this.minimumRating = Integer.toString(table.getMatch().getOptions().getMinimumRating()); this.limited = table.getMatch().getOptions().isLimited(); this.rated = table.getMatch().getOptions().isRated(); this.passworded = !table.getMatch().getOptions().getPassword().isEmpty(); this.spectatorsAllowed = table.getMatch().getOptions().isSpectatorsAllowed(); } else { StringBuilder infoText = new StringBuilder(); StringBuilder stateText = new StringBuilder(table.getState().toString()); infoText.append("Wins:").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded()); infoText.append(" Seats: ").append(this.seatsInfo); switch (table.getState()) { case READY_TO_START: case STARTING: infoText.append(" Time: ").append(table.getTournament().getOptions().getMatchOptions().getMatchTimeLimit().toString()); if (table.getTournament().getOptions().getMatchOptions().getFreeMulligans() > 0) { infoText.append(" Fr.Mul: ").append(table.getTournament().getOptions().getMatchOptions().getFreeMulligans());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT + versionStr, Integer.toString(tOptions.getMatchOptions().getPriorityTime())); if (this.spnConstructTime.isVisible()) { PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME + versionStr, Integer.toString(tOptions.getLimitedOptions().getConstructionTime())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(tOptions.getMatchOptions().getFreeMulligans())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS + versionStr, Integer.toString(tOptions.getMatchOptions().getWinsNeeded())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO + versionStr, Integer.toString(tOptions.getQuitRatio())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_MINIMUM_RATING + versionStr, Integer.toString(tOptions.getMinimumRating())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS + versionStr, (tOptions.getMatchOptions().isRollbackTurnsAllowed() ? "Yes" : "No")); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED + versionStr, (tOptions.getMatchOptions().isRated() ? "Yes" : "No"));
protected String createGameStartMessage() { StringBuilder sb = new StringBuilder(); sb.append("<br/><b>Match score:</b><br/>"); for (MatchPlayer mp : this.getPlayers()) { sb.append(" ").append(mp.getPlayer().getLogName()); sb.append(" - ").append(mp.getWins()).append(mp.getWins() == 1 ? " win" : " wins"); if (mp.hasQuit()) { sb.append(" QUITTED"); } sb.append("<br/>"); if (mp.getDeck() != null) { sb.append("DeckHash: ").append(mp.getDeck().getDeckHashCode()).append("<br/>"); } } if (getDraws() > 0) { sb.append(" Draws: ").append(getDraws()).append("<br/>"); } if (options.getRange() != null) { sb.append(" Range: ").append(options.getRange().toString()).append("<br/>"); } sb.append("<br/>").append("Match is ").append(this.getOptions().isRated() ? "" : "not ").append("rated<br/>"); sb.append("You have to win ").append(this.getWinsNeeded()).append(this.getWinsNeeded() == 1 ? " game" : " games").append(" to win the complete match<br/>"); sb.append("<br/>Game has started<br/><br/>"); return sb.toString(); }
@Override public int getFreeMulligans() { return options.getFreeMulligans(); }
private Optional<Player> createPlayer(String name, PlayerType playerType, int skill) { Optional<Player> playerOpt; if (options == null) { playerOpt = PlayerFactory.instance.createPlayer(playerType, name, RangeOfInfluence.ALL, skill); } else { playerOpt = PlayerFactory.instance.createPlayer(playerType, name, options.getRange(), skill); } if (playerOpt.isPresent()) { Player player = playerOpt.get(); logger.trace("Player " + player.getName() + " created id: " + player.getId()); } return playerOpt; }
@Override public MatchProto toProto() { MatchProto.Builder builder = MatchProto.newBuilder() .setName(this.getName()) .setGameType(this.getOptions().getGameType()) .setDeckType(this.getOptions().getDeckType()) .setGames(this.getNumGames()) .setDraws(this.getDraws()) .setMatchOptions(this.getOptions().toProto()) .setEndTimeMs((this.getEndTime() != null ? this.getEndTime() : new Date()).getTime()); for (MatchPlayer matchPlayer : this.getPlayers()) { MatchQuitStatus status = !matchPlayer.hasQuit() ? MatchQuitStatus.NO_MATCH_QUIT : matchPlayer.getPlayer().hasTimerTimeout() ? MatchQuitStatus.TIMER_TIMEOUT : matchPlayer.getPlayer().hasIdleTimeout() ? MatchQuitStatus.IDLE_TIMEOUT : MatchQuitStatus.QUIT; builder.addPlayersBuilder() .setName(matchPlayer.getName()) .setHuman(matchPlayer.getPlayer().isHuman()) .setQuit(status) .setWins(matchPlayer.getWins()); } return builder.build(); }
switch (options.getDeckType()) { case "Variant Magic - Commander": case "Variant Magic - Duel Commander": case "Variant Magic - MTGO 1v1 Commander": if (!options.getGameType().startsWith("Commander")) { JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Commander needs also a Commander game type", "Error", JOptionPane.ERROR_MESSAGE); return false; case "Variant Magic - Brawl": case "Variant Magic - Duel Brawl": if (!options.getGameType().startsWith("Brawl")) { JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Brawl needs also a Brawl game type", "Error", JOptionPane.ERROR_MESSAGE); return false; if (!options.getGameType().startsWith("Tiny Leaders")) { JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Tiny Leaders needs also a Tiny Leaders game type", "Error", JOptionPane.ERROR_MESSAGE); return false; if (!options.getGameType().startsWith("Momir Basic")) { JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Momir Basic needs also a Momir Basic game type", "Error", JOptionPane.ERROR_MESSAGE); return false; switch (options.getGameType()) { case "Commander Two Player Duel": case "Commander Free For All": if (!options.getDeckType().equals("Variant Magic - Commander") && !options.getDeckType().equals("Variant Magic - Duel Commander") && !options.getDeckType().equals("Variant Magic - MTGO 1v1 Commander")) { JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Commander needs also a Commander game type", "Error", JOptionPane.ERROR_MESSAGE);
this.matchId = match.getId(); this.matchName = match.getName(); this.gameType = match.getOptions().getGameType(); this.deckType = match.getOptions().getDeckType() + " [" + table.getName() + ']'; } else { this.deckType = match.getOptions().getDeckType(); this.endTime = match.getEndTime(); this.replayAvailable = match.isReplayAvailable(); this.rated = match.getOptions().isRated();
if (!table.getMatch().getOptions().getPassword().isEmpty() && playerType == PlayerType.HUMAN) { if (!table.getMatch().getOptions().getPassword().equals(password)) { user.showUserMessage("Join Table", "Wrong password."); return false; int quitRatio = table.getMatch().getOptions().getQuitRatio(); if (quitRatio < user.getMatchQuitRatio()) { String message = new StringBuilder("Your quit ratio ").append(user.getMatchQuitRatio()) int minimumRating = table.getMatch().getOptions().getMinimumRating(); int userRating; if (table.getMatch().getOptions().isLimited()) { userRating = user.getUserData().getLimitedRating(); } else { int edhPowerLevel = table.getMatch().getOptions().getEdhPowerLevel(); if (edhPowerLevel > 0 && table.getValidator().getName().toLowerCase(Locale.ENGLISH).equals("commander")) { int deckEdhPowerLevel = table.getValidator().getEdhPowerLevel(deck);
int quitRatio = options.getQuitRatio(); if (quitRatio < user.getMatchQuitRatio()) { user.showUserMessage("Create table", "Your quit ratio " + user.getMatchQuitRatio() + "% is higher than the table requirement " + quitRatio + '%'); int minimumRating = options.getMinimumRating(); int userRating; if (options.isLimited()) { userRating = user.getUserData().getLimitedRating(); } else {
public TableController(UUID roomId, UUID userId, TournamentOptions options) { this.userId = userId; tournament = TournamentFactory.instance.createTournament(options.getTournamentType(), options); if (userId != null) { Optional<User> user = UserManager.instance.getUser(userId); if (!user.isPresent()) { logger.fatal(new StringBuilder("User for userId ").append(userId).append(" could not be retrieved from UserManager").toString()); controllerName = "[unknown]"; } else { controllerName = user.get().getName(); } } else { controllerName = "System"; } table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, tournament, options.getMatchOptions().getBannedUsers(), options.isPlaneChase()); chatId = ChatManager.instance.createChatSession("Tourn. table " + table.getId()); }
public TournamentView(Tournament tournament) { tournamentName = tournament.getOptions().getName(); StringBuilder typeText = new StringBuilder(tournament.getOptions().getTournamentType()); if (!tournament.getTournamentType().isLimited()) { typeText.append(" / ").append(tournament.getOptions().getMatchOptions().getDeckType()); } if (tournament.getNumberRounds() > 0) { typeText.append(' ').append(tournament.getNumberRounds()).append(" rounds"); } tournamentType = typeText.toString(); startTime = tournament.getStartTime(); endTime = tournament.getEndTime(); stepStartTime = tournament.getStepStartTime(); constructionTime = tournament.getOptions().getLimitedOptions().getConstructionTime(); watchingAllowed = tournament.getOptions().isWatchingAllowed(); serverTime = new Date(); tournamentState = tournament.getTournamentState(); if (tournament.getTournamentState().equals("Drafting") && tournament.getDraft() != null) { runningInfo = "booster/card: " + tournament.getDraft().getBoosterNum() + '/' + (tournament.getDraft().getCardNum() -1); } else { runningInfo = ""; } for (TournamentPlayer player: tournament.getPlayers()) { players.add(new TournamentPlayerView(player)); } Collections.sort(players); for (Round round: tournament.getRounds()) { rounds.add(new RoundView(round)); } }
MatchProto.Builder matchBuilder = roundBuilder.addMatchesBuilder() .setName(match.getName()) .setGameType(match.getOptions().getGameType()) .setDeckType(match.getOptions().getDeckType()) .setGames(match.getNumGames()) .setDraws(match.getDraws()) .addPlayers(matchToProto(match, pair.getPlayer1())) .addPlayers(matchToProto(match, pair.getPlayer2())) .setMatchOptions(match.getOptions().toProto()) .setEndTimeMs((match.getEndTime() != null ? match.getEndTime() : new Date()).getTime());
public synchronized void startMatch() { if (table.getState() == TableState.STARTING) { try { if (table.isTournamentSubTable()) { logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId()); } else { UserManager.instance.getUser(userId).ifPresent(user -> { logger.info("MATCH started [" + match.getName() + "] " + match.getId() + '(' + user.getName() + ')'); logger.debug("- " + match.getOptions().getGameType() + " - " + match.getOptions().getDeckType()); }); } match.startMatch(); startGame(null); } catch (GameException ex) { logger.fatal("Error starting match ", ex); match.endGame(); } } }
@Override public void startGame() throws GameException { int startLife = 20; CanadianHighlanderDuel game = new CanadianHighlanderDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife); game.setStartMessage(this.createGameStartMessage()); initGame(game); games.add(game); }
@Override public void startGame() throws GameException { int startLife = 40; boolean alsoHand = true; if (options.getDeckType().equals("Variant Magic - Duel Penny Dreadful Commander")) { startLife = 30; alsoHand = true; // commander going to hand allowed to go to command zone effective July 17, 2015 } PennyDreadfulCommanderFreeForAll game = new PennyDreadfulCommanderFreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife); game.setStartMessage(this.createGameStartMessage()); game.setAlsoHand(alsoHand); game.setAlsoLibrary(true); initGame(game); games.add(game); }