### robocode

# Class TeamRobot

- `java.lang.Object`
- - `robocode._RobotBase`
  - - `robocode._Robot`
    - - `robocode.Robot`
      - - `robocode._AdvancedRobot`
        - - `robocode._AdvancedRadiansRobot`
          - - `robocode.AdvancedRobot`
            - - `robocode.TeamRobot`

Implemented Interfaces:
  IAdvancedEvents, IAdvancedRobot, IBasicEvents, IBasicEvents2, IBasicRobot, IInteractiveEvents, IInteractiveRobot, IPaintEvents, IPaintRobot, ITeamEvents, ITeamRobot, Runnable

`public class TeamRobot`
`extends AdvancedRobot`
`implements ITeamRobot, ITeamEvents`

An an advanced type of robot that supports sending messages between team mates in a robot team.

If you have not done already, you should create a `Robot` or `AdvancedRobot` first.

Authors:
  Mathew A. Nelson (original)
  Flemming N. Larsen (contributor)
  Pavel Savara (contributor)

See Also:
  `JuniorRobot`, `Robot`, `AdvancedRobot`, `Droid`

  ## Field Summary

  ### Fields inherited from class robocode._RobotBase

  `out`

  ## Method Summary

  `void`

  `broadcastMessage(Serializable message)`
    Broadcasts a message to all teammates.

  `Vector<MessageEvent>`

  `getMessageEvents()`
    Returns a vector containing all MessageEvents currently in the robot's queue.

  `ITeamEvents`

  `getTeamEventListener()`
    Do not call this method!

  `String[]`

  `getTeammates()`
    Returns the names of all teammates, or `null` there is no teammates.

  `boolean`

  `isTeammate(String name)`
    Checks if a given robot name is the name of one of your teammates.

  `void`

  `onMessageReceived(MessageEvent event)`

  `void`

  `sendMessage(String name, Serializable message)`
    Sends a message to one (or more) teammates.

  ### Methods inherited from class robocode.AdvancedRobot

  `addCustomEvent`, `clearAllEvents`, `execute`, `getAdvancedEventListener`, `getAllEvents`, `getBulletHitBulletEvents`, `getBulletHitEvents`, `getBulletMissedEvents`, `getDataDirectory`, `getDataFile`, `getDataQuotaAvailable`, `getDistanceRemaining`, `getEventPriority`, `getGunHeadingRadians`, `getGunTurnRemaining`, `getGunTurnRemainingRadians`, `getHeadingRadians`, `getHitByBulletEvents`, `getHitRobotEvents`, `getHitWallEvents`, `getRadarHeadingRadians`, `getRadarTurnRemaining`, `getRadarTurnRemainingRadians`, `getRobotDeathEvents`, `getScannedRobotEvents`, `getStatusEvents`, `getTurnRemaining`, `getTurnRemainingRadians`, `isAdjustGunForRobotTurn`, `isAdjustRadarForGunTurn`, `isAdjustRadarForRobotTurn`, `onCustomEvent`, `onSkippedTurn`, `removeCustomEvent`, `setAhead`, `setBack`, `setEventPriority`, `setFire`, `setFireBullet`, `setMaxTurnRate`, `setMaxVelocity`, `setResume`, `setStop`, `setStop`, `setTurnGunLeft`, `setTurnGunLeftRadians`, `setTurnGunRight`, `setTurnGunRightRadians`, `setTurnLeft`, `setTurnLeftRadians`, `setTurnRadarLeft`, `setTurnRadarLeftRadians`, `setTurnRadarRight`, `setTurnRadarRightRadians`, `setTurnRight`, `setTurnRightRadians`, `turnGunLeftRadians`, `turnGunRightRadians`, `turnLeftRadians`, `turnRadarLeftRadians`, `turnRadarRightRadians`, `turnRightRadians`, `void onDeath`, `void setInterruptible`, `waitFor`

  ### Methods inherited from class robocode._AdvancedRadiansRobot

  `getGunHeadingRadians`, `getGunTurnRemainingRadians`, `getHeadingRadians`, `getRadarHeadingRadians`, `getRadarTurnRemainingRadians`, `getTurnRemainingRadians`, `setTurnGunLeftRadians`, `setTurnGunRightRadians`, `setTurnLeftRadians`, `setTurnRadarLeftRadians`, `setTurnRadarRightRadians`, `setTurnRightRadians`, `turnGunLeftRadians`, `turnGunRightRadians`, `turnLeftRadians`, `turnRadarLeftRadians`, `turnRadarRightRadians`, `turnRightRadians`

  ### Methods inherited from class robocode._AdvancedRobot

  `double getGunHeadingDegrees`, `double getHeadingDegrees`, `double getRadarHeadingDegrees`, `int getMaxWaitCount`, `int getWaitCount`, `void endTurn`, `void setTurnGunLeftDegrees`, `void setTurnGunRightDegrees`, `void setTurnLeftDegrees`, `void setTurnRadarLeftDegrees`, `void setTurnRadarRightDegrees`, `void setTurnRightDegrees`, `void turnGunLeftDegrees`, `void turnGunRightDegrees`, `void turnLeftDegrees`, `void turnRadarLeftDegrees`, `void turnRadarRightDegrees`, `void turnRightDegrees`

  ### Methods inherited from class robocode.Robot

  `ahead`, `back`, `doNothing`, `fire`, `fireBullet`, `getBasicEventListener`, `getBattleFieldHeight`, `getBattleFieldWidth`, `getEnergy`, `getGraphics`, `getGunCoolingRate`, `getGunHeading`, `getGunHeat`, `getHeading`, `getHeight`, `getInteractiveEventListener`, `getName`, `getNumRounds`, `getOthers`, `getPaintEventListener`, `getRadarHeading`, `getRobotRunnable`, `getRoundNum`, `getTime`, `getVelocity`, `getWidth`, `getX`, `getY`, `onBattleEnded`, `onBulletHit`, `onBulletHitBullet`, `onBulletMissed`, `onDeath`, `onHitByBullet`, `onHitRobot`, `onHitWall`, `onKeyPressed`, `onKeyReleased`, `onKeyTyped`, `onMouseClicked`, `onMouseDragged`, `onMouseEntered`, `onMouseExited`, `onMouseMoved`, `onMousePressed`, `onMouseReleased`, `onMouseWheelMoved`, `onPaint`, `onRobotDeath`, `onScannedRobot`, `onStatus`, `onWin`, `resume`, `run`, `scan`, `setAdjustGunForRobotTurn`, `setAdjustRadarForGunTurn`, `setAdjustRadarForRobotTurn`, `setAllColors`, `setBodyColor`, `setBulletColor`, `setColors`, `setColors`, `setDebugProperty`, `setGunColor`, `setRadarColor`, `setScanColor`, `stop`, `stop`, `turnGunLeft`, `turnGunRight`, `turnLeft`, `turnRadarLeft`, `turnRadarRight`, `turnRight`, `void finalize`

  ### Methods inherited from class robocode._Robot

  `String getGunImageName`, `String getRadarImageName`, `String getRobotImageName`, `double getGunCharge`, `double getLife`, `int getBattleNum`, `int getNumBattles`, `setInterruptible`, `void setGunImageName`, `void setRadarImageName`, `void setRobotImageName`

  ### Methods inherited from class robocode._RobotBase

  `setOut`, `setPeer`

## Method Details

### broadcastMessage

    public void broadcastMessage(Serializable message)
                throws IOException

> Broadcasts a message to all teammates.

> Example:

>        public void run() {
>            broadcastMessage("I'm here!");
>        }

> Parameters:
>   `message` - the message to broadcast to all teammates
> See Also:
>   `isTeammate(String)`, `getTeammates()`, `sendMessage(String,Serializable)`

### getMessageEvents

    public Vector<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`

### getTeamEventListener

    public final ITeamEvents getTeamEventListener()

> Do not call this method!

> Specified by:
>   getTeamEventListener in interface ITeamRobot

### getTeammates

    public String[] getTeammates()

> Returns the names of all teammates, or `null` 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

    public boolean isTeammate(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)`

### onMessageReceived

    public void onMessageReceived(MessageEvent event)

> Specified by:
>   onMessageReceived in interface ITeamEvents

### sendMessage

    public void sendMessage(String name,
                            Serializable message)
                throws 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 message
>   `message` - the message to send
> See Also:
>   `isTeammate(String)`, `getTeammates()`, `broadcastMessage(Serializable)`