Class PlayerVsPlayerChallengeManager

java.lang.Object
games.stendhal.server.core.rp.pvp.PlayerVsPlayerChallengeManager
All Implemented Interfaces:
LogoutListener, TurnListener

public class PlayerVsPlayerChallengeManager extends Object implements TurnListener, LogoutListener
The PlayerVsPlayerChallengeManager stores, expires and creates PvP duels to allow two players to fight with each other
Author:
markus
  • Field Details

    • TIMEOUT_FOR_ACCEPTANCE

      protected static final int TIMEOUT_FOR_ACCEPTANCE
      See Also:
      Constant Field Values
  • Method Details

    • create

      public static PlayerVsPlayerChallengeManager create()
    • createChallenge

      public void createChallenge(Player challenger, Player challenged, int currentTurn)
      Create a new challenge between two players if not yet existing.
      Parameters:
      challenger -
      challenged -
      currentTurn -
    • accpetChallenge

      public void accpetChallenge(Player challenger, Player challenged, int currentTurn)
      Mark the challenge between challenger and challenged as accepted
      Parameters:
      challenger -
      challenged -
      currentTurn -
    • getOpenChallengeForPlayers

      protected PlayerVsPlayerChallenge getOpenChallengeForPlayers(Player challenger, Player challenged)
      Finds an open challenge for the given pair of players if existing
      Parameters:
      challenger -
      challenged -
      Returns:
      a currently open challenge object or null
    • onTurnReached

      public void onTurnReached(int currentTurn)
      Description copied from interface: TurnListener
      This method is called when the turn number is reached.
      Specified by:
      onTurnReached in interface TurnListener
      Parameters:
      currentTurn - current turn number
    • timeOutCurrentChallenges

      public void timeOutCurrentChallenges(int currentTurn)
      Filters out challenges that have to time out at the given turn
      Parameters:
      currentTurn -
    • onLoggedOut

      public void onLoggedOut(Player player)
      Remove player's current challenges on log out
      Specified by:
      onLoggedOut in interface LogoutListener
      Parameters:
      player - The player having logged out.
    • playersHaveActiveChallenge

      public boolean playersHaveActiveChallenge(Player attacker, Player victim)