|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGame
public class Game
This Game class represents all the server side game functionalites of this 304 cards game. When every new game is created, a class instent object of this class will be crated in server. Basically all the server side game functionalites are handled by this game class.
Field Summary | |
---|---|
private int |
bestbet
|
private int |
bestbetby
|
(package private) boolean[] |
betfinished
|
(package private) int[] |
bets
|
private java.util.ArrayList<Card>[] |
cards4player
|
private int |
gameId
|
private int |
lastRoundWinner
|
private int |
noOfRounds
|
private int[] |
playerPoints
|
private int |
roundStartsWith
|
private Cards304Server |
srv
|
private Card[] |
table
|
private int |
thisTurnPlayer
|
private Card |
trump
|
private boolean |
trumpOpen
|
private int[] |
wins
|
Constructor Summary | |
---|---|
Game(Cards304Server srv,
int gameId)
Constructor of this class, get the server object and gameId. |
Method Summary | |
---|---|
private void |
checkBestBet()
this methos is to check the best bet and to sent a message to the clients. |
static java.util.ArrayList<Card> |
deal(java.util.List<Card> deck,
int n)
This method is to divide the shuffeled cards into 4 players. |
private int |
enemyOf(int player)
This method is to find an openent of a player. |
void |
finalize()
This method finializes the game functionalities. |
private void |
finishPlay()
This method is to finish the current player and set the winner. |
private boolean |
isRoundFinished()
This method is to check whether a round finished or not. |
private void |
newPlay()
This method restores the default values to all those variables in this class and starts a new play |
private int |
partnerOf(int player)
This method is to find the partner of a player. |
private void |
resetTable()
This method is to reset the Table array and this method check whether 8 rounds finished or not, if 8 rounds finished, finishes the game and sets the winning results. |
void |
selectTurn()
This method is to select a turn according to the game logics. |
void |
setBet(int playerId,
int bet)
This method is to set a bet to its player and this function will be called from the server. |
private void |
setPoints()
This method is to sent the point to playerPoints array. |
void |
setSelectedCard(int playerId,
java.lang.String card)
This method is to set the selected card in client to a table card array. |
void |
setTrump(java.lang.String trump)
This method sets the trump card and this method will be called from server. |
void |
shuffleAndServe()
This method is to get a new deack of cards from cards class and suffle it and then to server it to the clients. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int gameId
private int bestbet
private int bestbetby
private int lastRoundWinner
private int thisTurnPlayer
private int roundStartsWith
private int noOfRounds
private int[] wins
private int[] playerPoints
private Card trump
private Cards304Server srv
private java.util.ArrayList<Card>[] cards4player
private Card[] table
private boolean trumpOpen
int[] bets
boolean[] betfinished
Constructor Detail |
---|
public Game(Cards304Server srv, int gameId)
srv
- Cards304Server class object to access server and send messages to the clients.gameId
- int index no of a game.Method Detail |
---|
public void shuffleAndServe()
public static java.util.ArrayList<Card> deal(java.util.List<Card> deck, int n)
public void setBet(int playerId, int bet)
playerId
- int index numer of a player or id of a playerbet
- int the amount of a bet.private void checkBestBet()
public void setTrump(java.lang.String trump)
public void setSelectedCard(int playerId, java.lang.String card)
playerId
- int this player's index number.card
- String name of a gard.private boolean isRoundFinished()
private void setPoints()
public void selectTurn()
private void resetTable()
private void finishPlay()
private void newPlay()
private int partnerOf(int player)
player
- int player id.
private int enemyOf(int player)
player
- int player id.
public void finalize()
finalize
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |