public class WarGameMaster extends GameMaster
jpleal@fc.up.pt| Modifier and Type | Field and Description |
|---|---|
(package private) static WarCardComparator |
cardComparator |
(package private) CardCollection |
heap |
| Constructor and Description |
|---|
WarGameMaster() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beforeRoundConclusion()
The player with the higher card value wins the round.
|
protected void |
checkCards(java.lang.String nick,
java.util.List<Card> cards)
Normally players play a single card, but in a war they must play 3 cards.
|
protected CardComparator |
getCardComparator()
War uses a special card comparator, defined in this package
|
protected GamePlayingStrategy |
getCardGameStrategy()
There is a single strategy available for this game -
WarGameStrategy. |
protected int |
getCardsPerPlayer()
Each player receives half of a complete deck when the game starts
|
protected java.lang.String |
getGameName()
Name of this game all in capitals, as in
GameFactory.. |
int |
getNumberOfPlayers()
WAR is a 2 player game
|
protected int |
getRoundPoints(java.lang.String player)
No points in turns.
|
protected java.lang.String |
getWinner()
The winner is the player with cards to play.
|
protected boolean |
hasEnded()
Game ends when one player runs out of cards to play.
|
protected java.lang.String |
initialTurnInRound()
Return
null since this game is not played in turns. |
protected boolean |
isWithTurns()
Players play at once, not in turns.
|
protected void |
startGame()
No initializations needed
|
acceptsPlayers, addPlayer, expired, getCardOnTable, getCardsOnTable, getDeck, getExpirationtime, getGameId, getHand, getInfo, getMode, getNickWithTurn, getPlayerNicks, getRoundsCompleted, getSuitToFollow, newCardCollection, nickWithMostPoints, playCard, playCards, sendCards, setExpirationtime, setModeaddObserver, broadcast, broadcast, broadcast, notifystatic WarCardComparator cardComparator
CardCollection heap
protected java.lang.String getGameName()
GameFactory..getGameName in class GameMasterprotected CardComparator getCardComparator()
getCardComparator in class GameMasterpublic int getNumberOfPlayers()
getNumberOfPlayers in class GameMasterprotected int getCardsPerPlayer()
getCardsPerPlayer in class GameMasterprotected boolean isWithTurns()
isWithTurns in class GameMastertrue if game is with turns; false otherwise.protected java.lang.String initialTurnInRound()
null since this game is not played in turns.initialTurnInRound in class GameMasterprotected void startGame()
startGame in class GameMasterprotected void checkCards(java.lang.String nick,
java.util.List<Card> cards)
throws CardGameException
checkCards in class GameMasternick - of player.cards - to check.CardGameException - if a rule was violated.protected void beforeRoundConclusion()
beforeRoundConclusion in class GameMasterprotected int getRoundPoints(java.lang.String player)
getRoundPoints in class GameMasterplayer - of player.protected boolean hasEnded()
hasEnded in class GameMastertrue if game ended; false otherwise.protected java.lang.String getWinner()
getWinner in class GameMasterprotected GamePlayingStrategy getCardGameStrategy()
WarGameStrategy.getCardGameStrategy in class GameMaster