Package jadex.bdi.examples.blackjack
Class Player
- java.lang.Object
-
- jadex.bdi.examples.blackjack.Player
-
- Direct Known Subclasses:
Dealer
public class Player extends java.lang.ObjectRepresentation of a player.
-
-
Field Summary
Fields Modifier and Type Field Description protected intaccountThe player's account.protected IComponentIdentifieraidThe player's agent id.protected intbetThe player's current bet.protected java.util.ListcardsThe cards held by the player.protected java.awt.ColorcolorThe player's color.protected java.lang.IntegercolorvalueHack, necessary because in Java Color is not a bean.protected booleandrawcardThe player's decision if to draw another card.protected intgamesThe game counter (incremented when a game is started).protected java.lang.StringnameThe player's name.protected SimplePropertyChangeSupportpcsThe helper object for bean events.protected java.lang.StringstateThe player state.static java.lang.StringSTATE_FINISHEDState of a player when all cards are drawn.static java.lang.StringSTATE_GAME_STARTEDState of a player at game start.static java.lang.StringSTATE_IDLEState of a player that is not involved in a game.static java.lang.StringSTATE_PLAYINGState of a player, after bet is made.static java.lang.StringSTATE_UNREGISTEREDState of a player that is not involved in a game.protected IStrategystrategyThe player's strategy.protected java.lang.StringstrategynameThe strategyname.
-
Constructor Summary
Constructors Constructor Description Player()Empty bean constructor.Player(IComponentIdentifier aid, java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)Create a new Player.Player(java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)Create a new Player.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCard(Card card)Add a card.voidaddPropertyChangeListener(PropertyChangeListener listener)Add a PropertyChangeListener to the listener list.booleanequals(java.lang.Object o)Test if this player equals another object.intgetAccount()Get the account of the player.IComponentIdentifiergetAgentID()Get the aid of the player.intgetBet()Get the bet.CardgetCard(int idx)Get a card.intgetCardCnt()Get the number of cards.Card[]getCards()Get the cards held by the player.java.awt.ColorgetColor()Get the color of the player.intgetColorValue()Get the color value.intgetGameCount()Get the game counter.intgetMoneyWon(Card[] dealercards)Get the money won in the current game.java.lang.StringgetName()Get the name of the player.java.lang.StringgetState()Get the state.IStrategygetStrategy()Get the strategy of the player.java.lang.StringgetStrategyName()Get the strategy name.inthashCode()Get the hash code of this player.voidmakeBet(int bet)Make a bet.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a PropertyChangeListener from the listener list.voidsetAccount(int account)Set the account of the player.voidsetAgentID(IComponentIdentifier aid)Set the aid of the player.voidsetBet(int bet)Set the bet.voidsetCard(int idx, Card card)Get a card.voidsetCards(Card[] cards)Get the cards held by the player.voidsetColorValue(int colorvalue)Set the color value.voidsetName(java.lang.String name)Set the name of the player.voidsetState(java.lang.String state)Set the state.voidsetStrategyName(java.lang.String strategyname)Set the strategy name.java.lang.StringtoString()
-
-
-
Field Detail
-
STATE_UNREGISTERED
public static final java.lang.String STATE_UNREGISTERED
State of a player that is not involved in a game.- See Also:
- Constant Field Values
-
STATE_IDLE
public static final java.lang.String STATE_IDLE
State of a player that is not involved in a game.- See Also:
- Constant Field Values
-
STATE_GAME_STARTED
public static final java.lang.String STATE_GAME_STARTED
State of a player at game start.- See Also:
- Constant Field Values
-
STATE_PLAYING
public static final java.lang.String STATE_PLAYING
State of a player, after bet is made.- See Also:
- Constant Field Values
-
STATE_FINISHED
public static final java.lang.String STATE_FINISHED
State of a player when all cards are drawn.- See Also:
- Constant Field Values
-
name
protected java.lang.String name
The player's name.
-
account
protected int account
The player's account.
-
color
protected java.awt.Color color
The player's color.
-
colorvalue
protected java.lang.Integer colorvalue
Hack, necessary because in Java Color is not a bean.
-
strategyname
protected java.lang.String strategyname
The strategyname.
-
strategy
protected IStrategy strategy
The player's strategy.
-
aid
protected IComponentIdentifier aid
The player's agent id.
-
state
protected java.lang.String state
The player state.
-
bet
protected int bet
The player's current bet.
-
drawcard
protected boolean drawcard
The player's decision if to draw another card.
-
cards
protected java.util.List cards
The cards held by the player.
-
games
protected int games
The game counter (incremented when a game is started).
-
pcs
protected SimplePropertyChangeSupport pcs
The helper object for bean events.
-
-
Constructor Detail
-
Player
public Player()
Empty bean constructor.
-
Player
public Player(java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)Create a new Player.
-
Player
public Player(IComponentIdentifier aid, java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)
Create a new Player.
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of the player.
-
setName
public void setName(java.lang.String name)
Set the name of the player.
-
getAccount
public int getAccount()
Get the account of the player.
-
setAccount
public void setAccount(int account)
Set the account of the player.
-
getColor
public java.awt.Color getColor()
Get the color of the player.
-
getColorValue
public int getColorValue()
Get the color value.- Returns:
- The color value.
-
setColorValue
public void setColorValue(int colorvalue)
Set the color value.- Parameters:
colorvalue- The color value.
-
getStrategy
public IStrategy getStrategy()
Get the strategy of the player.
-
getStrategyName
public java.lang.String getStrategyName()
Get the strategy name.- Returns:
- The strategy name.
-
setStrategyName
public void setStrategyName(java.lang.String strategyname)
Set the strategy name.- Parameters:
strategyname- The strategy name.
-
getAgentID
public IComponentIdentifier getAgentID()
Get the aid of the player.
-
setAgentID
public void setAgentID(IComponentIdentifier aid)
Set the aid of the player.
-
addCard
public void addCard(Card card)
Add a card.
-
getCards
public Card[] getCards()
Get the cards held by the player.
-
setCards
public void setCards(Card[] cards)
Get the cards held by the player.
-
getCard
public Card getCard(int idx)
Get a card.
-
setCard
public void setCard(int idx, Card card)Get a card.
-
getCardCnt
public int getCardCnt()
Get the number of cards.
-
getState
public java.lang.String getState()
Get the state.
-
setState
public void setState(java.lang.String state)
Set the state.
-
getBet
public int getBet()
Get the bet.
-
setBet
public void setBet(int bet)
Set the bet.
-
makeBet
public void makeBet(int bet)
Make a bet.
-
getGameCount
public int getGameCount()
Get the game counter.
-
getMoneyWon
public int getMoneyWon(Card[] dealercards)
Get the money won in the current game.
-
equals
public boolean equals(java.lang.Object o)
Test if this player equals another object.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Get the hash code of this player.- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Parameters:
listener- The PropertyChangeListener to be added.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Parameters:
listener- The PropertyChangeListener to be removed.
-
-