Realtimebattle-Team-Framework Manual
Author: David Tibbe and Tino Truppel

# Chapter 2.2.3 - The States

All states have to be derived by Strategies::State (described in strategies/state.h). This abstract class provides the following methods:

- `reset()`
  It is called every time a new game starts to clear the states and set the initial setting.
- `receiveRTBMessageXY()`
  For each message XY (e.g. collisions, coordinates, radar infos) the Realtime Battle Server is able to send during a running game (see [LINK:rtb protocol] for details), the corresponding method of the current state is invoked. For example, if you are interested in your energy level, simply overwrite the method `receiveRTBMessageEnergy()`.

All client states are also inherited from Strategies::ClientState (strategies/clientstate.h) that additionally provides the following methods:

- `roundFinished()`
  This method is called after all messages from the RealTimeBattle server are received in this round and were already sent to the master server. Use this message to do all calculations that can be made until the server tips will arrive.
- `reactOnServerTip()`
  This method is called for every server tip sent by the server states of the corresponding server coordinator in the master server. Use this method to react according the tips of the master server part of your strategy.
- `sendRTBMessages()`
  If this method is called, you should send the pending commands to the Realtime Battle server.
- `sendRTBMessageXY()`
  Use these messages to send any kind of allowed commands XY to the Realtime Battle server (e.g. to shoot, use method `sendRTBMessageShoot()`), see the [LINK:header] file and the [LINK:rtb protocol] for details.
- `setCurrentClientState()`
  Use this method to switch to another client state. This is necessary if your robot wants to change to another internal state (for example from attacking to braking). Since the new state is described by a scalar value, it is a good idea to define an enumeration for the different states (see notes about writing a strategy).

All server states are also inherited from Strategies::ServerState (strategies/serverstate.h) that additionally provides the following methods:

- `sendServerTipString()`
  Use this method to send a strategy defined server tip to the corresponding client coordinator / current client state.
- `sendServerTips()`
  If this method is invoked, you should send your last server tips to the client.
- `setCurrentServerState()`
  With this method, you can switch to another server state. Also in this case you should make use of an enumeration to identify you states (see notes about writing a strategy).