Ejemplo n.º 1
0
  /**
   * Handles the event of a player warping.
   *
   * @param pos boolean
   */
  public void handleWarp(boolean pos) {
    if (status == WARPING || status == RETURN) return;

    setStatus(WARPING);

    long now = System.currentTimeMillis();

    if ((now - lastFoul > 500) && (team.game.state == DuelGame.IN_PROGRESS)) stats.handleWarp();

    if (stats.getStat(StatType.WARPS) < 5 && team.game.state == DuelGame.IN_PROGRESS) {
      if (now - lastFoul > 500)
        if (pos)
          ba.sendPrivateMessage(
              name, "Warping is illegal in this league and if you warp again, you will forfeit.");
        else
          ba.sendPrivateMessage(
              name,
              "Changing freq or ship is illegal in this league and if you do this again, you will forfeit.");

      // BACKTRACK
      team.warpWarper(this);
    } else if (team.game.state != DuelGame.IN_PROGRESS)
      // BACKTRACK
      team.warpToSafe(this);
    else {
      ba.sendPrivateMessage(name, "You have forfeited due to warp abuse.");
      remove(WARPS);
    }

    lastFoul = now;
  }
Ejemplo n.º 2
0
  public void handleDeath(String killerName) {
    if (team == null) return;

    setStatus(WARPING);
    long now = System.currentTimeMillis();
    DuelPlayer killer = bot.players.get(killerName.toLowerCase());

    team.warpToSafe(this);

    // DoubleKill check - remember to add a timer in case its the last death
    if ((killer != null)
        && (killer.getTimeFromLastDeath() < 2001)
        && (name.equalsIgnoreCase(killer.getLastKiller()))) {
      ba.sendSmartPrivateMessage(name, "Double kill, doesn't count.");
      ba.sendSmartPrivateMessage(killerName, "Double kill, doesn't count.");
      killer.removeDeath();
      killer.sendDeaths();
      stats.decrementStat(StatType.KILLS);
    } else if (!team.checkTeamKill(name, killerName)) {
      if ((now - lastDeath) < ((d_spawnTime + d_deathTime) * 1000)) {
        ba.sendPrivateMessage(name, "Spawn Kill, doesn't count.");
        killer.handleSpawnKill();
      } else {
        stats.handleDeath();
        killer.addKill();
      }
    } else if (team.checkTeamKill(name, killerName)) stats.handleDeath();

    lastDeath = now;
    lastKiller = killerName;

    if (stats.getStat(StatType.DEATHS) >= specAt) {
      setStatus(OUT);
      dying =
          new TimerTask() {
            @Override
            public void run() {
              if (status == OUT) {
                remove(NORMAL);
                cancelTask(spawner);
              }
            }
          };
      ba.scheduleTask(dying, 2000);
    }

    spawner =
        new TimerTask() {
          @Override
          public void run() {
            // BACKTRACK
            if (status == PLAYING) team.warpToSpawn(DuelPlayer.this);
            else if (status == OUT) remove(NORMAL);
          }
        };
    ba.scheduleTask(spawner, d_deathTime * 1000);
    sendDeaths();
    // BACKTRACK
    team.game.updateScore();
  }
Ejemplo n.º 3
0
  /** Called when a player lags out of a game. */
  public void handleLagout() {
    if (team == null) return;

    setStatus(LAGGED);

    if (team.game.state == DuelGame.IN_PROGRESS) stats.handleLagout();

    doPlaytime();

    if (stats.getStat(StatType.LAGOUTS) < d_maxLagouts) {
      ba.sendSmartPrivateMessage(
          name,
          "You have 1 minute to return (!lagout) to your duel or you will forfeit! (!lagout)");
      lagout =
          new TimerTask() {
            @Override
            public void run() {
              bot.laggers.remove(name.toLowerCase());
              ba.sendSmartPrivateMessage(
                  name, "You have forfeited since you have been lagged out for over a minute.");
              remove(LAGOUTS);
              lagout = null;
            }
          };
      ba.scheduleTask(lagout, 60000);
      // BACKTRACK
      bot.laggers.put(name.toLowerCase(), this);
      team.partnerLagout(name);
    } else {
      ba.sendSmartPrivateMessage(name, "You have exceeded the lagout limit and forfeit your duel.");
      remove(LAGOUTS);
    }
  }
