|
||||||||||
| 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.Objectjava.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 Communicationpublic final void setPlayerName(java.lang.String s)
Communications.
After the player has joined a game,
this method will have no effect.
setPlayerName in interface CommunicationCommunication.isJoined()public final java.lang.String getTeamName()
Communication
getTeamName in interface Communicationpublic final void setTeamName(java.lang.String t)
Communicationt.
After the player has joined a game,
this method will have no effect.
setTeamName in interface CommunicationCommunication.isJoined()public final int getNumber()
Communication
getNumber in interface Communicationpublic final void setNumber(int n)
Communicationn.
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 CommunicationCommunication.isJoined()public final int getPosition()
Communication
getPosition in interface CommunicationPosition.GOALKEEPER,
Position.LEFT_DEFENSE,
Position.RIGHT_DEFENSE,
Position.LEFT_WING,
Position.RIGHT_WING,
Position.CENTERpublic final void setPosition(int p)
Communicationp.
After the player has joined a game,
this method will have no effect.
setPosition in interface CommunicationCommunication.isJoined(),
Position.GOALKEEPER,
Position.LEFT_DEFENSE,
Position.RIGHT_DEFENSE,
Position.LEFT_WING,
Position.RIGHT_WING,
Position.CENTERpublic final java.awt.Color getHelmetColor()
Communication
getHelmetColor in interface Communicationpublic final void setHelmetColor(java.awt.Color h)
Communicationh.
After the player has joined a game,
this method will have no effect.
setHelmetColor in interface CommunicationCommunication.isJoined()public final java.awt.Color getJerseyColor()
Communication
getJerseyColor in interface Communicationpublic final void setJerseyColor(java.awt.Color j)
Communicationj.
After the player has joined a game,
this method will have no effect.
setJerseyColor in interface CommunicationCommunication.isJoined()public final boolean isInHomeTeam()
Communicationtrue 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 CommunicationCommunication.isJoined()public final boolean isJoined()
Communicationtrue, if the player has
joined a game. After joining, changes in
name, number, position or colors have no effect.
isJoined in interface CommunicationCommunication.setPlayerName(String),
Communication.setTeamName(String),
Communication.setNumber(int),
Communication.setPosition(int),
Communication.setHelmetColor(Color),
Communication.setJerseyColor(Color)public final void shoot(double p)
Communicationp,
where p is from the range [0.0, 1.0].
shoot in interface Communicationpublic final void dash(double p)
Communicationp,
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 CommunicationCommunication.brake(double)public final void brake(double p)
Communicationp, 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 CommunicationCommunication.dash(double)public final void head(double a)
Communicationa in radians.
head in interface Communicationpublic final void say(long s)
Communications.
The message is received both by the own team
and the opponent.
say in interface Communicationpublic final void keepPuck()
Communicationshoot.
keepPuck in interface CommunicationCommunication.shoot(double)public final long time()
Communication
time in interface Communicationpublic final boolean isGameStopped()
Communication
isGameStopped in interface Communicationpublic final boolean isGameOver()
Communication
isGameOver in interface Communicationpublic final int score(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
score in interface Communicationpublic final double[] puck()
Communication
puck in interface CommunicationCommunication.X_COORDINATE,
Communication.Y_COORDINATE
public final double[] player(boolean us,
int p)
Communicationus == 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 CommunicationCommunication.X_COORDINATE,
Communication.Y_COORDINATE,
Communication.HEADING_ANGLEpublic final long[] messages(boolean us)
Communicationus == 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 Communicationpublic final int faceoff()
Communication
faceoff in interface CommunicationCommunication.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_RIGHTpublic final boolean isGoal(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
isGoal in interface Communicationpublic final boolean isIcing(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
isIcing in interface Communicationpublic final boolean isOffside(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
isOffside in interface Communicationpublic final boolean isInterferingGoalie(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
isInterferingGoalie in interface Communicationpublic final boolean isGoalieKeepingPuck(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
isGoalieKeepingPuck in interface Communicationpublic final boolean isFoul(boolean us)
Communicationus == true, the team is own,
otherwise the team is opponent.
isFoul in interface Communicationpublic final boolean isPuckUnplayable()
Communicationtrue 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 | |||||||||