|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--fi.utu.cs.hockey.net.Client
A hockey player client.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface fi.utu.cs.hockey.net.Communication |
CENTER_SPOT, HEADING_ANGLE, NO_FACEOFF, OUR_ENDZONE_LEFT, OUR_ENDZONE_RIGHT, OUR_NEUTRAL_ZONE_LEFT, OUR_NEUTRAL_ZONE_RIGHT, THEIR_ENDZONE_LEFT, THEIR_ENDZONE_RIGHT, THEIR_NEUTRAL_ZONE_LEFT, THEIR_NEUTRAL_ZONE_RIGHT, X_COORDINATE, Y_COORDINATE |
Fields inherited from interface fi.utu.cs.hockey.Position |
CENTER, GOALKEEPER, LEFT_DEFENSE, LEFT_WING, RIGHT_DEFENSE, RIGHT_WING |
Constructor Summary | |
protected |
Client()
Creates a player client. |
protected |
Client(java.lang.String s,
java.lang.String t,
int n,
int p,
java.awt.Color h,
java.awt.Color j)
Creates a player client with name s ,
team name t , number n ,
position p , helmet color h ,
and jersey color j . |
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 |
connect(java.lang.String sAddr,
int sPort,
int iPort,
java.lang.String gAddr,
int gPort)
Connects to a game server. |
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. |
void |
finalize()
Cleanup for the garbage collector. |
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. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected Client()
protected Client(java.lang.String s, java.lang.String t, int n, int p, java.awt.Color h, java.awt.Color j)
s
,
team name t
, number n
,
position p
, helmet color h
,
and jersey color j
.
Method Detail |
public void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void connect(java.lang.String sAddr, int sPort, int iPort, java.lang.String gAddr, int gPort)
gAddr
must be a D-class address (i.e., within the range
224.0.0.0-239.255.255.255). Preferably, it should be
from the range 239.0.0.0-239.255.255.255 which is intended
for local area network (LAN) use only.
sAddr
- Server addresssPort
- Server port for client inputiPort
- Server port for client initializationgAddr
- Multicast group for server outputgPort
- Multicast portpublic final java.lang.String getPlayerName()
Communication
getPlayerName
in interface Communication
public final void setPlayerName(java.lang.String s)
Communication
s
.
After the player has joined a game,
this method will have no effect.
setPlayerName
in interface Communication
Communication.isJoined()
public final java.lang.String getTeamName()
Communication
getTeamName
in interface Communication
public final void setTeamName(java.lang.String t)
Communication
t
.
After the player has joined a game,
this method will have no effect.
setTeamName
in interface Communication
Communication.isJoined()
public final int getNumber()
Communication
getNumber
in interface Communication
public final void setNumber(int n)
Communication
n
.
The number should be from the range 1-99.
After the player has joined a game,
this method will have no effect.
setNumber
in interface Communication
Communication.isJoined()
public final int getPosition()
Communication
getPosition
in interface Communication
Position.GOALKEEPER
,
Position.LEFT_DEFENSE
,
Position.RIGHT_DEFENSE
,
Position.LEFT_WING
,
Position.RIGHT_WING
,
Position.CENTER
public final void setPosition(int p)
Communication
p
.
After the player has joined a game,
this method will have no effect.
setPosition
in interface Communication
Communication.isJoined()
,
Position.GOALKEEPER
,
Position.LEFT_DEFENSE
,
Position.RIGHT_DEFENSE
,
Position.LEFT_WING
,
Position.RIGHT_WING
,
Position.CENTER
public final java.awt.Color getHelmetColor()
Communication
getHelmetColor
in interface Communication
public final void setHelmetColor(java.awt.Color h)
Communication
h
.
After the player has joined a game,
this method will have no effect.
setHelmetColor
in interface Communication
Communication.isJoined()
public final java.awt.Color getJerseyColor()
Communication
getJerseyColor
in interface Communication
public final void setJerseyColor(java.awt.Color j)
Communication
j
.
After the player has joined a game,
this method will have no effect.
setJerseyColor
in interface Communication
Communication.isJoined()
public final boolean isInHomeTeam()
Communication
true
if the player
belongs to the home team; otherwise returns
false
.
Before the player has joined a game,
this method returns only false
.
isInHomeTeam
in interface Communication
Communication.isJoined()
public final boolean isJoined()
Communication
true
, if the player has
joined a game. After joining, changes in
name, number, position or colors have no effect.
isJoined
in interface Communication
Communication.setPlayerName(String)
,
Communication.setTeamName(String)
,
Communication.setNumber(int)
,
Communication.setPosition(int)
,
Communication.setHelmetColor(Color)
,
Communication.setJerseyColor(Color)
public final void shoot(double p)
Communication
p
,
where p
is from the range [0.0, 1.0].
shoot
in interface Communication
public final void dash(double p)
Communication
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
in interface Communication
Communication.brake(double)
public final void brake(double p)
Communication
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
in interface Communication
Communication.dash(double)
public final void head(double a)
Communication
a
in radians.
head
in interface Communication
public final void say(long s)
Communication
s
.
The message is received both by the own team
and the opponent.
say
in interface Communication
public final void keepPuck()
Communication
shoot
.
keepPuck
in interface Communication
Communication.shoot(double)
public final long time()
Communication
time
in interface Communication
public final boolean isGameStopped()
Communication
isGameStopped
in interface Communication
public final boolean isGameOver()
Communication
isGameOver
in interface Communication
public final int score(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
score
in interface Communication
public final double[] puck()
Communication
puck
in interface Communication
Communication.X_COORDINATE
,
Communication.Y_COORDINATE
public final double[] player(boolean us, int p)
Communication
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.
player
in interface Communication
Communication.X_COORDINATE
,
Communication.Y_COORDINATE
,
Communication.HEADING_ANGLE
public final long[] messages(boolean us)
Communication
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]
.
messages
in interface Communication
public final int faceoff()
Communication
faceoff
in interface Communication
Communication.NO_FACEOFF
,
Communication.CENTER_SPOT
,
Communication.OUR_ENDZONE_LEFT
,
Communication.OUR_ENDZONE_RIGHT
,
Communication.OUR_NEUTRAL_ZONE_LEFT
,
Communication.OUR_NEUTRAL_ZONE_RIGHT
,
Communication.THEIR_NEUTRAL_ZONE_LEFT
,
Communication.THEIR_NEUTRAL_ZONE_RIGHT
,
Communication.THEIR_ENDZONE_LEFT
,
Communication.THEIR_ENDZONE_RIGHT
public final boolean isGoal(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
isGoal
in interface Communication
public final boolean isIcing(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
isIcing
in interface Communication
public final boolean isOffside(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
isOffside
in interface Communication
public final boolean isInterferingGoalie(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
isInterferingGoalie
in interface Communication
public final boolean isGoalieKeepingPuck(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
isGoalieKeepingPuck
in interface Communication
public final boolean isFoul(boolean us)
Communication
us == true
, the team is own,
otherwise the team is opponent.
isFoul
in interface Communication
public final boolean isPuckUnplayable()
Communication
true
if the puck has become
unplayable.
isPuckUnplayable
in interface Communication
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |