Пример #1
0
  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;
  }
Пример #2
0
 private boolean checkWager(Duel d) {
   Double wager = (Double) d.getDuelOptionValue(DuelOption.MONEY);
   if (wager == null) return true;
   HashSet<ArenaPlayer> players = new HashSet<ArenaPlayer>(d.getChallengedPlayers());
   players.addAll(d.getChallengerTeam().getPlayers());
   for (ArenaPlayer ap : players) {
     if (MoneyController.balance(ap.getName()) < wager) {
       MessageUtil.sendMessage(ap, "&4[Duel] &cYou don't have enough money to accept the wager!");
       cancelFormingDuel(
           d, "&4[Duel]&6" + ap.getDisplayName() + " didn't have enough money for the wager");
       return false;
     }
   }
   for (ArenaPlayer ap : players) {
     MessageUtil.sendMessage(
         ap,
         "&4[Duel] &6"
             + wager
             + " "
             + Defaults.MONEY_STR
             + "&e has been subtracted from your account");
     MoneyController.subtract(ap.getName(), wager);
   }
   d.setTotalMoney((wager) * players.size());
   return true;
 }
Пример #3
0
 public void cancelFormingDuel(Duel d, String msg) {
   formingDuels.remove(d);
   Collection<ArenaPlayer> players = d.getChallengedPlayers();
   for (ArenaPlayer p : players) {
     MessageUtil.sendMessage(p, msg);
   }
   ArenaTeam t = d.getChallengerTeam();
   t.sendMessage(msg);
 }