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, setMode
addObserver, broadcast, broadcast, broadcast, notify
static WarCardComparator cardComparator
CardCollection heap
protected java.lang.String getGameName()
GameFactory
..getGameName
in class GameMaster
protected CardComparator getCardComparator()
getCardComparator
in class GameMaster
public int getNumberOfPlayers()
getNumberOfPlayers
in class GameMaster
protected int getCardsPerPlayer()
getCardsPerPlayer
in class GameMaster
protected boolean isWithTurns()
isWithTurns
in class GameMaster
true
if game is with turns; false
otherwise.protected java.lang.String initialTurnInRound()
null
since this game is not played in turns.initialTurnInRound
in class GameMaster
protected void startGame()
startGame
in class GameMaster
protected void checkCards(java.lang.String nick, java.util.List<Card> cards) throws CardGameException
checkCards
in class GameMaster
nick
- of player.cards
- to check.CardGameException
- if a rule was violated.protected void beforeRoundConclusion()
beforeRoundConclusion
in class GameMaster
protected int getRoundPoints(java.lang.String player)
getRoundPoints
in class GameMaster
player
- of player.protected boolean hasEnded()
hasEnded
in class GameMaster
true
if game ended; false
otherwise.protected java.lang.String getWinner()
getWinner
in class GameMaster
protected GamePlayingStrategy getCardGameStrategy()
WarGameStrategy
.getCardGameStrategy
in class GameMaster