|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.htwdd.rosenkoenig.game.Game
public class Game
This class implements the game and all of its properties. As Domi calls jocosely it is the 'zentrale Obermopsklasse'. It does - of course - not contain anything that has something to do with GUI or whatsoever.
| Field Summary | |
|---|---|
protected Color |
activePlayer
|
protected int |
availableStones
|
protected Color[][] |
board
|
protected Position |
currentPosition
|
private static double[][][] |
directions
These are the constants for the coding of the directions of the cards. |
private static double[][] |
distance
These constants are used to code the distance of a card. |
protected java.util.List<Card> |
drawDeck
|
protected java.util.List<GUI> |
guis
|
protected java.util.List<Card> |
knightableCards
List of knightable cards. |
protected boolean |
knightsSelected
Wheter or not knights are enabled. |
protected static Position |
maxDimension
This variable give the maximum board dimensions. |
protected Card |
nextCard
this property determines user's next move; if user can move, and this property is unequal to five then the selected card is played otherwise the user draws a card, if possible (i.e. lt 5 cards) |
protected java.util.List<GameObserver> |
observers
List of game observers observing the game. |
protected Color |
passivePlayer
|
protected java.util.List<Card> |
playableCards
List of playable cards. |
protected java.util.List<Card> |
playedCardsDeck
|
protected java.util.EnumMap<Color,Player> |
players
This enumeration represents the players. |
| Constructor Summary | |
|---|---|
Game(Player playerOne,
Player playerTwo)
Ctor - randomly choses, which player is about to start. |
|
Game(Player playerOne,
Player playerTwo,
GUI gui)
Ctor - calls public |
|
| Method Summary | |
|---|---|
void |
addGUI(GUI gui)
Add a gui to the game. |
void |
addObserver(GameObserver observer)
Add an observer to the game. |
int |
calcScore(Color color)
|
boolean |
cardKnightable(Card card)
|
boolean |
cardPlayable(Card card)
|
protected void |
endGame()
endGame updates the players highscore and notifies the observers that the game has ended. |
void |
endTurn()
This function persists the move. |
Color |
getActivePlayer()
Getter of the property activePlayer |
int |
getAvailableStones()
Getter of the property stones |
Color[][] |
getBoard()
Getter of the property board |
private int |
getCoherentArea(Color color,
int score,
boolean[][] tmpBoard,
int x,
int y)
|
Position |
getCurrentPosition()
Getter of the property currentPosition |
java.util.List<Card> |
getDrawDeck()
Getter of the property drawDeck |
Card |
getNextCard()
Getter of the property nextCard |
Color |
getPassivePlayer()
Getter of the property passivePlayer |
java.util.List<Card> |
getPlayedCardsDeck()
Getter of the property playedCardsDeck |
java.util.EnumMap<Color,Player> |
getPlayers()
Getter of the property players |
double[][] |
getRotMatrix(double degree)
Calculate the rotation matrix for a certain degree rotation. |
boolean |
isCardPlayable(Card card,
boolean withKnight)
Checks for active player if card is playable. |
boolean |
isCardPlayable(Color player,
Card card,
boolean withKnight)
Checks for player if card is playable. |
Color[][] |
normalizeBoard()
Normalize the board. |
java.util.ArrayList<Card> |
normalizeCards(Color player)
Rotate (normalize) the cards for player depending on the position of the crown. |
int[] |
normalizeCrown()
Put the crown in a position of the field that is saved. |
double[] |
prepareNetFeed()
A highly sophisticated function that, much better than all other functions: creates a double array for the crown (1), player color (2), card direction, move width, playability of the card for all ten cards ((8+3+1)*10) and 10 values for the knights (four, three, two, one or no knights) For the crown there is only a small part of the board saved and rotated (normalized) to save input neurons of the net. |
protected void |
prepareTurn()
Activates the current player's controls, updates the gui and notifies all observers. |
void |
removeGUI(GUI gui)
Remove a game from the gui. |
void |
removeObserver(GameObserver observer)
Remove an observer to the game. |
void |
selectCard(Card card)
|
void |
selectDrawDeck()
This function is called, when the player clicks on the drawDeck. |
void |
setActivePlayer(Color activePlayer)
Setter of the property activePlayer |
void |
setAvailableStones(int availableStones)
Setter of the property stones |
void |
setBoard(Color[][] board)
Setter of the property board |
void |
setCurrentPosition(Position currentPosition)
Setter of the property currentPosition |
void |
setDrawDeck(java.util.List<Card> drawDeck)
Setter of the property drawDeck |
void |
setNextCard(Card nextCard)
Setter of the property nextCard |
void |
setPassivePlayer(Color passivePlayer)
Setter of the property passivePlayer |
void |
setPlayedCardsDeck(java.util.List<Card> playedCardsDeck)
Setter of the property playedCardsDeck |
void |
setPlayers(java.util.EnumMap<Color,Player> players)
Setter of the property players |
void |
start()
Start a game. |
void |
toggleKnights()
This function toggles the knight selection of the currently active player. |
protected void |
undoMove()
This function deselects the card currently activated by the player and remove the shady stone from the board/resets the old stone to the board, in case the active player planned to use a knight. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Position maxDimension
private static final double[][][] directions
private static final double[][] distance
protected java.util.EnumMap<Color,Player> players
protected int availableStones
protected java.util.List<Card> drawDeck
protected java.util.List<Card> playedCardsDeck
protected Color[][] board
protected Color activePlayer
protected Color passivePlayer
protected Position currentPosition
protected Card nextCard
protected java.util.List<GUI> guis
protected java.util.List<GameObserver> observers
protected java.util.List<Card> knightableCards
protected java.util.List<Card> playableCards
protected boolean knightsSelected
| Constructor Detail |
|---|
public Game(Player playerOne,
Player playerTwo)
playerOne - player oneplayerTwo - player two
public Game(Player playerOne,
Player playerTwo,
GUI gui)
playerOne - player oneplayerTwo - player twogui - the gui to be attached| Method Detail |
|---|
public java.util.EnumMap<Color,Player> getPlayers()
public int getAvailableStones()
public void setAvailableStones(int availableStones)
stones - The stones to set.public java.util.List<Card> getDrawDeck()
public void setDrawDeck(java.util.List<Card> drawDeck)
drawDeck - The drawDeck to set.public java.util.List<Card> getPlayedCardsDeck()
public void setPlayedCardsDeck(java.util.List<Card> playedCardsDeck)
playedCardsDeck - The playedCardsDeck to set.public Color[][] getBoard()
public void setBoard(Color[][] board)
board - The boards to set.public Color getActivePlayer()
public void setActivePlayer(Color activePlayer)
activePlayer - The activePlayer to set.public Color getPassivePlayer()
public void setPassivePlayer(Color passivePlayer)
activePlayer - The passivePlayer to set.public Position getCurrentPosition()
public void setCurrentPosition(Position currentPosition)
currentPosition - The currentPosition to set.public void selectDrawDeck()
protected void undoMove()
public void selectCard(Card card)
card - the card to playpublic void endTurn()
protected void endGame()
public boolean cardPlayable(Card card)
card - card to be checked for playability
public boolean cardKnightable(Card card)
card - to be checked for knightability
public void toggleKnights()
public Card getNextCard()
public void setNextCard(Card nextCard)
nextCard - The nextCard to set.public int calcScore(Color color)
color - color of the player whose score is to be calculated
private int getCoherentArea(Color color,
int score,
boolean[][] tmpBoard,
int x,
int y)
color - the color of the user whose score is to be calculatedscore - the score so fartmpBoard - a temporary structure containing all fields already processed
public void start()
protected void prepareTurn()
public boolean isCardPlayable(Card card,
boolean withKnight)
card - card to be checkedwithKnight - whether or not use a knight
public boolean isCardPlayable(Color player,
Card card,
boolean withKnight)
player - card - card to be checkedwithKnight - whether or not use a knight
public void addGUI(GUI gui)
gui - guess!public void removeGUI(GUI gui)
gui - guess!public void addObserver(GameObserver observer)
observer - the observer to be added.public void removeObserver(GameObserver observer)
observer - the observer to be removed.public void setPlayers(java.util.EnumMap<Color,Player> players)
players - The players to set.public double[] prepareNetFeed()
public int[] normalizeCrown()
public Color[][] normalizeBoard()
public java.util.ArrayList<Card> normalizeCards(Color player)
player - the cards must be rotated for
public double[][] getRotMatrix(double degree)
degree - degree of rotation
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||