megamek.server.victory
Class VictoryResult

java.lang.Object
  extended by megamek.server.victory.VictoryResult
All Implemented Interfaces:
Victory.Result
Direct Known Subclasses:
SimpleResult

public class VictoryResult
extends java.lang.Object
implements Victory.Result

quick implementation of a Victory.Result stores player scores and a flag if game-ending victory is achieved or not


Field Summary
protected  double hiScore
           
protected  java.util.HashMap<java.lang.Integer,java.lang.Double> playerScore
           
protected  java.util.ArrayList<Report> reports
           
protected  java.util.HashMap<java.lang.Integer,java.lang.Double> teamScore
           
protected  java.lang.Throwable tr
           
protected  boolean victory
           
 
Constructor Summary
VictoryResult(boolean win)
           
 
Method Summary
 void addPlayerScore(int id, double score)
           
 void addReport(Report r)
           
 void addTeamScore(int id, double score)
           
 int[] getPlayers()
          list players
 double getPlayerScore(int id)
           
 java.util.ArrayList<Report> getReports()
           
 int[] getTeams()
          list teams
 double getTeamScore(int id)
          list team scores all teams which are not listed, can be assumed to be at 0.0
protected  java.lang.String getTrace()
           
 int getWinningPlayer()
           
 int getWinningTeam()
           
 boolean isDraw()
           
 boolean isWinningPlayer(int id)
           
 boolean isWinningTeam(int id)
           
 void setVictory(boolean b)
           
 java.lang.String toString()
           
protected  void updateHiScore()
           
 boolean victory()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

victory

protected boolean victory

tr

protected java.lang.Throwable tr

reports

protected java.util.ArrayList<Report> reports

playerScore

protected java.util.HashMap<java.lang.Integer,java.lang.Double> playerScore

teamScore

protected java.util.HashMap<java.lang.Integer,java.lang.Double> teamScore

hiScore

protected double hiScore
Constructor Detail

VictoryResult

public VictoryResult(boolean win)
Method Detail

getWinningPlayer

public int getWinningPlayer()
Specified by:
getWinningPlayer in interface Victory.Result
Returns:
id of the winning player, Player.TEAM_NONE if it's a draw

getWinningTeam

public int getWinningTeam()
Specified by:
getWinningTeam in interface Victory.Result
Returns:
id of the winning team, Player.TEAM_NONE if it's a draw

updateHiScore

protected void updateHiScore()

addPlayerScore

public void addPlayerScore(int id,
                           double score)

addTeamScore

public void addTeamScore(int id,
                         double score)

isWinningPlayer

public boolean isWinningPlayer(int id)
Specified by:
isWinningPlayer in interface Victory.Result
Returns:
true if this is a winning player id (draw == win in this case)

isWinningTeam

public boolean isWinningTeam(int id)
Specified by:
isWinningTeam in interface Victory.Result
Returns:
true if this is a winning team id (draw == win in this case)

victory

public boolean victory()
Specified by:
victory in interface Victory.Result
Returns:
true if the game is about to end since someone has completed the victory conditions

setVictory

public void setVictory(boolean b)

getPlayerScore

public double getPlayerScore(int id)
Specified by:
getPlayerScore in interface Victory.Result
Returns:
player victory level 0.0(total loss) to 1.0 (total victory) anybody not listed can be assumed to be at 0.0 score

getPlayers

public int[] getPlayers()
Description copied from interface: Victory.Result
list players

Specified by:
getPlayers in interface Victory.Result

getTeamScore

public double getTeamScore(int id)
Description copied from interface: Victory.Result
list team scores all teams which are not listed, can be assumed to be at 0.0

Specified by:
getTeamScore in interface Victory.Result

getTeams

public int[] getTeams()
Description copied from interface: Victory.Result
list teams

Specified by:
getTeams in interface Victory.Result

addReport

public void addReport(Report r)

getReports

public java.util.ArrayList<Report> getReports()
Specified by:
getReports in interface Victory.Result
Returns:
arrayList of reports generated by the victory checking. Usually empty when no victory should never be null might contain reports about victoryconditions which are about to be filled or are time triggered

getTrace

protected java.lang.String getTrace()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isDraw

public boolean isDraw()
Specified by:
isDraw in interface Victory.Result
Returns:
if this is a draw