de.htwdd.rosenkoenig.neuro
Class PatternCreator

java.lang.Object
  extended by de.htwdd.rosenkoenig.neuro.PatternCreator
All Implemented Interfaces:
GameObserver

public class PatternCreator
extends java.lang.Object
implements GameObserver

This class implements the interface GameObserver in order to create output that the net later on can be fed with.


Field Summary
private  int card
          This integer represents the number of the card played.
private  java.io.PrintStream currentStream
          Guessing by the name I'd suggest this is the PrintStream of the currenly active player.
private  java.lang.String directory
          Internal variable used to store the directory the files containing the net feed.
private  boolean drawCard
          This boolean persists the state of the drawCard stack.
private  Game game
          A reference the game we're observing.
private  boolean knight
          This boolean persists the state of the knights.
private  org.apache.log4j.Logger log
          The logging facility.
private  java.util.EnumMap<Color,java.io.PrintStream> printStreams
          Enumeration containing the PrintStreams of the feeds for the two players.
 
Constructor Summary
PatternCreator(Game game, java.lang.String directory)
          Ctor.
 
Method Summary
 void cardSelected()
          Remember the index of the card the player selected.
 void drawDeckSelected()
          Persist that user selected the drawCards deck and set the played card to -1 (no card played).
 void gameEnded()
          On end of the game simply close all open PrintStreams.
 void gameStarted()
          At the beginning of the game we must create a PrintStream for both players.
 void knightsToggled()
          Toggle the knight status.
 void turnEnded()
          When the player ended their turn, we can write the result of the move.
 void turnStarted()
          Turn started sets currentStream to the active player, initilizes card and drawCard and writes the board information to this file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

directory

private java.lang.String directory
Internal variable used to store the directory the files containing the net feed.


printStreams

private java.util.EnumMap<Color,java.io.PrintStream> printStreams
Enumeration containing the PrintStreams of the feeds for the two players.


currentStream

private java.io.PrintStream currentStream
Guessing by the name I'd suggest this is the PrintStream of the currenly active player.


game

private Game game
A reference the game we're observing.


knight

private boolean knight
This boolean persists the state of the knights.


drawCard

private boolean drawCard
This boolean persists the state of the drawCard stack.


card

private int card
This integer represents the number of the card played. It's either -1 (user could not move or drew a card) or a value from 0 through 4 (one of the cards).


log

private org.apache.log4j.Logger log
The logging facility.

Constructor Detail

PatternCreator

public PatternCreator(Game game,
                      java.lang.String directory)
Ctor.

Parameters:
game - a reference to the game to be observed.
directory - the directory that is supposed to contain the feeds
Method Detail

drawDeckSelected

public void drawDeckSelected()
Persist that user selected the drawCards deck and set the played card to -1 (no card played).

Specified by:
drawDeckSelected in interface GameObserver

cardSelected

public void cardSelected()
Remember the index of the card the player selected. DrawCards deck is disabled, hence the drawCard boolean must be set to false.

Specified by:
cardSelected in interface GameObserver

gameEnded

public void gameEnded()
On end of the game simply close all open PrintStreams.

Specified by:
gameEnded in interface GameObserver

gameStarted

public void gameStarted()
At the beginning of the game we must create a PrintStream for both players. We use the current time in seconds over 60000 to distinguish the files (this is ~15 minutes, which should be enough to have unique file names).

Specified by:
gameStarted in interface GameObserver

knightsToggled

public void knightsToggled()
Toggle the knight status.

Specified by:
knightsToggled in interface GameObserver

turnStarted

public void turnStarted()
Turn started sets currentStream to the active player, initilizes card and drawCard and writes the board information to this file. See game.prepareNetFeed for further information on what the feed looks like

Specified by:
turnStarted in interface GameObserver

turnEnded

public void turnEnded()
When the player ended their turn, we can write the result of the move. The result looks like that: -1:-1:-1:-1:-1:-1 - player could not move 1:-1:-1:-1:-1:-1 - player played the first card -1:1:-1:-1:-1:-1 - player played the second card... -1:-1:-1:-1:-1:1 - player drew a card

Specified by:
turnEnded in interface GameObserver