simulations.core
Class Judge

java.lang.Object
  extended by java.lang.Thread
      extended by simulations.core.Judge
All Implemented Interfaces:
java.lang.Runnable

public class Judge
extends java.lang.Thread

This class describes the judge of the game (the mediator)


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Judge(Game game)
          Creates a new instance of Judge
 
Method Summary
 void addToGraph()
          Add the last list of players to the playerListList to construct graph
 double[] coalitionListToData(java.util.ArrayList l)
          Returns a array of double that represents the data of l
 PlayerTurn doAttack(Player attackingPlayer, Player playerToAttack, java.util.ArrayList playersToAskSupport)
          Do an attack when all parameters are set.
 void endGame()
          end the game
 void endTurn()
          validate the end of a turn.
 java.util.ArrayList getClassement()
          Getter for property classement.
 java.util.ArrayList getCloneRemainingPlayers()
          Returns (aclone) of the list of remaining players
 java.util.ArrayList getCoalitionListList()
          Getter for property coalitionListList.
 java.util.Hashtable getCoalitionsRanking()
          Getter for property coalitionsRanking.
 CoalitionView getCoalitionView()
          Getter for property coalitionView.
 int getCurrentTurn()
          Getter for property currentTurn.
 Game getGame()
          Getter for property game.
 HistoryWriter getHistoryWriter()
          Getter for property historyWriter.
 java.util.ArrayList getPlayerListList()
          Getter for property playerListList.
 java.util.ArrayList getStatisticsList()
          Getter for property statisticsList.
 java.lang.String getTurnDescription()
          Getter for property turnDescription.
 void initGame()
          init the game : creates list instance, memorize time, etc...
 boolean isInClassement(Player p)
          This method returns true if the player p is already dead and he's already in classement
 boolean nextGameTurn()
          return true if game is finish because the three last turn are the same false otherwise
 Turn nextTurn()
          playing next turn of the game.
 boolean playGame()
          launch the game
 Turn returnLastTurn()
          This method returns the last turn of the game.
 void run()
          This method is overiden from Thread.
 void setClassement(java.util.ArrayList classement)
          Setter for property classement.
 void setCoalitionListList(java.util.ArrayList coalitionListList)
          Setter for property coalitionListList.
 void setCoalitionsRanking(java.util.Hashtable coalitionsRanking)
          Setter for property coalitionsRanking.
 void setCoalitionView(CoalitionView coalitionView)
          Setter for property coalitionView.
 void setCurrentTurn(int currentTurn)
          Setter for property currentTurn.
 void setGame(Game game)
          Setter for property game.
 void setHistoryWriter(HistoryWriter historyWriter)
          Setter for property historyWriter.
 void setPlayerListList(java.util.ArrayList playerListList)
          Setter for property playerListList.
 void setStatisticsList(java.util.ArrayList statisticsList)
          Setter for property statisticsList.
 void setTurnDescription(java.lang.String turnDescription)
          Setter for property turnDescription.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Judge

public Judge(Game game)
Creates a new instance of Judge

Parameters:
game - The game that the judge will manage.
Method Detail

initGame

public void initGame()
init the game : creates list instance, memorize time, etc...


nextGameTurn

public boolean nextGameTurn()
return true if game is finish because the three last turn are the same false otherwise

Returns:
return true if game is finish because the three last turn are the same false otherwise

coalitionListToData

public double[] coalitionListToData(java.util.ArrayList l)
Returns a array of double that represents the data of l

Parameters:
l - The list of coalition list
Returns:
a array of double that represents the data of l

endGame

public void endGame()
end the game


playGame

public boolean playGame()
launch the game

Returns:
false if the game has stoppe because of the three last turn rule true otherwise

returnLastTurn

public Turn returnLastTurn()
This method returns the last turn of the game. The judge will use this method to give informations about the last turn to players

Returns:
The last turn of the game

getCloneRemainingPlayers

public java.util.ArrayList getCloneRemainingPlayers()
Returns (aclone) of the list of remaining players

