|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.ninm.games.cardgames.belot.StateAdapter | +--org.ninm.games.cardgames.belot.PlayingState
The superclass of all the playing states which holds most of the common functionality
Field Summary | |
private int |
m_cardsPlayedInHand
|
protected Hand |
m_hand
|
protected boolean |
m_isFirstHand
|
protected boolean |
m_isFirstMove
|
protected java.util.Set |
m_trumpSuits
|
Fields inherited from class org.ninm.games.cardgames.belot.StateAdapter |
m_belotEngine |
Constructor Summary | |
PlayingState(BelotEngine belotEngine,
java.util.Set trumpSuits)
Constructor PlayingState. |
Method Summary | |
boolean |
announceTrick(BelotTrick trick)
tells the engine that a particular player wishes to anounce a trick |
boolean |
beats(Card card1,
Card card2)
|
static boolean |
beats(Card card1,
Card card2,
java.util.Set trumpSuits)
determines if the first card beats the second card in any game |
static boolean |
beats(Face face1,
Face face2,
boolean isTrump)
determines if the first face is higher than the second face in either trump or non trump order |
protected java.util.Set |
findAnnouncedBelots()
finds any announced belots |
abstract java.util.Set |
getAllowedCards()
returns the allowed cards that the current player can play |
java.util.Set |
getAllowedTricks()
returns the allowed tricks that the current player can announce |
java.util.Set |
getCardsThatBeat(java.util.Set cards,
Card card)
|
static java.util.Set |
getCardsThatBeat(java.util.Set cards,
Card card,
java.util.Set trumpSuits)
|
static int |
getScore(Card card,
java.util.Set trumpSuits)
|
boolean |
isTrump(Card card)
|
static boolean |
isTrump(Card card,
java.util.Set trumpSuits)
|
boolean |
playCard(Card card)
indicates a card has been played by a particular player |
private void |
removeBeatenTricks(java.util.Set tricksSoFar,
java.util.Set oppositionAnnouncedTricks)
removes any tricks that are beaten by opposition announced tricks |
protected java.util.Set |
removeBelot(java.util.Set announcedTricks)
removes any belots from the set of announced tricks |
protected java.util.Set |
removeConflictingTricks(java.util.Set currentPalyerTricks,
java.util.Set announcedTricks)
removes any tricks that conflict with announced tricks |
void |
start()
starts the logic of this state! |
Methods inherited from class org.ninm.games.cardgames.belot.StateAdapter |
bidMade, getAllowedBids |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final Hand m_hand
protected final java.util.Set m_trumpSuits
protected boolean m_isFirstHand
protected boolean m_isFirstMove
private int m_cardsPlayedInHand
Constructor Detail |
public PlayingState(BelotEngine belotEngine, java.util.Set trumpSuits)
belotEngine
- a reference to the belot enginetrumpSuits
- all the suits that are trumpsMethod Detail |
public boolean announceTrick(BelotTrick trick)
State
announceTrick
in interface State
announceTrick
in class StateAdapter
trick
- the trick
public abstract java.util.Set getAllowedCards()
State
getAllowedCards
in interface State
getAllowedCards
in class StateAdapter
public boolean playCard(Card card)
State
playCard
in interface State
playCard
in class StateAdapter
card
- the card being played
public void start()
State
public static boolean beats(Face face1, Face face2, boolean isTrump)
face1
- the first faceface2
- the second faceisTrump
- true if the order is trump order
public static boolean beats(Card card1, Card card2, java.util.Set trumpSuits)
card1
- the first cardcard2
- the second cardtrumpSuits
- all trump suits
public static boolean isTrump(Card card, java.util.Set trumpSuits)
public boolean isTrump(Card card)
public java.util.Set getCardsThatBeat(java.util.Set cards, Card card)
public static java.util.Set getCardsThatBeat(java.util.Set cards, Card card, java.util.Set trumpSuits)
public boolean beats(Card card1, Card card2)
public static int getScore(Card card, java.util.Set trumpSuits)
public java.util.Set getAllowedTricks()
State
getAllowedTricks
in interface State
getAllowedTricks
in class StateAdapter
private void removeBeatenTricks(java.util.Set tricksSoFar, java.util.Set oppositionAnnouncedTricks)
tricksSoFar
- the tricks found so far in the players handoppositionAnnouncedTricks
- any tricks announced by the oppositionprotected java.util.Set removeConflictingTricks(java.util.Set currentPalyerTricks, java.util.Set announcedTricks)
currentPalyerTricks
- announcedTricks
-
protected java.util.Set removeBelot(java.util.Set announcedTricks)
announcedTricks
-
protected java.util.Set findAnnouncedBelots()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |