fi.utu.cs.hockey.net
Interface Communication

All Superinterfaces:
Position
All Known Implementing Classes:
Client

public interface Communication
extends Position

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

NO_FACEOFF

public static final int NO_FACEOFF
No faceoff.

See Also:
Constant Field Values

CENTER_SPOT

public static final int CENTER_SPOT
Faceoff at the center spot.

See Also:
Constant Field Values

OUR_ENDZONE_LEFT

public static final int OUR_ENDZONE_LEFT
Faceoff at our endzone on the left side.

See Also:
Constant Field Values

OUR_ENDZONE_RIGHT

public static final int OUR_ENDZONE_RIGHT
Faceoff at our endzone on the right side.

See Also:
Constant Field Values

OUR_NEUTRAL_ZONE_LEFT

public static final int OUR_NEUTRAL_ZONE_LEFT
Faceoff at our neutral zone on the left side.

See Also:
Constant Field Values

OUR_NEUTRAL_ZONE_RIGHT

public static final int OUR_NEUTRAL_ZONE_RIGHT
Faceoff at our neutral zone on the right side.

See Also:
Constant Field Values

THEIR_NEUTRAL_ZONE_LEFT

public static final int THEIR_NEUTRAL_ZONE_LEFT
Faceoff at their neutral zone on the left side.

See Also:
Constant Field Values

THEIR_NEUTRAL_ZONE_RIGHT

public static final int THEIR_NEUTRAL_ZONE_RIGHT
Faceoff at their neutral zone on the right side.

See Also:
Constant Field Values

THEIR_ENDZONE_LEFT

public static final int THEIR_ENDZONE_LEFT
Faceoff at their endzone on the left side.

See Also:
Constant Field Values

THEIR_ENDZONE_RIGHT

public static final int THEIR_ENDZONE_RIGHT
Faceoff at their endzone on the right side.

See Also:
Constant Field Values

X_COORDINATE

public static final int X_COORDINATE
Array index for the x-coordinate.

See Also:
Constant Field Values

Y_COORDINATE

public static final int Y_COORDINATE
Array index for the y-coordinate.

See Also:
Constant Field Values

HEADING_ANGLE

public static final int HEADING_ANGLE
Array index for the angle of heading.

See Also:
Constant Field Values
Method Detail

getPlayerName

public java.lang.String getPlayerName()
Returns the player's name.


setPlayerName

public void setPlayerName(java.lang.String s)
Sets the player's name to s. After the player has joined a game, this method will have no effect.

See Also:
isJoined()

getTeamName

public java.lang.String getTeamName()
Returns the name of the player's team.


setTeamName

public void setTeamName(java.lang.String t)
Sets the name of the player's team to t. After the player has joined a game, this method will have no effect.

See Also:
isJoined()

getNumber

public int getNumber()
Returns the player's number.


setNumber

public void setNumber(int n)
Sets the player's number to n. The number should be from the range 1-99. After the player has joined a game, this method will have no effect.

See Also:
isJoined()

getPosition

public int getPosition()
Returns the player's position in the team.

See Also:
Position.GOALKEEPER, Position.LEFT_DEFENSE, Position.RIGHT_DEFENSE, Position.LEFT_WING, Position.RIGHT_WING, Position.CENTER

setPosition

public void setPosition(int p)
Sets the player's position in the team to p. After the player has joined a game, this method will have no effect.

See Also:
isJoined(), Position.GOALKEEPER, Position.LEFT_DEFENSE, Position.RIGHT_DEFENSE, Position.LEFT_WING, Position.RIGHT_WING, Position.CENTER

getHelmetColor

public java.awt.Color getHelmetColor()
Returns the color of the player's helmet.


setHelmetColor

public void setHelmetColor(java.awt.Color h)
Sets the name of the player's helmet to h. After the player has joined a game, this method will have no effect.

See Also:
isJoined()

getJerseyColor

public java.awt.Color getJerseyColor()
Returns the color of the player's jersey.


setJerseyColor

public void setJerseyColor(java.awt.Color j)
Sets the name of the player's jersey to j. After the player has joined a game, this method will have no effect.

See Also:
isJoined()

isInHomeTeam

public boolean isInHomeTeam()
Returns true if the player belongs to the home team; otherwise returns false. Before the player has joined a game, this method returns only false.

See Also:
isJoined()

isJoined

public boolean isJoined()
Returns true, if the player has joined a game. After joining, changes in name, number, position or colors have no effect.

See Also:
setPlayerName(String), setTeamName(String), setNumber(int), setPosition(int), setHelmetColor(Color), setJerseyColor(Color)

shoot

public void shoot(double p)
Shoots the puck with the relative power p, where p is from the range [0.0, 1.0].


dash

public void dash(double p)
Dashes the player with the relative power 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).

See Also:
brake(double)

brake

public 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]. Methods dash and brake cancel out each other (i.e., only the last call will remain active).

See Also:
dash(double)

head

public void head(double a)
Sets the player's heading to the angle a in radians.


say

public void say(long s)
Says the 64-bit long word s. The message is received both by the own team and the opponent.


keepPuck

public void keepPuck()
Keeps the puck, if the player is a goalkeeper. Cancels out any calls to the method shoot.

See Also:
shoot(double)

time

public long time()
Returns the time left in the game in milliseconds.


isGameStopped

public boolean isGameStopped()
Returns whether the game is stopped.


isGameOver

public boolean isGameOver()
Returns whether the game is over.


score

public int score(boolean us)
Returns the score of a team. If us == true, the team is own, otherwise the team is opponent.


puck

public double[] puck()
Returns the location of the puck.

See Also:
X_COORDINATE, Y_COORDINATE

player

public double[] player(boolean us,
                       int p)
Returns the location and the angle of the heading of a player. If 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.

See Also:
X_COORDINATE, Y_COORDINATE, HEADING_ANGLE

messages

public long[] messages(boolean us)
Returns a team's messages. If 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].


faceoff

public int faceoff()
Returns the place of the faceoff.

See Also:
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

isGoal

public boolean isGoal(boolean us)
Returns whether a team has scored a goal. If us == true, the team is own, otherwise the team is opponent.


isIcing

public boolean isIcing(boolean us)
Returns whether a team is in icing. If us == true, the team is own, otherwise the team is opponent.


isOffside

public boolean isOffside(boolean us)
Returns whether a team is in offside. If us == true, the team is own, otherwise the team is opponent.


isInterferingGoalie

public boolean isInterferingGoalie(boolean us)
Returns whether any member of a team is interfering the other team's goalie. If us == true, the team is own, otherwise the team is opponent.


isGoalieKeepingPuck

public boolean isGoalieKeepingPuck(boolean us)
Returns whether the goalkeeper of a team is keeping the puck. If us == true, the team is own, otherwise the team is opponent.


isFoul

public boolean isFoul(boolean us)
Returns whether a team has caused some other foul. If us == true, the team is own, otherwise the team is opponent.


isPuckUnplayable

public boolean isPuckUnplayable()
Returns true if the puck has become unplayable.