Class Player
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Entity>,HasCard
Player class stores almost the state that corresponds to a particular player, like a collection of EntityZone objects and select Attribute and PlayerAttribute attributes as an Entity that
exists in the game.
Unusually, the Spellsource.ZonesMessage.Zones.WEAPON and Spellsource.ZonesMessage.Zones.HERO_POWER zones are located on the Hero entity
retrievable by getHero().
More state is discoverable on the GameContext.getEnvironment() and GameContext.getTriggers()
fields.
Player entities are the appropriate target of many effects, especially text that seems to "live on" after a
card is played. For example, take the card Mark of the Future, which reads: "The next minion you play gains +2/+2 and
Taunt." The Enchantment (called also a "trigger" in the card JSON format described by CardDesc) that actually gives the next minion played its buff lives on the EntityReference.FRIENDLY_PLAYER,
not on the spell.
- See Also:
-
for more on what player entities are requests to do.for a description of the difference zones (i.e. lists) of entities that each player has.for a description of the class that stores the Entity objects in the game.- Serialized Form
-
Field Summary
FieldsFields inherited from class net.demilich.metastone.game.entities.Entity
attributes, effectSource, entityLocation, name, NO_OWNER, sourceCard -
Constructor Summary
ConstructorsConstructorDescriptionPlayer()Use build from config to actually build the class.Creates a player with the hero card of the specified hero classCreates a player from the specified deck.Creates a player from the specified deck. -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones the underlying data and behaviour of this player instance.static Playerempty()Create an empty player instance.booleanCompares two player objects.findEntity(int id) static PlayerCreates a player for the given integer id, userId and deck.getCopy()Clones this player.getDeck()Retrieves the deck for this player as it is in game.Retrieves the cards the player is currently discovering.com.hiddenswitch.spellsource.rpc.Spellsource.EntityTypeMessage.EntityTypeGets the type of entity this is.Retrieves the player's graveyard.getHand()Retrieves the player's hand.getHero()Retrieves the hero specified inside theheroZonefield, anEntityZonethat typically holds just one hero object for the player.Retrieves the hero power zone stored inside the hero entity.Retrieves the hero zone.intGets the player's mana locked by the Overload mechanic.intgetMana()Retrieves the current amount of mana the player has to spend this turn.intThe maximum amount of mana the player can currently have.Gets the minions on this player's side of the battlefield.intgetOwner()Gets the owner of this entity, orIdFactory.UNASSIGNEDif it has no owner.Gets theQuestentities that are in play from this player.Retrieves entities that are removed from play.Retrieves the card IDs of the secrets owned by this player.Retrieves the secrets owned by this player.Retrieves the set aside zone, or the location where cards are temporarily moved during complex interactions.For a player entity, its source card corresponds to the hero's source card.Retrieves statistics collected about this player in the current game.Retrieves the weapon zone belonging to this player's hero entity.getZone(com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones zone) Retrieves a zone by key.inthashCode()voidSets the player's current hero.voidsetId(int id) Sets the player's ID.voidsetLockedMana(int lockedMana) Sets the amount of mana that was overloaded.voidsetMana(int mana) Sets the current mana this player has.voidsetMaxMana(int maxMana) Gives the player this many "empty mana crystals."toString()Returns aTargetPlayerspecifier for this player.voidupdateLookup(@NotNull Entity entity) Updates the lookup table with the specified entity's IDMethods inherited from class net.demilich.metastone.game.entities.Entity
compareTo, diedOnBattlefield, evaluateDescriptions, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getCardInventoryId, getCopySource, getDescription, getDescription, getDynamicDescription, getEffectSource, getEntityLocation, getGameTriggers, getId, getIndex, getMaxNumberOfAttacks, getName, getRace, getReference, getUserId, getZone, hasAttribute, hasPersistentEffects, isDestroyed, isInPlay, isRemovedPeacefully, modifyAttribute, modifyHpBonus, moveOrAddTo, moveOrAddTo, resetEntityLocations, setAttribute, setAttribute, setAttribute, setDescription, setEffectSource, setEntityLocation, setName, setOwner, setSourceCard, setUserId, transformResolved, transformResolved
-
Field Details
-
deck
-
-
Constructor Details
-
Player
public Player()Use build from config to actually build the class. -
Player
Creates a player from the specified deck.- Parameters:
deck- The deck instance to use.
-
Player
Creates a player from the specified deck.- Parameters:
deck- The deck instance to use.
-
Player
Creates a player with the hero card of the specified hero class- Parameters:
heroClass-
-
-
Method Details
-
empty
Create an empty player instance.- Returns:
- A player specified with an
GameDeck.EMPTYand aChooseLastBehaviour.
-
forUser
Creates a player for the given integer id, userId and deck.- Parameters:
userId- The networked user ID of the player.id- The player's ID,IdFactory.PLAYER_1orIdFactory.PLAYER_2deck- The deck to initialize the player with.- Returns:
- A new player instance with the specified settings and a
ChooseLastBehaviour.
-
clone
Clones the underlying data and behaviour of this player instance. -
getDeck
Retrieves the deck for this player as it is in game. ThisCardZoneis mutated over time. This is distinct from aGameDeckobject, which is better interpreted as the base deck from which this object was initialized.- Returns:
- The player's deck in game.
-
getEntityType
public com.hiddenswitch.spellsource.rpc.Spellsource.EntityTypeMessage.EntityType getEntityType()Description copied from class:EntityGets the type of entity this is. These will very nearly match up with the classes, but are primarily used for filters that e.g. draw a Spell or destroy all Secrets.- Specified by:
getEntityTypein classEntity- Returns:
- An
Spellsource.EntityTypeMessage.EntityType
-
getGraveyard
Retrieves the player's graveyard.- Returns:
- An
EntityZonecontaining played cards and dead minions. - See Also:
-
for more about the graveyard.
-
getHand
Retrieves the player's hand.- Returns:
- A
CardZonecontaining the player's current hand. - See Also:
-
for more about the hand.
-
getHero
Retrieves the hero specified inside theheroZonefield, anEntityZonethat typically holds just one hero object for the player.- Returns:
- A
Heroinstance. - See Also:
-
for the one-item EntityZone that this field consults for the Hero entity.for more about the hero zone.
-
getLockedMana
public int getLockedMana()Gets the player's mana locked by the Overload mechanic. The locked mana is set to the amount of mana overloaded the previous turn.- Returns:
- The amount of mana that is unusable this turn due to playing a card with
Attribute.OVERLOADlast turn. - See Also:
-
getMana
public int getMana()Retrieves the current amount of mana the player has to spend this turn. This amount of mana is set togetMaxMana()minus the amount ofgetLockedMana()at the start of the player's turn/- Returns:
- The amount of mana available to spend.
-
getMaxMana
public int getMaxMana()The maximum amount of mana the player can currently have. At the start of the turn, the player'smanais set to this value.- Returns:
- The maximum amount of mana this player can have.
-
getMinions
Gets the minions on this player's side of the battlefield.- Returns:
- An
EntityZoneof minions.
-
getSecretCardIds
Retrieves the card IDs of the secrets owned by this player. Used to enforce that players can only have at most one of each secret in theirsecretZone.- Returns:
- The set of secret card IDs.
- See Also:
-
getSecrets
Retrieves the secrets owned by this player.- Returns:
- Secret entities.
-
getSetAsideZone
Retrieves the set aside zone, or the location where cards are temporarily moved during complex interactions.- Returns:
- The zone.
- See Also:
-
for more about the set aside zone.
-
getStatistics
Retrieves statistics collected about this player in the current game.- Returns:
- A
GameStatisticsobject.
-
setHero
Sets the player's current hero. If aHerocurrently exists in the hero zone, it is removed.- Parameters:
hero- The hero entity.- See Also:
-
setLockedMana
public void setLockedMana(int lockedMana) Sets the amount of mana that was overloaded.- Parameters:
lockedMana- The amount of mana to lock this turn.- See Also:
-
setMana
public void setMana(int mana) Sets the current mana this player has. Usually invoked by spells that increase mana temporarily or when cards are played.- Parameters:
mana- The amount of mana this player should now have.
-
setMaxMana
public void setMaxMana(int maxMana) Gives the player this many "empty mana crystals."- Parameters:
maxMana- The maximum amount of mana a player can have. Increased by one each turn.
-
toString
-
hashCode
public int hashCode() -
equals
Compares two player objects.They are considered equal if their IDs and names match.
-
setId
public void setId(int id) Sets the player's ID. Can only be called once. Sets the owner fields on the zones stored in this player object.- Overrides:
setIdin classEntity- Parameters:
id- The ID to set to, eitherIdFactory.PLAYER_1orIdFactory.PLAYER_2.
-
getCopy
Clones this player. -
getHeroZone
Retrieves the hero zone.- Returns:
- The zone that stores this player's hero entity.
-
getHeroPowerZone
Retrieves the hero power zone stored inside the hero entity.- Returns:
- The hero power stored by this hero.
- See Also:
-
getWeaponZone
Retrieves the weapon zone belonging to this player's hero entity.- Returns:
- A weapon zone.
- See Also:
-
getDiscoverZone
Retrieves the cards the player is currently discovering.- Returns:
- A
CardZoneof cards.
-
getRemovedFromPlay
Retrieves entities that are removed from play. Typically enchantments likeQuestandSecretgo here, and cards created during aDiscoverSpellgo here.Entities that are in
Spellsource.ZonesMessage.Zones.REMOVED_FROM_PLAYshould not be targetable, so it would be unusual to iterate through this zone.- Returns:
- Entities removed from play.
- See Also:
-
getOwner
public int getOwner()Description copied from class:EntityGets the owner of this entity, orIdFactory.UNASSIGNEDif it has no owner.Owners are mutable because the owner of an entity, especially minions, can change.
The owner should match the
Entity.getEntityLocation()'s owner. The minion's location should be changed first, then its owner.- Overrides:
getOwnerin classEntity- Returns:
GameContext.PLAYER_1,GameContext.PLAYER_2, orIdFactory.UNASSIGNED.
-
getQuests
Gets theQuestentities that are in play from this player.- Returns:
- An
EntityZone.
-
getSourceCard
For a player entity, its source card corresponds to the hero's source card.- Specified by:
getSourceCardin interfaceHasCard- Overrides:
getSourceCardin classEntity- Returns:
- The
Hero's source card, ornullif no hero is set.
-
toTargetPlayer
Returns aTargetPlayerspecifier for this player.- Returns:
- Either
TargetPlayer.PLAYER_1orTargetPlayer.PLAYER_2.
-
updateLookup
Updates the lookup table with the specified entity's ID- Parameters:
entity-
-
findEntity
-
getLookup
-
getWeapon
-