public Duel accept(ArenaPlayer player) { Duel d = getChallengedDuel(player); if (d != null) { d.accept(player); if (d.isReady()) { /// Do a final check to see if they have completed all the duel options if (!checkWager(d)) return null; ArenaTeam t = d.getChallengerTeam(); ArenaTeam t2 = d.makeChallengedTeam(); List<ArenaTeam> teams = new ArrayList<ArenaTeam>(); teams.add(t); teams.add(t2); JoinOptions jo = new JoinOptions(); jo.setMatchParams(d.getMatchParams()); jo.setJoinLocation(player.getLocation()); if (d.getOptions().hasOption(DuelOption.ARENA)) { jo.setArena((Arena) d.getOptions().getOptionValue(DuelOption.ARENA)); } Matchup m = new Matchup(d.getMatchParams(), teams, jo); m.addArenaListener(this); formingDuels.remove(d); ongoingDuels.put(m, d); MatchTeamQObject mo = new MatchTeamQObject(m); BattleArena.getBAController().addMatchup(mo); } } return d; }
private void makePreliminaryRound() { Matchup m; round++; Round tr = new Round(round); rounds.add(tr); int nrounds = getNRounds(teams.size()) + 1; int minTeams = eventParams.getMinTeams(); final int needed_size = (int) Math.pow(minTeams, nrounds - 1); final int nprelims = (aliveTeams.size() - needed_size) / (minTeams - 1); int loffset = needed_size - 1; int hoffset = needed_size; for (int i = 0; i < nprelims; i++) { List<Team> newTeams = new ArrayList<Team>(); for (int j = 0; j < minTeams / 2; j++) { newTeams.add(aliveTeams.get(loffset)); newTeams.add(aliveTeams.get(hoffset)); loffset--; hoffset++; } m = new Matchup(eventParams, newTeams); m.addArenaListener(this); tr.addMatchup(m); } }
private void makeNextRound() { Matchup m; round++; Round tr = new Round(round); rounds.add(tr); int minTeams = eventParams.getMinTeams(); int size = aliveTeams.size(); final int nMatches = size / minTeams; for (int i = 0; i < nMatches; i++) { List<Team> newTeams = new ArrayList<Team>(); for (int j = 0; j < minTeams / 2; j++) { int index = i + j * nMatches; newTeams.add(aliveTeams.get(index)); newTeams.add(aliveTeams.get(size - 1 - index)); } m = new Matchup(eventParams, newTeams); m.addArenaListener(this); tr.addMatchup(m); } }