Package robocode.robotinterfaces.peer
Interface ITeamRobotPeer
-
- All Superinterfaces:
IAdvancedRobotPeer
,IBasicRobotPeer
,IStandardRobotPeer
public interface ITeamRobotPeer extends IAdvancedRobotPeer
The team robot peer for team robots likeTeamRobot
.A robot peer is the object that deals with game mechanics and rules, and makes sure your robot abides by them.
- Since:
- 1.6
- Author:
- Pavel Savara (original), Flemming N. Larsen (contributor)
- See Also:
IBasicRobotPeer
,IStandardRobotPeer
,IAdvancedRobotPeer
,IJuniorRobotPeer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
broadcastMessage(java.io.Serializable message)
Broadcasts a message to all teammates.java.util.List<MessageEvent>
getMessageEvents()
Returns a vector containing all MessageEvents currently in the robot's queue.java.lang.String[]
getTeammates()
Returns the names of all teammates, ornull
there is no teammates.boolean
isTeammate(java.lang.String name)
Checks if a given robot name is the name of one of your teammates.void
sendMessage(java.lang.String name, java.io.Serializable message)
Sends a message to one (or more) teammates.-
Methods inherited from interface robocode.robotinterfaces.peer.IAdvancedRobotPeer
addCustomEvent, clearAllEvents, getAllEvents, getBulletHitBulletEvents, getBulletHitEvents, getBulletMissedEvents, getDataDirectory, getDataFile, getDataQuotaAvailable, getEventPriority, getHitByBulletEvents, getHitRobotEvents, getHitWallEvents, getRobotDeathEvents, getScannedRobotEvents, getStatusEvents, isAdjustGunForBodyTurn, isAdjustRadarForBodyTurn, isAdjustRadarForGunTurn, removeCustomEvent, setEventPriority, setInterruptible, setMaxTurnRate, setMaxVelocity, setMove, setResume, setStop, setTurnBody, setTurnGun, setTurnRadar, waitFor
-
Methods inherited from interface robocode.robotinterfaces.peer.IBasicRobotPeer
execute, fire, getBattleFieldHeight, getBattleFieldWidth, getBodyHeading, getBodyTurnRemaining, getCall, getDistanceRemaining, getEnergy, getGraphics, getGunCoolingRate, getGunHeading, getGunHeat, getGunTurnRemaining, getName, getNumRounds, getNumSentries, getOthers, getRadarHeading, getRadarTurnRemaining, getRoundNum, getSentryBorderSize, getTime, getVelocity, getX, getY, move, rescan, setBodyColor, setBulletColor, setCall, setDebugProperty, setFire, setGunColor, setRadarColor, setScanColor, turnBody, turnGun
-
Methods inherited from interface robocode.robotinterfaces.peer.IStandardRobotPeer
resume, setAdjustGunForBodyTurn, setAdjustRadarForBodyTurn, setAdjustRadarForGunTurn, stop, turnRadar
-
-
-
-
Method Detail
-
getTeammates
java.lang.String[] getTeammates()
Returns the names of all teammates, ornull
there is no teammates.Example:
public void run() { // Prints out all teammates String[] teammates = getTeammates(); if (teammates != null) { for (String member : teammates) { out.println(member); } } }
- Returns:
- a String array containing the names of all your teammates, or
null
if there is no teammates. The length of the String array is equal to the number of teammates. - See Also:
isTeammate(String)
,broadcastMessage(Serializable)
,sendMessage(String, Serializable)
-
isTeammate
boolean isTeammate(java.lang.String name)
Checks if a given robot name is the name of one of your teammates.Example:
public void onScannedRobot(ScannedRobotEvent e) { if (isTeammate(e.getName()) { return; } fire(1); }
- Parameters:
name
- the robot name to check- Returns:
true
if the specified name belongs to one of your teammates;false
otherwise.- See Also:
getTeammates()
,broadcastMessage(Serializable)
,sendMessage(String, Serializable)
-
broadcastMessage
void broadcastMessage(java.io.Serializable message) throws java.io.IOException
Broadcasts a message to all teammates.Example:
public void run() { broadcastMessage("I'm here!"); }
- Parameters:
message
- the message to broadcast to all teammates- Throws:
java.io.IOException
- if the message could not be broadcasted to the teammates- See Also:
isTeammate(String)
,getTeammates()
,sendMessage(String, Serializable)
-
sendMessage
void sendMessage(java.lang.String name, java.io.Serializable message) throws java.io.IOException
Sends a message to one (or more) teammates.Example:
public void run() { sendMessage("sample.DroidBot", "I'm here!"); }
- Parameters:
name
- the name of the intended recipient of the messagemessage
- the message to send- Throws:
java.io.IOException
- if the message could not be sent- See Also:
isTeammate(String)
,getTeammates()
,broadcastMessage(Serializable)
-
getMessageEvents
java.util.List<MessageEvent> getMessageEvents()
Returns a vector containing all MessageEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
for (MessageEvent e : getMessageEvents()) { // do something with e }
- Returns:
- a vector containing all MessageEvents currently in the robot's queue
- Since:
- 1.2.6
- See Also:
onMessageReceived(MessageEvent)
,MessageEvent
-
-