|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimulator.model.debug.SMfacade
public class SMfacade
A trivial implementation of the required simulator model interfaces for debugging purposes. In most cases this simply logs the calls to a log file.
Field Summary |
---|
Fields inherited from interface simulator.model.ISimulatorView |
---|
BALL_RADIUS, FIELD_LENGTH, FIELD_WIDTH, GOAL_WIDTH, NUMBER_OF_PLAYERS, PLAYER_RADIUS |
Constructor Summary | |
---|---|
SMfacade()
|
Method Summary | |
---|---|
void |
accelerate(Side side,
int p,
double a)
Sets the acceleration for the player |
void |
endGame()
Indicates game should end due to a request from one or more teams. |
CartesianVect |
getBallPosition()
|
PolarVect |
getBallVelocity()
|
Student |
getFieldName()
Which simulator is the host. |
ISimulatorNet |
getISimulatorNet()
Get the object that implements the ISimulatorNet interface. |
CartesianVect |
getPlayerPosition(Side t,
int p)
The position of a particular player. |
PolarVect |
getPlayerVelocity(Side t,
int p)
The orientation of a particular player. |
java.lang.String |
getStatusMessage()
The last status message. |
Student |
getTeamName(Side t)
The name of each team. |
int |
getTeamScore(Side t)
The number of goals scored by each team. |
int |
getTime()
The number of milliseconds played. |
boolean |
isGameInProgress()
|
boolean |
isPlayerInGame(Side t,
int p)
Is the player in play |
void |
kick(Side side,
int p,
double v,
double alpha)
Updates field data in response to a kick request |
void |
placeBall(CartesianVect l)
placeBall places ball at given coordinates |
void |
placePlayer(Side side,
int p,
CartesianVect l)
places player at given coordinates |
void |
setNet(INetSimulator n)
Set the network layer. |
void |
setStatusMessage(java.lang.String msg)
|
void |
setTeams(Student west,
Student east)
Indicates which team is on each side. |
void |
setTestMode(boolean m)
Set the model into 'test mode' or not. |
void |
setTime(int t)
setTime sets game time |
void |
spin(Side side,
int p,
double av)
Sets angular velocity for the player |
void |
startGame()
Indicates that game should start (time == 0). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SMfacade()
Method Detail |
---|
public void setNet(INetSimulator n)
ISimulatorNet
setNet
in interface ISimulatorNet
public void startGame()
ISimulatorNet
Precondidtion: setTeams and setNet have been called and
isGameInProgress() is false.
Postcondition: isGameInProgress()
startGame
in interface ISimulatorNet
public void endGame()
ISimulatorNet
Precondition: true
Postcondition: !isGameInProgress()
endGame
in interface ISimulatorNet
public void accelerate(Side side, int p, double a)
ISimulatorNet
Precondition: isGameInProgress()
accelerate
in interface ISimulatorNet
p
- Player number, in {0, 1, 2, 3, 4}a
- rate of acceleration, -5 <= a <= 1public void kick(Side side, int p, double v, double alpha)
ISimulatorNet
Precondition: isGameInProgress()
kick
in interface ISimulatorNet
side
- the team sidep
- Player number, in {0, 1, 2, 3, 4}v
- Change in the ball's velocity. 0 <= v <= 10alpha
- Offset in degrees from a line connecting the player's
centre to the ball's centre. -45 <= alpha <= 45public void placePlayer(Side side, int p, CartesianVect l)
ISimulatorNet
Precondition: game is in test mode
placePlayer
in interface ISimulatorNet
side
- Player teamp
- Player number. In {0, 1, 2, 3, 4}l
- new location for playerpublic void setTeams(Student west, Student east)
ISimulatorNet
setTeams
in interface ISimulatorNet
west
- team on WEST side.east
- team on EAST side.public void spin(Side side, int p, double av)
ISimulatorNet
Precondition: isGameInProgress()
spin
in interface ISimulatorNet
p
- Player number in {0, 1, 2, 3, 4}av
- double Angular velocity in degrees per second. -90 <= av <= 90public ISimulatorNet getISimulatorNet()
ISimulatorView
getISimulatorNet
in interface ISimulatorView
public void setTestMode(boolean m)
ISimulatorView
setTestMode
in interface ISimulatorView
m
- true to set the model in test mode, false for normal play modepublic Student getFieldName()
ISimulatorView
getFieldName
in interface ISimulatorView
public java.lang.String getStatusMessage()
ISimulatorView
getStatusMessage
in interface ISimulatorView
public void setStatusMessage(java.lang.String msg)
public boolean isGameInProgress()
isGameInProgress
in interface ISimulatorView
public Student getTeamName(Side t)
ISimulatorView
Precondition: isGameInProgress()
getTeamName
in interface ISimulatorView
t
- The team, 0 or 1.public int getTeamScore(Side t)
ISimulatorView
Precondition: isGameInProgress()
getTeamScore
in interface ISimulatorView
t
- The team, 0 or 1.public int getTime()
ISimulatorView
Precondition: isGameInProgress()
getTime
in interface ISimulatorView
public CartesianVect getPlayerPosition(Side t, int p)
ISimulatorView
Precondition: isGameInProgress()
getPlayerPosition
in interface ISimulatorView
t
- The team, 0 or 1.p
- The player: 0 less than or equal p, p less than number_of_players()public boolean isPlayerInGame(Side t, int p)
ISimulatorView
isPlayerInGame
in interface ISimulatorView
t
- team sidep
- player. 0 less than or equal p, p less than number_of_players()
public PolarVect getPlayerVelocity(Side t, int p)
ISimulatorView
Precondition: isGameInProgress()
getPlayerVelocity
in interface ISimulatorView
t
- The team, 0 or 1.p
- The player: 0 less than or equal p, p less than NUMBER_OF_PLAYERS()public CartesianVect getBallPosition()
getBallPosition
in interface ISimulatorView
public PolarVect getBallVelocity()
getBallVelocity
in interface ISimulatorView
public void placeBall(CartesianVect l)
ISimulatorNet
Precondition: game is in test mode
placeBall
in interface ISimulatorNet
l
- location to place the ballpublic void setTime(int t)
ISimulatorNet
Precondition: game is in test mode
setTime
in interface ISimulatorNet
t
- int Game time is set to t (in miliseconds)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |