This class is really the "bridge" between the "coach" (whether it would be a human or a computer) and the rules engine. More...
#include <Api.hh>
Inheritance diagram for Api:

Public Member Functions | |
| Api (CRules *rules) | |
Game informations | |
Following methods are all accessors... Feel free to call them whenever you want. It's cheap ! | |
| int | turn () const |
| Get the current turn. | |
| int | half () const |
| Get the current half. | |
| int | myTeamId () const |
| Grab your team id. | |
| Point | ball () const |
| Get ball position. | |
| const CPlayer * | getBallOwner () const |
| Get ball owner. | |
| const char * | gameStateString () const |
| Get the stringified version of game status. | |
| int | teamId (const Point &pos) |
| Get the player team id at the specified position. | |
| void | selectTeam (int team_id) |
| Select team to fetch information from. | |
| const CTeam * | getTeam () const |
| Get the selected team. | |
| int | selectPlayer (int player_id) |
| Select player to fetch information from. | |
| int | selectSkilledPlayer (int player_id) |
| Select player to use a skill with. | |
| int | playerId (const Point &pos) |
| Get the player id at the specified position. | |
| const CPlayer * | getPlayer () const |
| Get the selected player. | |
| const CPlayer * | getPlayer (int player_id) |
| Get a player, of the selected team. | |
| const CPlayer * | getPlayer (const Point &pos) |
| Get a player on the field. | |
| int | declarationPossibleNumber () |
| Get the number of possible declaration for the selected player. | |
| int | declarationPossible (int index) const |
| Get a possible declaration for the selected player. | |
| int | actionPossibleNumber () |
| Get the number of possible action for the selected player. | |
| int | actionPossible (int index) const |
| Get a possible action for the selected player. | |
| int | moveLength (const Point &to) |
| Length that a move will take to the specified destination for the for selected player. | |
| int | moveDifficulty (int step) |
| Difficulty to get (FIXME) in/outside a square for a specified step. | |
| Point | movePath (int step) |
| Where the player will be on the field at this step. | |
| int | movePossible (const Point &to) |
| Determine if a move is possible for the selected player to the specified destination. | |
| int | remainingTime () const |
| Get the remaining time, for the turn. | |
| const Weather * | getWeather () const |
| Get the current weather. | |
Actions | |
Following methods are all possible actions. Functions can return SUCCESS, or any error code defined in common/Constants.hh
Remember that even if they return success, an action may or may not be accepted later by the server. | |
| void | doEndTurn () |
| End the current turn. | |
| void | doMoveTurnMarker () |
| Move the turn marker. | |
| void | doAskIllegalProcedure () |
| Ask for an illegal procedure. | |
| int | doChooseKickoff (bool kickoff) |
| Choose to kick off or receive. | |
| int | doPlacePlayer (const Point &pos) |
| Place the selected player, before a kick off. | |
| int | doEndPlacement () |
| End team's placement, before a kick off. | |
| int | doPlaceBall (const Point &pos) |
| Place the ball, on the kick off. | |
| int | doGiveBall (int p) |
| Give the ball to one of your player, if the ball goes out of field on kick off. | |
| int | doReroll (bool reroll) |
| Reroll or accept the last dice roll. | |
| int | doUseSkill (enum eSkill skill, bool useIt) |
| Use a skill of the selected player. | |
| int | doDeclare (enum eDeclaredAction action) |
| Declare an action for the selected player. | |
| int | doChooseBlockDice (int n) |
| After a block action, choose which block dice to use. | |
| int | doBlockPush (int n) |
| After a block action, push the defender to the selected square. | |
| int | doFollow (bool follow) |
| After a block action, choose to follow the defender. | |
| int | doStandUpPlayer () |
| Stand up the selected player. | |
| int | doMovePlayer (const Point &to) |
| Move the selected player. | |
| int | doBlockPlayer (int def_p) |
| Block with the selected player. | |
| int | doPassPlayer (const Point &to) |
| Throw the ball to the specified position. | |
| void | doCheatDice (int roll) |
| Choose the next dice result. | |
| void | sendChatMessage (const std::string &msg) |
| Send a chat message. | |
This class is really the "bridge" between the "coach" (whether it would be a human or a computer) and the rules engine.
For all methods asking for an action (eg. moving player), remember that even if they return success, an action may or may not be accepted later by the server.
| int Api::actionPossible | ( | int | index | ) | const [inline] |
Get a possible action for the selected player.
| index | Action index, in the range [0 - actionPossibleNumber() - 1]. |
| int Api::actionPossibleNumber | ( | ) | [inline] |
Get the number of possible action for the selected player.
| Point Api::ball | ( | ) | const [inline] |
Get ball position.
| int Api::declarationPossible | ( | int | index | ) | const [inline] |
Get a possible declaration for the selected player.
| index | Action index, in the range [0 - declarationPossibleNumber() - 1]. |
| int Api::declarationPossibleNumber | ( | ) | [inline] |
Get the number of possible declaration for the selected player.
| int Api::doBlockPlayer | ( | int | def_p | ) | [inline] |
Block with the selected player.
| def_p | The defender id, on the other team. |
| int Api::doBlockPush | ( | int | n | ) | [inline] |
After a block action, push the defender to the selected square.
| n | A number between 1 and 3, depending on the previous returned server message. |
| void Api::doCheatDice | ( | int | roll | ) | [inline] |
Choose the next dice result.
| roll | Next result to obtain, between 1 and number of dice faces. |
| int Api::doChooseBlockDice | ( | int | n | ) | [inline] |
After a block action, choose which block dice to use.
| n | A number between 0 and 2, depending on the previous returned server message. |
| int Api::doChooseKickoff | ( | bool | kickoff | ) | [inline] |
Choose to kick off or receive.
| kickoff | true if coach want to kick off. false if coach want to receive. |
| int Api::doDeclare | ( | enum eDeclaredAction | action | ) | [inline] |
Declare an action for the selected player.
| action | Action to declare. |
| int Api::doFollow | ( | bool | follow | ) | [inline] |
After a block action, choose to follow the defender.
| follow | true if following is wanted, else false. |
| int Api::doGiveBall | ( | int | p | ) | [inline] |
Give the ball to one of your player, if the ball goes out of field on kick off.
| p | Player id to give the ball. |
| int Api::doMovePlayer | ( | const Point & | to | ) | [inline] |
Move the selected player.
| int Api::doPassPlayer | ( | const Point & | to | ) | [inline] |
Throw the ball to the specified position.
| to | Where to throw the ball. |
| int Api::doPlaceBall | ( | const Point & | pos | ) | [inline] |
| int Api::doPlacePlayer | ( | const Point & | pos | ) | [inline] |
Place the selected player, before a kick off.
| pos | Position to place the player. (-1,-1) to place the player in the reserve. Any other coordinates out of team's zone do the same. |
| int Api::doReroll | ( | bool | reroll | ) | [inline] |
Reroll or accept the last dice roll.
| reroll | true if coach want to reroll, false to accept the result. |
| int Api::doStandUpPlayer | ( | ) | [inline] |
Stand up the selected player.
| int Api::doUseSkill | ( | enum eSkill | skill, | |
| bool | useIt | |||
| ) | [inline] |
Use a skill of the selected player.
| skill | The skill the player will use or not... SK_UNASSIGNED to not use any of the skills asked. | |
| useIt | Whether or not use the skill. |
| const char * Api::gameStateString | ( | ) | const [inline] |
Get the stringified version of game status.
Mainly useful for debugging.
| const CPlayer * Api::getBallOwner | ( | ) | const [inline] |
Get ball owner.
Get a player on the field.
| pos | A position on the field |
| const CPlayer * Api::getPlayer | ( | int | player_id | ) | [inline] |
Get a player, of the selected team.
| player_id | The identifiant of this player. |
| const CPlayer * Api::getPlayer | ( | ) | const [inline] |
Get the selected player.
| const CTeam * Api::getTeam | ( | ) | const [inline] |
Get the selected team.
| const Weather * Api::getWeather | ( | ) | const [inline] |
Get the current weather.
| int Api::half | ( | ) | const [inline] |
Get the current half.
| int Api::moveDifficulty | ( | int | step | ) | [inline] |
Difficulty to get (FIXME) in/outside a square for a specified step.
| step | The step (starting from 0 to move_length - 1) of the current movement projection. |
| int Api::moveLength | ( | const Point & | to | ) | [inline] |
Length that a move will take to the specified destination for the for selected player.
| to | Coordinate of destination. |
| Point Api::movePath | ( | int | step | ) | [inline] |
Where the player will be on the field at this step.
| step | The current step (starting from 0 to move_length - 1) of the current movement projection. |
| int Api::movePossible | ( | const Point & | to | ) | [inline] |
Determine if a move is possible for the selected player to the specified destination.
| to | Coordinate of destination. |
| int Api::myTeamId | ( | ) | const [inline] |
Grab your team id.
| int Api::playerId | ( | const Point & | pos | ) | [inline] |
Get the player id at the specified position.
| pos | A position on the field. |
| int Api::remainingTime | ( | ) | const [inline] |
Get the remaining time, for the turn.
| int Api::selectPlayer | ( | int | player_id | ) | [inline] |
Select player to fetch information from.
Further call to all other API function will return information for that player.
| player_id | Player identifier, in the range [0, MAX_PLAYER - 1]. |
| int Api::selectSkilledPlayer | ( | int | player_id | ) | [inline] |
Select player to use a skill with.
Further call to Api::doUseSkill(...) will concern this player.
| player_id | Player identifier, in the range [0, MAX_PLAYER - 1]. |
| void Api::selectTeam | ( | int | team_id | ) | [inline] |
Select team to fetch information from.
Further call to all other API function will return information for that team.
| team_id | 0 or 1 to select by team identifiant, US to select your team and THEM to select the other team. |
| void Api::sendChatMessage | ( | const std::string & | msg | ) | [inline] |
Send a chat message.
Can be called every time.
| msg | Message to send. |
| int Api::teamId | ( | const Point & | pos | ) | [inline] |
Get the player team id at the specified position.
| pos | A position on the field. |
| int Api::turn | ( | ) | const [inline] |
Get the current turn.
1.4.7