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.Object
Representation of a player.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
account
The player's account.protected IComponentIdentifier
aid
The player's agent id.protected int
bet
The player's current bet.protected java.util.List
cards
The cards held by the player.protected java.awt.Color
color
The player's color.protected java.lang.Integer
colorvalue
Hack, necessary because in Java Color is not a bean.protected boolean
drawcard
The player's decision if to draw another card.protected int
games
The game counter (incremented when a game is started).protected java.lang.String
name
The player's name.protected SimplePropertyChangeSupport
pcs
The helper object for bean events.protected java.lang.String
state
The player state.static java.lang.String
STATE_FINISHED
State of a player when all cards are drawn.static java.lang.String
STATE_GAME_STARTED
State of a player at game start.static java.lang.String
STATE_IDLE
State of a player that is not involved in a game.static java.lang.String
STATE_PLAYING
State of a player, after bet is made.static java.lang.String
STATE_UNREGISTERED
State of a player that is not involved in a game.protected IStrategy
strategy
The player's strategy.protected java.lang.String
strategyname
The 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 void
addCard(Card card)
Add a card.void
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.boolean
equals(java.lang.Object o)
Test if this player equals another object.int
getAccount()
Get the account of the player.IComponentIdentifier
getAgentID()
Get the aid of the player.int
getBet()
Get the bet.Card
getCard(int idx)
Get a card.int
getCardCnt()
Get the number of cards.Card[]
getCards()
Get the cards held by the player.java.awt.Color
getColor()
Get the color of the player.int
getColorValue()
Get the color value.int
getGameCount()
Get the game counter.int
getMoneyWon(Card[] dealercards)
Get the money won in the current game.java.lang.String
getName()
Get the name of the player.java.lang.String
getState()
Get the state.IStrategy
getStrategy()
Get the strategy of the player.java.lang.String
getStrategyName()
Get the strategy name.int
hashCode()
Get the hash code of this player.void
makeBet(int bet)
Make a bet.void
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.void
setAccount(int account)
Set the account of the player.void
setAgentID(IComponentIdentifier aid)
Set the aid of the player.void
setBet(int bet)
Set the bet.void
setCard(int idx, Card card)
Get a card.void
setCards(Card[] cards)
Get the cards held by the player.void
setColorValue(int colorvalue)
Set the color value.void
setName(java.lang.String name)
Set the name of the player.void
setState(java.lang.String state)
Set the state.void
setStrategyName(java.lang.String strategyname)
Set the strategy name.java.lang.String
toString()
-
-
-
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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Get the hash code of this player.- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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.
-
-