beverbende
Class CardBase

java.lang.Object
  extended by beverbende.CardBase

public class CardBase
extends java.lang.Object


Constructor Summary
CardBase(int nAgents, java.util.Map<Card.cardKind,java.lang.Integer> cardamount)
          Card base constructor
 
Method Summary
 void changePosition(int[] pos1, int[] pos2)
          Switch the positions of two cards.
 void disposeHandCard(int agent)
          Removes the 5th card that an agent might still have in his/her hand
 void drawFromClosed(int agentID, int pos)
          Draws a card from the closed deck and gives it to the agent (hand).
 void drawFromOpen(int agentID)
          Draws a card from open deck and gives it to the agent (hand).
 int getAgentCardID(int agent, int position)
           
 Card.cardKind getAgentCardKind(int agent, int position)
           
 java.lang.String getAgentCardKindString(int agent, int position)
           
 int getAgentCardValue(int agent, int position)
           
 double getAverageCardCount()
           
 java.util.Map<Card.cardKind,java.lang.Integer> getCardCount()
           
 int[] getCardPosition(int cardID)
          This card can only be in the hand of an agent!
 Card.cardKind getHighestCardKind()
           
 Card.cardKind getLowestCardKind()
           
 int getNumberOfDifferentCards()
           
 void putOnOpen(int card)
          Puts the given card on the open pile
 Card.cardKind seeOpenCard()
           
 java.lang.String seeOpenCardString()
           
 void setCardCount(Card.cardKind kind, int newCardCount)
          Changes the number of cards available for a specific value
 void setupCards(int numAgents, java.util.Map<Card.cardKind,java.lang.Integer> cardamount)
          Initializes the cards in use and distributes them to the agents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardBase

public CardBase(int nAgents,
                java.util.Map<Card.cardKind,java.lang.Integer> cardamount)
Card base constructor

Parameters:
nAgents - the number of agents
cardamount - map containing the amounts of each card in play
Method Detail

setupCards

public void setupCards(int numAgents,
                       java.util.Map<Card.cardKind,java.lang.Integer> cardamount)
Initializes the cards in use and distributes them to the agents

Parameters:
numAgents - the number of agents
cardamount - map containing the amounts of each card in play

drawFromClosed

public void drawFromClosed(int agentID,
                           int pos)
Draws a card from the closed deck and gives it to the agent (hand). Unless we're at the beginning or the end of the game (pos should be 5 for hand)

Parameters:
agentID - id of the agent
pos - position to put the card on

drawFromOpen

public void drawFromOpen(int agentID)
Draws a card from open deck and gives it to the agent (hand). This card can only go to position 5 so there is no need to add the position as an argument

Parameters:
agentID - id of the agent

putOnOpen

public void putOnOpen(int card)
Puts the given card on the open pile

Parameters:
card - id of the card

seeOpenCard

public Card.cardKind seeOpenCard()
Returns:
the card kind of the card on the open pile

disposeHandCard

public void disposeHandCard(int agent)
Removes the 5th card that an agent might still have in his/her hand

Parameters:
agent - id of the agent

changePosition

public void changePosition(int[] pos1,
                           int[] pos2)
Switch the positions of two cards. [agent1][pos1] & [agent2][pos2] This only works for cards that are in agent hands.

Parameters:
pos1 - position 1
pos2 - position 2

getAgentCardID

public int getAgentCardID(int agent,
                          int position)
Parameters:
agent - id of the agent
position - position of the card
Returns:
the cardID of a card on a specific location

getAgentCardValue

public int getAgentCardValue(int agent,
                             int position)
Parameters:
agent - id of the agent
position - position of the card
Returns:
the value of a card, given its position

getAgentCardKind

public Card.cardKind getAgentCardKind(int agent,
                                      int position)
Parameters:
agent - id of the agent
position - position of the card
Returns:
the type of a card, given its position

getCardPosition

public int[] getCardPosition(int cardID)
This card can only be in the hand of an agent!

Parameters:
cardID - id of a card
Returns:
the position of a card, given it's id

getNumberOfDifferentCards

public int getNumberOfDifferentCards()

getAverageCardCount

public double getAverageCardCount()
Returns:
the average value of all the cards in the deck

getHighestCardKind

public Card.cardKind getHighestCardKind()
Returns:
the card kind with the highest value in the game

getLowestCardKind

public Card.cardKind getLowestCardKind()
Returns:
the card kind with the lowest value in the game

setCardCount

public void setCardCount(Card.cardKind kind,
                         int newCardCount)
Changes the number of cards available for a specific value

Parameters:
kind - card kind
newCardCount - amount of cards for this card kind

getAgentCardKindString

public java.lang.String getAgentCardKindString(int agent,
                                               int position)
Parameters:
agent -
position -
Returns:
the cardkind of a specific card of a specific agent

seeOpenCardString

public java.lang.String seeOpenCardString()
Returns:
the card kind of the top card from the open deck

getCardCount

public java.util.Map<Card.cardKind,java.lang.Integer> getCardCount()
Returns:
the map containing the amounts of each card in play