org.ninm.games.cardgames.common
Class AbstractEngine

java.lang.Object
  |
  +--org.ninm.games.cardgames.common.AbstractEngine
All Implemented Interfaces:
Engine
Direct Known Subclasses:
BelotEngine

public abstract class AbstractEngine
extends java.lang.Object
implements Engine

This class provides a skeletal implementation of the card game engine which most card games should subclass.

Version:
1.0
Author:
Nikolay

Field Summary
private  javax.swing.event.EventListenerList m_eventListenerList
           
 
Constructor Summary
AbstractEngine()
           
 
Method Summary
 void addBonusListener(BonusListener bonusListener)
          registers the bonus listener with this engine
 void addDealerListener(DealerListener dealerListener)
          registers the dealer listener with this engine
 boolean announceTrick(Player player, Trick trick)
          this implementation just checks weather the player making the anouncement is the currant player and weather the trick is one of the allowed tricks.
 boolean bidMade(Player player, Bid bid)
          this implementation just checks weather the player making the anouncement is the currant player and weather the trick is one of the allowed tricks.
protected  void fireBonusReceived(Player player, Team team, Bonus bonus)
          helper method to let every listener know of the bonus being received
protected  void fireCardDelt(Player player, Team team, Player dealer, Card card)
          helper method to let every listener know that a card has been delt
protected  boolean isAllowedBid(Bid bid)
          a helper method used to determine if the passed in bid is one of the allowed bid
protected  boolean isAllowedCard(Card card)
          a helper method used to determine if the card passed in is one of the allowed cards to be played now
protected  boolean isAllowedTrick(Trick trick)
          a helper method used to determine if the passed in trick is one of the allowed tricks
protected  boolean isCurrantPlayer(Player player)
          a helper method used to determine if the passed in player is the currant player
 boolean playCard(Player player, Card card)
          This implementation just checks weather the player is the currante player and weather the card is one of the allowed cards.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ninm.games.cardgames.Engine
getActivePlayer, getAllowedBids, getAllowedCards, getAllowedTricks
 

Field Detail

m_eventListenerList

private final javax.swing.event.EventListenerList m_eventListenerList
Constructor Detail

AbstractEngine

public AbstractEngine()
Method Detail

playCard

public boolean playCard(Player player,
                        Card card)
This implementation just checks weather the player is the currante player and weather the card is one of the allowed cards.

Specified by:
playCard in interface Engine
Parameters:
player - the player playing the card
card - the card being player
Returns:
if it is the current player and they can play the card

announceTrick

public boolean announceTrick(Player player,
                             Trick trick)
this implementation just checks weather the player making the anouncement is the currant player and weather the trick is one of the allowed tricks.

Specified by:
announceTrick in interface Engine
Parameters:
player - the player announcing the trick
trick - the trick being announced
Returns:
returns true if it is the currant player and is and allowed trick

bidMade

public boolean bidMade(Player player,
                       Bid bid)
this implementation just checks weather the player making the anouncement is the currant player and weather the trick is one of the allowed tricks.

Specified by:
bidMade in interface Engine
Parameters:
player - the player making the bid
bid - the bid being made
Returns:
true if it is the currant player and it is an allowed player

isCurrantPlayer

protected boolean isCurrantPlayer(Player player)
a helper method used to determine if the passed in player is the currant player

Parameters:
player - the player to be compared
Returns:
boolean true if the passed in player is the currant player

isAllowedTrick

protected boolean isAllowedTrick(Trick trick)
a helper method used to determine if the passed in trick is one of the allowed tricks

Parameters:
trick - the trick to be compared
Returns:
boolean true if the passed in trick is allowed

isAllowedBid

protected boolean isAllowedBid(Bid bid)
a helper method used to determine if the passed in bid is one of the allowed bid

Parameters:
bid - the bid to be compared
Returns:
boolean true if the passed in bid is allowed

isAllowedCard

protected boolean isAllowedCard(Card card)
a helper method used to determine if the card passed in is one of the allowed cards to be played now

Parameters:
card - the card to be compared
Returns:
boolean true if this is one of the allowed cards

addBonusListener

public void addBonusListener(BonusListener bonusListener)
Description copied from interface: Engine
registers the bonus listener with this engine

Specified by:
addBonusListener in interface Engine
Parameters:
bonusListener - the bonus listener

addDealerListener

public void addDealerListener(DealerListener dealerListener)
Description copied from interface: Engine
registers the dealer listener with this engine

Specified by:
addDealerListener in interface Engine
Parameters:
dealerListener - the dealer listener

fireBonusReceived

protected void fireBonusReceived(Player player,
                                 Team team,
                                 Bonus bonus)
helper method to let every listener know of the bonus being received

Parameters:
player - the player receiving the bonus
team - the team receiving the bonus
bonus - the bonus being received

fireCardDelt

protected void fireCardDelt(Player player,
                            Team team,
                            Player dealer,
                            Card card)
helper method to let every listener know that a card has been delt

Parameters:
player - the player receiving the card
team - the team that the player belongs to
dealer - the dealer dealing the card
card - the card being delt

SourceForge.net Logo