Ejemplo n.º 4
0
  /** Handles a player's !lagout command */
  public void doLagout() {
    if (status != LAGGED) {
      ba.sendPrivateMessage(name, "You are not lagged out.");
      return;
    }

    setStatus(RETURN);
    cancelTask(lagout);
    bot.laggers.remove(name.toLowerCase());
    ba.sendPrivateMessage(
        name,
        "You have " + (d_maxLagouts - stats.getStat(StatType.LAGOUTS)) + " lagouts remaining.");
    lastFoul = System.currentTimeMillis();
    ba.setShip(name, ship);
    ba.setFreq(name, freq);

    if (team != null && team.game != null && team.game.state == DuelGame.IN_PROGRESS) {
      lastSpec = lastFoul;
      team.warpPlayer(this);
    } else if (team != null && team.game != null && team.game.state == DuelGame.SETUP)
      team.warpToSafe(this);
  }
Ejemplo n.º 5
0
  /**
   * Unused.
   *
   * @param p DuelPlayer
   * @deprecated
   */
  public void warpDelay(DuelPlayer p) {
    setStatus(WARPING);
    team.warpToSafe(this);

    spawner =
        new TimerTask() {
          @Override
          public void run() {
            if (status == PLAYING) team.warpPlayer(DuelPlayer.this);
            else if (status == OUT) remove(NORMAL);
          }
        };
    ba.scheduleTask(spawner, d_deathTime * 1000);
  }
Ejemplo n.º 6
0
  /**
   * Removes the player from the duel and reports the reason for it.
   *
   * @param reason int
   */
  public void remove(int reason) {
    ba.specWithoutLock(name);
    ba.setFreq(name, freq);
    endTimePlayed();

    if (lagout != null) {
      cancelTask(lagout);
      bot.laggers.remove(name.toLowerCase());
    }

    if (status == REOUT) {
      setStatus(OUT);
      return;
    }

    out = reason;

    if (stats.getStat(StatType.DEATHS) != specAt) stats.setStat(StatType.DEATHS, specAt);

    setStatus(OUT);
    team.playerOut(this);
  }
Ejemplo n.º 7
0
  public void handleFSC(FrequencyShipChange event) {
    int shipNum = event.getShipType();

    if (status == WARPING
        || ((status == LAGGED || status == OUT) && shipNum == 0)
        || status == RETURN) return;

    int f = event.getFrequency();
    int statusID = status;
    setStatus(WARPING);

    if (statusID == OUT) {
      ba.sendPrivateMessage(
          name, "Please stay in spec and on your freq until your duel is finished.");
      ba.specWithoutLock(name);

      if (freq != f) ba.setFreq(name, freq);

      setStatus(OUT);
      return;
    } else if (statusID == LAGGED) {
      ba.specWithoutLock(name);

      if (freq != f) ba.setFreq(name, freq);

      ba.sendPrivateMessage(name, "Please use !lagout to return to your duel.");
      setStatus(LAGGED);
      return;
    }

    if (team == null) {
      if (shipNum == 4 || shipNum == 6) {
        if (ship != 0) ba.setShip(name, ship);
        else ba.specWithoutLock(name);

        ba.sendPrivateMessage(name, "Invalid ship!");
      } else if (shipNum == 0 && duelFreq > -1 && partner != null) {
        bot.removeChalls(duelFreq);
        duelFreq = -1;
        partner = null;
        ship = shipNum;
      } else if (ship == 0 && shipNum > 0 && !registered) {
        ba.sendPrivateMessage(
            name,
            "NOTICE: You will not be able to play in ranked league duels until you have registered using !signup.");
        ship = shipNum;
      } else ship = shipNum;

      /*  if (bot.freqs.contains(freq)) ba.setFreq(name, freq); else freq =
      freq; */

    } else {

      boolean foul = false;

      if (shipNum == 0 && (statusID == PLAYING)) {
        ba.setFreq(name, freq);
        handleLagout();
        return;
      }

      /* if (freq != freq) { foul = true; ba.setFreq(name, freq); } */

      if ((shipNum != ship) && (team.game.state != DuelGame.SETUP)) {
        foul = true;
        ba.setShip(name, ship);
        ba.specificPrize(name, -13);
      } else if ((team.game.div == 5) && (team.game.state == DuelGame.SETUP)) {
        if (shipNum == 6 || shipNum == 4) ba.setShip(name, ship);
        else ship = shipNum;
      } else if ((shipNum != ship) && (team.game.div != 5) && (team.game.state == DuelGame.SETUP))
        ba.setShip(name, ship);

      if (foul || team.game.state == DuelGame.IN_PROGRESS) {
        setStatus(statusID);
        handleWarp(false);
        return;
      } else team.warpToSafe(this);
    }

    setStatus(statusID);
  }