Returns:
Returns (a clone) of the list of remaining players

addToGraph

public void addToGraph()
Add the last list of players to the playerListList to construct graph


nextTurn

public Turn nextTurn()
playing next turn of the game. Each player plays one shot.

Returns:
Return the desrciption of the turn

isInClassement

public boolean isInClassement(Player p)
This method returns true if the player p is already dead and he's already in classement

Parameters:
p - The player
Returns:
true if the player p is already dead and he's already in classement false otherwise

endTurn

public void endTurn()
validate the end of a turn. Update truth between players. write results of turn into history file.


doAttack

public PlayerTurn doAttack(Player attackingPlayer,
                           Player playerToAttack,
                           java.util.ArrayList playersToAskSupport)
Do an attack when all parameters are set.

Parameters:
attackingPlayer - The attacking player
playerToAttack - The attacked player
playersToAskSupport - The players to ask support.
Returns:
The description of the player turn

getGame

public Game getGame()
Getter for property game.

Returns:
Value of property game.

setGame

public void setGame(Game game)
Setter for property game.

Parameters:
game - New value of property game.

getCurrentTurn

public int getCurrentTurn()
Getter for property currentTurn.

Returns:
Value of property currentTurn.

setCurrentTurn

public void setCurrentTurn(int currentTurn)
Setter for property currentTurn.

Parameters:
currentTurn - New value of property currentTurn.

getHistoryWriter

public HistoryWriter getHistoryWriter()
Getter for property historyWriter.

Returns:
Value of property historyWriter.

setHistoryWriter

public void setHistoryWriter(HistoryWriter historyWriter)
Setter for property historyWriter.

Parameters:
historyWriter - New value of property historyWriter.

getPlayerListList

public java.util.ArrayList getPlayerListList()
Getter for property playerListList.

Returns:
Value of property playerListList.

setPlayerListList

public void setPlayerListList(java.util.ArrayList playerListList)
Setter for property playerListList.

Parameters:
playerListList - New value of property playerListList.

run

public void run()
This method is overiden from Thread. It launch the thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getCoalitionView

public CoalitionView getCoalitionView()
Getter for property coalitionView.

Returns:
Value of property coalitionView.

setCoalitionView

public void setCoalitionView(CoalitionView coalitionView)
Setter for property coalitionView.

Parameters:
coalitionView - New value of property coalitionView.

getStatisticsList

public java.util.ArrayList getStatisticsList()
Getter for property statisticsList.

Returns:
Value of property statisticsList.

setStatisticsList

public void setStatisticsList(java.util.ArrayList statisticsList)
Setter for property statisticsList.

Parameters:
statisticsList - New value of property statisticsList.

getTurnDescription

public java.lang.String getTurnDescription()
Getter for property turnDescription.

Returns:
Value of property turnDescription.

setTurnDescription

public void setTurnDescription(java.lang.String turnDescription)
Setter for property turnDescription.

Parameters:
turnDescription - New value of property turnDescription.

getClassement

public java.util.ArrayList getClassement()
Getter for property classement.

Returns:
Value of property classement.

setClassement

public void setClassement(java.util.ArrayList classement)
Setter for property classement.

Parameters:
classement - New value of property classement.

getCoalitionListList

public java.util.ArrayList getCoalitionListList()
Getter for property coalitionListList.

Returns:
Value of property coalitionListList.

setCoalitionListList

public void setCoalitionListList(java.util.ArrayList coalitionListList)
Setter for property coalitionListList.

Parameters:
coalitionListList - New value of property coalitionListList.

getCoalitionsRanking

public java.util.Hashtable getCoalitionsRanking()
Getter for property coalitionsRanking.

Returns:
Value of property coalitionsRanking.

setCoalitionsRanking

public void setCoalitionsRanking(java.util.Hashtable coalitionsRanking)
Setter for property coalitionsRanking.

Parameters:
coalitionsRanking - New value of property coalitionsRanking.