org.ninm.games.cardgames.belot
Class BelotEngine

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

public final class BelotEngine
extends AbstractEngine

This class holds the logic of the belot game

Version:
1.0
Author:
Nikolay

Field Summary
private  int m_activePlayer
           
private  Belot m_belot
           
private  BelotBid m_belotBid
           
private  Team m_biddingTeam
           
private  int m_dealer
           
private  DefaultPlayer[] m_players
           
private  State m_state
           
 
Fields inherited from class org.ninm.games.cardgames.common.AbstractEngine
 
Constructor Summary
BelotEngine(Belot belot)
           
 
Method Summary
 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.
private  void dealCard(DefaultPlayer player, Card card)
           
(package private)  void dealCards(int numberOfCards)
           
 Player getActivePlayer()
          returns the player whos turn it is
 java.util.Set getAllowedBids()
          returs the allowed bids the current player can make
 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
(package private)  BelotBid getBelotBid()
          Returns the belotBid.
 Team getBiddingTeam()
          Returns the biddingTeam.
(package private)  DefaultTeam getOposition(Team team)
           
(package private)  java.util.List getPlayers()
           
(package private)  DefaultScore getScore()
           
(package private)  State getState()
           
private  int next(int player)
           
(package private)  void nextDealer()
          sets the active dealer to be the next player in an anti-clockwise fashion
(package private)  void nextPlayer()
          sets the active player to be the next player in an anti-clockwise fashion
 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.
(package private)  void returnCardsToDeck()
          returns all the cards to the deck
(package private)  void setActivePlayer(Player player)
           
(package private)  void setBelotBid(BelotBid belotBid)
          Sets the belotBid.
 void setBiddingTeam(Team biddingTeam)
          Sets the biddingTeam.
(package private)  void setDealerToActivePlayer()
           
(package private)  void setState(State state)
           
 void start()
           
 
Methods inherited from class org.ninm.games.cardgames.common.AbstractEngine
addBonusListener, addDealerListener, fireBonusReceived, fireCardDelt, isAllowedBid, isAllowedCard, isAllowedTrick, isCurrantPlayer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_belot

private final Belot m_belot

m_players

private final DefaultPlayer[] m_players

m_belotBid

private BelotBid m_belotBid

m_state

private State m_state

m_biddingTeam

private Team m_biddingTeam

m_activePlayer

private int m_activePlayer

m_dealer

private int m_dealer
Constructor Detail

BelotEngine

public BelotEngine(Belot belot)
Method Detail

getActivePlayer

public Player getActivePlayer()
Description copied from interface: Engine
returns the player whos turn it is

Returns:
Player the player whos turn it is

getAllowedCards

public java.util.Set getAllowedCards()
Description copied from interface: Engine
returns the allowed cards that the current player can play

Returns:
List the array of allowed cards for the player

getAllowedTricks

public java.util.Set getAllowedTricks()
Description copied from interface: Engine
returns the allowed tricks that the current player can announce

Returns:
List the array of allowed tricks for the current player

getAllowedBids

public java.util.Set getAllowedBids()
Description copied from interface: Engine
returs the allowed bids the current player can make

Returns:
List a list of bids

playCard

public boolean playCard(Player player,
                        Card card)
Description copied from class: AbstractEngine
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
Overrides:
playCard in class AbstractEngine
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)
Description copied from class: AbstractEngine
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
Overrides:
announceTrick in class AbstractEngine
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)
Description copied from class: AbstractEngine
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
Overrides:
bidMade in class AbstractEngine
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

getPlayers

java.util.List getPlayers()

dealCard

private void dealCard(DefaultPlayer player,
                      Card card)

dealCards

void dealCards(int numberOfCards)

returnCardsToDeck

void returnCardsToDeck()
returns all the cards to the deck


setState

void setState(State state)

getState

State getState()

nextPlayer

void nextPlayer()
sets the active player to be the next player in an anti-clockwise fashion


next

private int next(int player)

setDealerToActivePlayer

void setDealerToActivePlayer()

nextDealer

void nextDealer()
sets the active dealer to be the next player in an anti-clockwise fashion


start

public void start()

getBiddingTeam

public Team getBiddingTeam()
Returns the biddingTeam.

Returns:
Team

setBiddingTeam

public void setBiddingTeam(Team biddingTeam)
Sets the biddingTeam.

Parameters:
biddingTeam - The biddingTeam to set

getBelotBid

BelotBid getBelotBid()
Returns the belotBid.

Returns:
BelotBid

setBelotBid

void setBelotBid(BelotBid belotBid)
Sets the belotBid.

Parameters:
belotBid - The belotBid to set

getScore

DefaultScore getScore()

setActivePlayer

void setActivePlayer(Player player)

getOposition

DefaultTeam getOposition(Team team)

SourceForge.net Logo