Class Player

All Implemented Interfaces:
Serializable, ITurnOrdered

public final class Player extends TurnOrdered
Represents a player in the game.

Note that Player should be usable for any type of game (TW, AS, BF, SBF) and therefore should not make any direct use of Game, Entity, AlphaStrikeElement etc., instead using IGame and InGameObject if necessary. Note that two Players are equal if their ID is equal.

See Also:
  • Field Details

  • Constructor Details

    • Player

      public Player(int id, String name)
  • Method Details

    • getMinefields

      public Vector<Minefield> getMinefields()
    • addMinefield

      public void addMinefield(Minefield mf)
    • addMinefields

      public void addMinefields(Vector<Minefield> minefields)
    • removeMinefield

      public void removeMinefield(Minefield mf)
    • removeMinefields

      public void removeMinefields()
    • removeArtyAutoHitHexes

      public void removeArtyAutoHitHexes()
    • containsMinefield

      public boolean containsMinefield(Minefield mf)
    • hasMinefields

      public boolean hasMinefields()
    • setNbrMFConventional

      public void setNbrMFConventional(int nbrMF)
    • setNbrMFCommand

      public void setNbrMFCommand(int nbrMF)
    • setNbrMFVibra

      public void setNbrMFVibra(int nbrMF)
    • setNbrMFActive

      public void setNbrMFActive(int nbrMF)
    • setNbrMFInferno

      public void setNbrMFInferno(int nbrMF)
    • getNbrMFConventional

      public int getNbrMFConventional()
    • getNbrMFCommand

      public int getNbrMFCommand()
    • getNbrMFVibra

      public int getNbrMFVibra()
    • getNbrMFActive

      public int getNbrMFActive()
    • getNbrMFInferno

      public int getNbrMFInferno()
    • setNbrMFEMP

      public void setNbrMFEMP(int nbrMF)
    • getNbrMFEMP

      public int getNbrMFEMP()
    • getCamouflage

      public Camouflage getCamouflage()
    • setCamouflage

      public void setCamouflage(Camouflage camouflage)
    • setGame

      public void setGame(IGame game)
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getEmail

      public String getEmail()
    • setEmail

      public void setEmail(String email)
    • getId

      public int getId()
    • getTeam

      public int getTeam()
    • setTeam

      public void setTeam(int team)
    • isDone

      public boolean isDone()
    • setDone

      public void setDone(boolean done)
    • isGhost

      public boolean isGhost()
    • setGhost

      public void setGhost(boolean ghost)
    • isBot

      public boolean isBot()
      Returns:
      true if this player connected as a bot.
    • setBot

      public void setBot(boolean bot)
      Sets whether this player connected as a bot.
    • isGameMasterPermitted

      public boolean isGameMasterPermitted()
      Returns:
      true if this player may become a Game Master. Any human may be a GM
    • isGameMaster

      public boolean isGameMaster()
      Returns:
      true if gameMaster flag is true and isGameMasterPermitted()
    • getGameMaster

      public boolean getGameMaster()
      If you are checking to see this player is a Game Master, use isGameMaster() instead
      Returns:
      the value of gameMaster flag, without checking if it is permitted.
    • setGameMaster

      public void setGameMaster(boolean gameMaster)
      sets gameMaster but this only allows GM status if other conditions permits it. see isGameMaster()
    • isObserver

      public boolean isObserver()
      Returns:
      true if observer flag is true and not in VICTORY phase
    • isNotObserver

      public boolean isNotObserver()
      Returns:
      true if this Player is not considered an observer.
      See Also:
    • setSeeAll

      public void setSeeAll(boolean seeAll)
      sets seeAll. This will only enable seeAll if other conditions allow it. see canIgnoreDoubleBlind()
    • getSeeAll

      public boolean getSeeAll()
      If you are checking to see if double-blind applies to this player, use canIgnoreDoubleBlind()
      Returns:
      the value of seeAll flag, without checking if it is permitted
    • canSeeAll

      public boolean canSeeAll()
      If you are checking to see if double-blind applies to this player, use canIgnoreDoubleBlind()
      Returns:
      true if seeAll is true and is permitted
    • isSeeAllPermitted

      public boolean isSeeAllPermitted()
      If you are checking to see if double-blind applies to this player, use canIgnoreDoubleBlind()
      Returns:
      true if player is allowed use seeAll
    • setObserver

      public void setObserver(boolean observer)
      set the observer flag. Observers have no units add no team
    • setSingleBlind

      public void setSingleBlind(boolean singleBlind)
      sets seeAll. This will only enable seeAll if other conditions allow it. see canIgnoreDoubleBlind()
    • getSingleBlind

      public boolean getSingleBlind()
      If you are checking to see this player can ignore double-blind, use canIgnoreDoubleBlind() instead
      Returns:
      the value of singleBlind flag, without checking if it is permitted.
    • canSeeSingleBlind

      public boolean canSeeSingleBlind()
      Returns:
      true if singleBlind flag is true and isSingleBlindPermitted()
    • isSingleBlindPermitted

      public boolean isSingleBlindPermitted()
      If you are checking to see if double-blind applies to this player, use canIgnoreDoubleBlind()
      Returns:
      true if player is allowed use single blind (bots only)
    • canIgnoreDoubleBlind

      public boolean canIgnoreDoubleBlind()
      Double-blind uses Line-of-sight to determine which units are displayed on the board and in reports. seeAll and singleBlind flags allow this to be ignored, granting a view of the entire map and units.
      Returns:
      true if this player ignores the double-blind setting.
    • getColour

      public PlayerColour getColour()
    • setColour

      public void setColour(PlayerColour colour)
    • getStartingPos

      public int getStartingPos()
    • setStartingPos

      public void setStartingPos(int startingPos)
    • getStartOffset

      public int getStartOffset()
    • setStartOffset

      public void setStartOffset(int startOffset)
    • getStartWidth

      public int getStartWidth()
    • setStartWidth

      public void setStartWidth(int startWidth)
    • getStartingAnyNWx

      public int getStartingAnyNWx()
    • setStartingAnyNWx

      public void setStartingAnyNWx(int i)
    • getStartingAnyNWy

      public int getStartingAnyNWy()
    • setStartingAnyNWy

      public void setStartingAnyNWy(int i)
    • getStartingAnySEx

      public int getStartingAnySEx()
    • setStartingAnySEx

      public void setStartingAnySEx(int i)
    • getStartingAnySEy

      public int getStartingAnySEy()
    • setStartingAnySEy

      public void setStartingAnySEy(int i)
    • adjustStartingPosForReinforcements

      public void adjustStartingPosForReinforcements()
      Set deployment zone to edge of board for reinforcements
    • isEnemyOf

      public boolean isEnemyOf(Player other)
    • setAdmitsDefeat

      public void setAdmitsDefeat(boolean admitsDefeat)
    • admitsDefeat

      public boolean admitsDefeat()
    • doesNotAdmitDefeat

      public boolean doesNotAdmitDefeat()
    • getGroundObjectsToPlace

      public List<ICarryable> getGroundObjectsToPlace()
      Collection of carryable objects that this player will be placing during the game.
    • setGroundObjectsToPlace

      public void setGroundObjectsToPlace(List<ICarryable> groundObjectsToPlace)
      Present for serialization purposes only
    • setVotedToAllowTeamChange

      public void setVotedToAllowTeamChange(boolean allowChange)
    • getVotedToAllowTeamChange

      public boolean getVotedToAllowTeamChange()
    • setVotedToAllowGameMaster

      public void setVotedToAllowGameMaster(boolean allowChange)
    • getVotedToAllowGameMaster

      public boolean getVotedToAllowGameMaster()
    • setArtyAutoHitHexes

      public void setArtyAutoHitHexes(List<BoardLocation> newArtyAutoHitHexes)
    • getArtyAutoHitHexes

      public List<BoardLocation> getArtyAutoHitHexes()
    • addArtyAutoHitHex

      public void addArtyAutoHitHex(BoardLocation boardLocation)
    • removeArtyAutoHitHex

      public void removeArtyAutoHitHex(BoardLocation boardLocation)
    • getInitialEntityCount

      public int getInitialEntityCount()
    • setInitialEntityCount

      public void setInitialEntityCount(int initialEntityCount)
    • changeInitialEntityCount

      public void changeInitialEntityCount(int initialEntityCountChange)
    • getBV

      public int getBV()
      Returns the combined strength (Battle Value/PV) of all the player's usable assets. This includes only units that should count according to InGameObject.countForStrengthSum().
      Returns:
      The combined strength (BV/PV) of all the player's assets
    • isMyUnit

      public boolean isMyUnit(InGameObject unit)
      Returns true when the given unit belongs to this Player.
      Parameters:
      unit - The unit
      Returns:
      True when the unit belongs to "me", this Player
    • getInitialBV

      public int getInitialBV()
    • setInitialBV

      public void setInitialBV(int initialBV)
    • changeInitialBV

      public void changeInitialBV(int initialBVChange)
    • setInitCompensationBonus

      public void setInitCompensationBonus(int newBonus)
      Specified by:
      setInitCompensationBonus in interface ITurnOrdered
      Overrides:
      setInitCompensationBonus in class TurnOrdered
    • getInitCompensationBonus

      public int getInitCompensationBonus()
      Specified by:
      getInitCompensationBonus in interface ITurnOrdered
      Overrides:
      getInitCompensationBonus in class TurnOrdered
    • setConstantInitBonus

      public void setConstantInitBonus(int b)
    • getConstantInitBonus

      public int getConstantInitBonus()
    • getTurnInitBonus

      public int getTurnInitBonus()
      Returns:
      the bonus to this player's initiative rolls granted by his units
    • getHQInitBonus

      public int getHQInitBonus()
      Returns:
      the best HQ initiative bonus from this player's units (TacOps Mobile HQs option)
    • getQuirkInitBonus

      public int getQuirkInitBonus()
      Returns:
      the best quirk initiative bonus from this player's units
    • getQuirkInitBonusName

      public String getQuirkInitBonusName()
      Returns:
      the name of the quirk providing the best initiative bonus, or null if none
    • getCommandConsoleBonus

      public int getCommandConsoleBonus()
      Returns:
      the best command console/tech officer initiative bonus from this player's units (+2)
    • getCrewCommandBonus

      public int getCrewCommandBonus()
      Returns:
      the best crew command skill initiative bonus from this player's units (RPG option)
    • getOverallCommandBonus

      public int getOverallCommandBonus()
      Returns:
      the bonus to this player's initiative rolls for the highest value initiative (i.e. the 'commander')
    • getIndividualCommandBonus

      public int getIndividualCommandBonus(Entity entity, boolean useCommandInit)
      Calculate command bonus for an individual entity within the player's force or team TODO: move all of this into Entity
      Parameters:
      entity - being considered
      useCommandInit - boolean based on game options
    • getTCPInitBonus

      public int getTCPInitBonus()
      Calculate the Triple-Core Processor initiative bonus for this player's force. Per IO pg 81, a TCP-implanted warrior with VDNI/BVDNI provides: - +2 base initiative bonus - +1 additional if unit has CCM, C3/C3i, or >3 tons communications equipment - -1 if unit is shutdown or ECM-affected (unless unit has own ECM for counter-ECM)
      Returns:
      The TCP initiative bonus from the best qualifying entity
    • getColorForPlayer

      public String getColorForPlayer()
    • getColoredPlayerNameWithTeam

      public String getColoredPlayerNameWithTeam()
    • redactPrivateData

      public void redactPrivateData()
      Clears any data from this Player that should not be transmitted to other players from the server, such as email addresses. Note that this changes this Player's data permanently and should typically be done to a copy of the player, see copy().
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object object)
      Two players are equal if their ids are equal
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • copy

      public Player copy()
    • getFleeZone

      public HexArea getFleeZone()
      Returns:
      The area of the board this player's units are allowed to flee from; An empty area as return value means they may not flee at all.
    • setFleeZone

      public void setFleeZone(HexArea fleeArea)
      Sets the board area this player's units may flee from. The area may be empty, in which case the units may not flee.
      Parameters:
      fleeArea - The new flee area.
      See Also: