Package megamek.common
Class Player
java.lang.Object
megamek.common.turns.TurnOrdered
megamek.common.Player
- All Implemented Interfaces:
Serializable,ITurnOrdered
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final String[]static final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArtyAutoHitHex(BoardLocation boardLocation) voidvoidaddMinefields(Vector<Minefield> minefields) voidSet deployment zone to edge of board for reinforcementsbooleanbooleanDouble-blind uses Line-of-sight to determine which units are displayed on the board and in reports.booleanIf you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()booleanvoidchangeInitialBV(int initialBVChange) voidchangeInitialEntityCount(int initialEntityCountChange) booleancopy()booleanbooleanTwo players are equal if their ids are equalintgetBV()Returns the combined strength (Battle Value/PV) of all the player's usable assets.intintintThe colour this player is actually shown in.getEmail()booleanIf you are checking to see this player is a Game Master, useisGameMaster()insteadCollection of carryable objects that this player will be placing during the game.intintgetId()intgetIndividualCommandBonus(Entity entity, boolean useCommandInit) Calculate command bonus for an individual entity within the player's force or team TODO: move all of this into EntityintintintintgetMinefieldCount(int minefieldType) Given a minefield type from one of the TYPE_[MINEFIELDTYPE] constants in Minefield.java returns how many mines of that type this player hasgetName()intintintintintintintintintbooleanIf you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()booleanIf you are checking to see this player can ignore double-blind, usecanIgnoreDoubleBlind()insteadintintintintintintintintintCalculate the Triple-Core Processor initiative bonus for this player's force.intgetTeam()intbooleaninthashCode()booleanbooleanbooleanisBot()booleanisDone()booleanbooleanbooleanbooleanisGhost()booleanisMyUnit(InGameObject unit) Returns true when the given unit belongs to this Player.booleanbooleanbooleanIf you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()booleanIf you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()voidClears any data from this Player that should not be transmitted to other players from the server, such as email addresses.voidremoveArtyAutoHitHex(BoardLocation boardLocation) voidvoidvoidvoidsetAdmitsDefeat(boolean admitsDefeat) voidsetArtilleryRevealAll(boolean artilleryRevealAll) voidsetArtyAutoHitHexes(List<BoardLocation> newArtyAutoHitHexes) voidsetBot(boolean bot) Sets whether this player connected as a bot.voidsetCamouflage(Camouflage camouflage) voidsetColour(PlayerColour colour) voidsetConstantInitBonus(int b) voidsetDone(boolean done) voidvoidsetFleeZone(HexArea fleeArea) Sets the board area this player's units may flee from.voidvoidsetGameMaster(boolean gameMaster) setsgameMasterbut this only allows GM status if other conditions permits it.voidsetGhost(boolean ghost) voidsetGroundObjectsToPlace(List<ICarryable> groundObjectsToPlace) Present for serialization purposes onlyvoidsetInitCompensationBonus(int newBonus) voidsetInitialBV(int initialBV) voidsetInitialEntityCount(int initialEntityCount) voidsetMinefieldCount(int minefieldType, int count) Given a minefield type from one of the TYPE_[MINEFIELDTYPE] constants in Minefield.java and a count (preferably more than 0), set the count of that type of mine for this player.voidvoidsetNbrFortifiedHexes(int nbrFortifiedHexes) voidsetNbrMFActive(int nbrMF) voidsetNbrMFCommand(int nbrMF) voidsetNbrMFConventional(int nbrMF) voidsetNbrMFEMP(int nbrMF) voidsetNbrMFInferno(int nbrMF) voidsetNbrMFVibra(int nbrMF) voidsetObserver(boolean observer) set theobserverflag.voidsetSeeAll(boolean seeAll) setsseeAll.voidsetSingleBlind(boolean singleBlind) setsseeAll.voidsetStartingAnyNWx(int i) voidsetStartingAnyNWy(int i) voidsetStartingAnySEx(int i) voidsetStartingAnySEy(int i) voidsetStartingPos(int startingPos) voidsetStartingVictoryPoints(int startingVictoryPoints) voidsetStartOffset(int startOffset) voidsetStartWidth(int startWidth) voidsetTeam(int team) voidsetVotedToAllowTeamChange(boolean allowChange) toString()Methods inherited from class megamek.common.turns.TurnOrdered
clearInitiative, generateTurnOrder, getAeroTurns, getDropshipTurns, getEvenTurns, getInitiative, getJumpshipTurns, getMultiTurns, getNormalTurns, getOtherTurns, getSmallCraftTurns, getSpaceStationTurns, getTeleMissileTurns, getWarshipTurns, incrementAeroTurns, incrementDropshipTurns, incrementEvenTurns, incrementJumpshipTurns, incrementMultiTurns, incrementOtherTurns, incrementSmallCraftTurns, incrementSpaceStationTurns, incrementTeleMissileTurns, incrementWarshipTurns, resetAeroTurns, resetDropshipTurns, resetEvenTurns, resetInitiativeCompensation, resetJumpshipTurns, resetMultiTurns, resetOtherTurns, resetSmallCraftTurns, resetSpaceStationTurns, resetTeleMissileTurns, resetWarshipTurns, rollInitAndResolveTies, rollInitAndResolveTies, rollInitiative, rollInitiative, setInitiative
-
Field Details
-
PLAYER_NONE
public static final int PLAYER_NONE- See Also:
-
TEAM_NONE
public static final int TEAM_NONE- See Also:
-
TEAM_UNASSIGNED
public static final int TEAM_UNASSIGNED- See Also:
-
TEAM_NAMES
-
-
Constructor Details
-
Player
-
-
Method Details
-
getMinefields
-
addMinefield
-
addMinefields
-
removeMinefield
-
removeMinefields
public void removeMinefields() -
removeArtyAutoHitHexes
public void removeArtyAutoHitHexes() -
containsMinefield
-
hasMinefields
public boolean hasMinefields() -
setMinefieldCount
public void setMinefieldCount(int minefieldType, int count) Given a minefield type from one of the TYPE_[MINEFIELDTYPE] constants in Minefield.java and a count (preferably more than 0), set the count of that type of mine for this player. -
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) -
setNbrMFEMP
public void setNbrMFEMP(int nbrMF) -
getMinefieldCount
public int getMinefieldCount(int minefieldType) Given a minefield type from one of the TYPE_[MINEFIELDTYPE] constants in Minefield.java returns how many mines of that type this player has -
getNbrMFConventional
public int getNbrMFConventional() -
getNbrMFCommand
public int getNbrMFCommand() -
getNbrMFVibra
public int getNbrMFVibra() -
getNbrMFActive
public int getNbrMFActive() -
getNbrMFInferno
public int getNbrMFInferno() -
getNbrMFEMP
public int getNbrMFEMP() -
getNbrFortifiedHexes
public int getNbrFortifiedHexes()- Returns:
- the number of fortified hexes this player may place during the minefield deployment phase (Trench/Fieldworks Engineers, TO:AUE p.153)
-
setNbrFortifiedHexes
public void setNbrFortifiedHexes(int nbrFortifiedHexes) -
getCamouflage
-
setCamouflage
-
setGame
-
getName
-
setName
-
getEmail
-
setEmail
-
getId
public int getId() -
getTeam
public int getTeam() -
setTeam
public void setTeam(int team) -
getTeamName
-
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
gameMasterflag is true andisGameMasterPermitted()
-
getGameMaster
public boolean getGameMaster()If you are checking to see this player is a Game Master, useisGameMaster()instead- Returns:
- the value of gameMaster flag, without checking if it is permitted.
-
setGameMaster
public void setGameMaster(boolean gameMaster) setsgameMasterbut this only allows GM status if other conditions permits it. seeisGameMaster() -
isObserver
public boolean isObserver()- Returns:
- true if
observerflag 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) setsseeAll. This will only enable seeAll if other conditions allow it. seecanIgnoreDoubleBlind() -
getSeeAll
public boolean getSeeAll()If you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()- Returns:
- the value of seeAll flag, without checking if it is permitted
-
setArtilleryRevealAll
public void setArtilleryRevealAll(boolean artilleryRevealAll) - Parameters:
artilleryRevealAll- Whether the server should reveal all in-flight artillery (both teams) to this player - a client-set testing aid for the Rounds in the Air view
-
isArtilleryRevealAll
public boolean isArtilleryRevealAll()- Returns:
trueif the server should include enemy artillery attacks in this player's artillery packet (the Rounds in the Air testing reveal);falsefor normal team-only (double-blind) behavior
-
canSeeAll
public boolean canSeeAll()If you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()- Returns:
- true if
seeAllis true and is permitted
-
isSeeAllPermitted
public boolean isSeeAllPermitted()If you are checking to see if double-blind applies to this player, usecanIgnoreDoubleBlind()- Returns:
- true if player is allowed use seeAll
-
setObserver
public void setObserver(boolean observer) set theobserverflag. Observers have no units add no team -
setSingleBlind
public void setSingleBlind(boolean singleBlind) setsseeAll. This will only enable seeAll if other conditions allow it. seecanIgnoreDoubleBlind() -
getSingleBlind
public boolean getSingleBlind()If you are checking to see this player can ignore double-blind, usecanIgnoreDoubleBlind()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, usecanIgnoreDoubleBlind()- 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
-
getDisplayColour
The colour this player is actually shown in. A player picks a colour in the lobby by choosing a colour camouflage, and that choice lives on the camouflage -getColour()is a separate field that the lobby never sets, so it stays at its default for most players and cannot be trusted to say what the player looks like. Anything drawing something in a player's colour wants this.- Returns:
- The colour of this player's colour camouflage, or the plain colour field when the camouflage is an image rather than a colour
-
setColour
-
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
-
setAdmitsDefeat
public void setAdmitsDefeat(boolean admitsDefeat) -
admitsDefeat
public boolean admitsDefeat() -
doesNotAdmitDefeat
public boolean doesNotAdmitDefeat() -
getGroundObjectsToPlace
Collection of carryable objects that this player will be placing during the game. -
setGroundObjectsToPlace
Present for serialization purposes only -
setVotedToAllowTeamChange
public void setVotedToAllowTeamChange(boolean allowChange) -
getVotedToAllowTeamChange
public boolean getVotedToAllowTeamChange() -
setArtyAutoHitHexes
-
getArtyAutoHitHexes
-
addArtyAutoHitHex
-
removeArtyAutoHitHex
-
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 toInGameObject.countForStrengthSum().- Returns:
- The combined strength (BV/PV) of all the player's assets
-
isMyUnit
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:
setInitCompensationBonusin interfaceITurnOrdered- Overrides:
setInitCompensationBonusin classTurnOrdered
-
getInitCompensationBonus
public int getInitCompensationBonus()- Specified by:
getInitCompensationBonusin interfaceITurnOrdered- Overrides:
getInitCompensationBonusin classTurnOrdered
-
setConstantInitBonus
public void setConstantInitBonus(int b) -
getConstantInitBonus
public int getConstantInitBonus() -
getStartingVictoryPoints
public int getStartingVictoryPoints()- Returns:
- The victory points this player's side starts the game with, as set by a scenario's faction definition; 0 unless a scenario set it
-
setStartingVictoryPoints
public void setStartingVictoryPoints(int startingVictoryPoints) -
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
- 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
Calculate command bonus for an individual entity within the player's force or team TODO: move all of this into Entity- Parameters:
entity- being considereduseCommandInit- 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
-
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, seecopy(). -
toString
-
equals
Two players are equal if their ids are equal -
hashCode
public int hashCode() -
copy
-
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
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:
-