|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Communication between a hockey player client and server from the
client's perspective.
The client has six methods for affecting the server:
shoot
, dash
, brake
,
head
, say
, and keepPuck
.
On the other hand, the client receives from the server,
in addition to the state of the game, the location
of the puck, the location, orientation and messages from
all players.
Field Summary | |
static int |
CENTER_SPOT
Faceoff at the center spot. |
static int |
HEADING_ANGLE
Array index for the angle of heading. |
static int |
NO_FACEOFF
No faceoff. |
static int |
OUR_ENDZONE_LEFT
Faceoff at our endzone on the left side. |
static int |
OUR_ENDZONE_RIGHT
Faceoff at our endzone on the right side. |
static int |
OUR_NEUTRAL_ZONE_LEFT
Faceoff at our neutral zone on the left side. |
static int |
OUR_NEUTRAL_ZONE_RIGHT
Faceoff at our neutral zone on the right side. |
static int |
THEIR_ENDZONE_LEFT
Faceoff at their endzone on the left side. |
static int |
THEIR_ENDZONE_RIGHT
Faceoff at their endzone on the right side. |
static int |
THEIR_NEUTRAL_ZONE_LEFT
Faceoff at their neutral zone on the left side. |
static int |
THEIR_NEUTRAL_ZONE_RIGHT
Faceoff at their neutral zone on the right side. |
static int |
X_COORDINATE
Array index for the x-coordinate. |
static int |
Y_COORDINATE
Array index for the y-coordinate. |
Fields inherited from interface fi.utu.cs.hockey.Position |
CENTER, GOALKEEPER, LEFT_DEFENSE, LEFT_WING, RIGHT_DEFENSE, RIGHT_WING |
Method Summary | |
void |
brake(double p)
Brakes (or dashes backwards) the player with the relative power p , where p
is from the range [0.0, 1.0].
|
void |
dash(double p)
Dashes the player with the relative power p ,
where p is from the range [0.0, 1.0].
|
int |
faceoff()
Returns the place of the faceoff. |
java.awt.Color |
getHelmetColor()
Returns the color of the player's helmet. |
java.awt.Color |
getJerseyColor()
Returns the color of the player's jersey. |
int |
getNumber()
Returns the player's number. |
java.lang.String |
getPlayerName()
Returns the player's name. |
int |
getPosition()
Returns the player's position in the team. |
java.lang.String |
getTeamName()
Returns the name of the player's team. |
void |
head(double a)
Sets the player's heading to the angle a in radians. |
boolean |
isFoul(boolean us)
Returns whether a team has caused some other foul. |
boolean |
isGameOver()
Returns whether the game is over. |
boolean |
isGameStopped()
Returns whether the game is stopped. |
boolean |
isGoal(boolean us)
Returns whether a team has scored a goal. |
boolean |
isGoalieKeepingPuck(boolean us)
Returns whether the goalkeeper of a team is keeping the puck. |
boolean |
isIcing(boolean us)
Returns whether a team is in icing. |
boolean |
isInHomeTeam()
Returns true if the player
belongs to the home team; otherwise returns
false .
|
boolean |
isInterferingGoalie(boolean us)
Returns whether any member of a team is interfering the other team's goalie. |
boolean |
isJoined()
Returns true , if the player has
joined a game. |
boolean |
isOffside(boolean us)
Returns whether a team is in offside. |
boolean |
isPuckUnplayable()
Returns true if the puck has become
unplayable. |
void |
keepPuck()
Keeps the puck, if the player is a goalkeeper. |
long[] |
messages(boolean us)
Returns a team's messages. |
double[] |
player(boolean us,
int p)
Returns the location and the angle of the heading of a player. |
double[] |
puck()
Returns the location of the puck. |
void |
say(long s)
Says the 64-bit long word s .
|
int |
score(boolean us)
Returns the score of a team. |
void |
setHelmetColor(java.awt.Color h)
Sets the name of the player's helmet to h .
|
void |
setJerseyColor(java.awt.Color j)
Sets the name of the player's jersey to j .
|
void |
setNumber(int n)
Sets the player's number to n .
|
void |
setPlayerName(java.lang.String s)
Sets the player's name to s .
|
void |
setPosition(int p)
Sets the player's position in the team to p .
|
void |
setTeamName(java.lang.String t)
Sets the name of the player's team to t .
|
void |
shoot(double p)
Shoots the puck with the relative power p ,
where p is from the range [0.0, 1.0]. |
long |
time()
Returns the time left in the game in milliseconds. |
Field Detail |
public static final int NO_FACEOFF
public static final int CENTER_SPOT
public static final int OUR_ENDZONE_LEFT
public static final int OUR_ENDZONE_RIGHT
public static final int OUR_NEUTRAL_ZONE_LEFT
public static final int OUR_NEUTRAL_ZONE_RIGHT
public static final int THEIR_NEUTRAL_ZONE_LEFT
public static final int THEIR_NEUTRAL_ZONE_RIGHT
public static final int THEIR_ENDZONE_LEFT
public static final int THEIR_ENDZONE_RIGHT
public static final int X_COORDINATE
public static final int Y_COORDINATE
public static final int HEADING_ANGLE
Method Detail |
public java.lang.String getPlayerName()
public void setPlayerName(java.lang.String s)
s
.
After the player has joined a game,
this method will have no effect.
isJoined()
public java.lang.String getTeamName()
public void setTeamName(java.lang.String t)
t
.
After the player has joined a game,
this method will have no effect.
isJoined()
public int getNumber()
public void setNumber(int n)
n
.
The number should be from the range 1-99.
After the player has joined a game,
this method will have no effect.
isJoined()
public int getPosition()
Position.GOALKEEPER
,
Position.LEFT_DEFENSE
,
Position.RIGHT_DEFENSE
,
Position.LEFT_WING
,
Position.RIGHT_WING
,
Position.CENTER
public void setPosition(int p)
p
.
After the player has joined a game,
this method will have no effect.
isJoined()
,
Position.GOALKEEPER
,
Position.LEFT_DEFENSE
,
Position.RIGHT_DEFENSE
,
Position.LEFT_WING
,
Position.RIGHT_WING
,
Position.CENTER
public java.awt.Color getHelmetColor()
public void setHelmetColor(java.awt.Color h)
h
.
After the player has joined a game,
this method will have no effect.
isJoined()
public java.awt.Color getJerseyColor()
public void setJerseyColor(java.awt.Color j)
j
.
After the player has joined a game,
this method will have no effect.
isJoined()
public boolean isInHomeTeam()
true
if the player
belongs to the home team; otherwise returns
false
.
Before the player has joined a game,
this method returns only false
.
isJoined()
public boolean isJoined()
true
, if the player has
joined a game. After joining, changes in
name, number, position or colors have no effect.
setPlayerName(String)
,
setTeamName(String)
,
setNumber(int)
,
setPosition(int)
,
setHelmetColor(Color)
,
setJerseyColor(Color)
public void shoot(double p)
p
,
where p
is from the range [0.0, 1.0].
public void dash(double p)
p
,
where p
is from the range [0.0, 1.0].
Methods dash
and brake
cancel out each other (i.e., only the last call
will remain active).
brake(double)
public void brake(double p)
p
, where p
is from the range [0.0, 1.0].
Methods dash
and brake
cancel out each other (i.e., only the last call
will remain active).
dash(double)
public void head(double a)
a
in radians.
public void say(long s)
s
.
The message is received both by the own team
and the opponent.
public void keepPuck()
shoot
.
shoot(double)
public long time()
public boolean isGameStopped()
public boolean isGameOver()
public int score(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public double[] puck()
X_COORDINATE
,
Y_COORDINATE
public double[] player(boolean us, int p)
us == true
, the player is in the own
team, otherwise in the opponent team. The parameter
p
indicates the position of the player.
For example, the player's own position can be retrieved
with the method call
double[] s = player(true, getPosition())
.
Now, the player is in the coordinate position
(s[X_COORDINATE]
, s[Y_COORDINATE]
)
and has the heading s[HEADING_ANGLE]
in radians.
X_COORDINATE
,
Y_COORDINATE
,
HEADING_ANGLE
public long[] messages(boolean us)
us == true
, the messages originate
from the own team, otherwise fromthe opponent team.
For example, the message from the own team's
goalkeeper can be retrieved with the method call
long msg = messages(true)[GOALKEEPER]
.
public int faceoff()
NO_FACEOFF
,
CENTER_SPOT
,
OUR_ENDZONE_LEFT
,
OUR_ENDZONE_RIGHT
,
OUR_NEUTRAL_ZONE_LEFT
,
OUR_NEUTRAL_ZONE_RIGHT
,
THEIR_NEUTRAL_ZONE_LEFT
,
THEIR_NEUTRAL_ZONE_RIGHT
,
THEIR_ENDZONE_LEFT
,
THEIR_ENDZONE_RIGHT
public boolean isGoal(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public boolean isIcing(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public boolean isOffside(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public boolean isInterferingGoalie(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public boolean isGoalieKeepingPuck(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public boolean isFoul(boolean us)
us == true
, the team is own,
otherwise the team is opponent.
public boolean isPuckUnplayable()
true
if the puck has become
unplayable.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |