Api Class Reference
[Client API]

User interface for graphical interface, AI, etc.

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:

Inheritance graph
[legend]
List of all members.

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 CPlayergetBallOwner () 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 CTeamgetTeam () 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 CPlayergetPlayer () const
 Get the selected player.
const CPlayergetPlayer (int player_id)
 Get a player, of the selected team.
const CPlayergetPlayer (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 WeathergetWeather () 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.

Detailed Description

User interface for graphical interface, AI, etc.

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.


Member Function Documentation

int Api::actionPossible ( int  index  )  const [inline]

Get a possible action for the selected player.

Parameters:
index Action index, in the range [0 - actionPossibleNumber() - 1].
Returns:
Action that this player may perform.

int Api::actionPossibleNumber (  )  [inline]

Get the number of possible action for the selected player.

Returns:
The number of possible action

Point Api::ball (  )  const [inline]

Get ball position.

Returns:
Return the ball position, (-1, -1) if outside.

int Api::declarationPossible ( int  index  )  const [inline]

Get a possible declaration for the selected player.

Parameters:
index Action index, in the range [0 - declarationPossibleNumber() - 1].
Attention:
Always call declarationPossibleNumber() just before.
Returns:
Action that this player may perform.

int Api::declarationPossibleNumber (  )  [inline]

Get the number of possible declaration for the selected player.

Returns:
The number of possible declaration

int Api::doBlockPlayer ( int  def_p  )  [inline]

Block with the selected player.

Note:
Declare a DCL_BLOCK or DCL_BLITZ action before.
Parameters:
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.

Note:
Wait for the right server reponse before calling it.
Parameters:
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.

Parameters:
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.

Note:
Wait for the right server reponse before calling it.
Parameters:
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.

Parameters:
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.

Parameters:
action Action to declare.

int Api::doFollow ( bool  follow  )  [inline]

After a block action, choose to follow the defender.

Note:
Wait for the right server reponse before calling it.
Parameters:
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.

Parameters:
p Player id to give the ball.

int Api::doMovePlayer ( const Point to  )  [inline]

Move the selected player.

Note:
Declare a DCL_MOVE or DCL_BLITZ or DCL_PASS action before.

int Api::doPassPlayer ( const Point to  )  [inline]

Throw the ball to the specified position.

Note:
Declare a DCL_PASS action before.
Parameters:
to Where to throw the ball.

int Api::doPlaceBall ( const Point pos  )  [inline]

Place the ball, on the kick off.

Parameters:
pos Position to place the ball.

int Api::doPlacePlayer ( const Point pos  )  [inline]

Place the selected player, before a kick off.

Note:
If there is already a player on this square, he will be placed in the reserve.
Parameters:
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.

Parameters:
reroll true if coach want to reroll, false to accept the result.

int Api::doStandUpPlayer (  )  [inline]

Stand up the selected player.

Note:
Declare a DCL_MOVE or DCL_BLITZ or DCL_PASS action before.

int Api::doUseSkill ( enum eSkill  skill,
bool  useIt 
) [inline]

Use a skill of the selected player.

Parameters:
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.

Returns:
The current game status.

const CPlayer * Api::getBallOwner (  )  const [inline]

Get ball owner.

Returns:
Return the ball owner, NULL if none.

const CPlayer * Api::getPlayer ( const Point pos  )  [inline]

Get a player on the field.

Parameters:
pos A position on the field
Returns:
The player standing in this field position, or NULL if there is nobody.

const CPlayer * Api::getPlayer ( int  player_id  )  [inline]

Get a player, of the selected team.

Parameters:
player_id The identifiant of this player.
Returns:
The chosen player, or NULL if it doesn't exists.

const CPlayer * Api::getPlayer (  )  const [inline]

Get the selected player.

Returns:
The selected player.

const CTeam * Api::getTeam (  )  const [inline]

Get the selected team.

Returns:
The selected team, or NULL if none was chosen.

const Weather * Api::getWeather (  )  const [inline]

Get the current weather.

Note:
FIXME: currently disabled.

int Api::half (  )  const [inline]

Get the current half.

Returns:
The current half.

int Api::moveDifficulty ( int  step  )  [inline]

Difficulty to get (FIXME) in/outside a square for a specified step.

Parameters:
step The step (starting from 0 to move_length - 1) of the current movement projection.
Returns:
The number of tackles zone for this step.
Note:
You have to make a successful call to moveLength before.

int Api::moveLength ( const Point to  )  [inline]

Length that a move will take to the specified destination for the for selected player.

Parameters:
to Coordinate of destination.
Returns:
The number of case the selected player will have to do, or 0 if that move can't be made.

Point Api::movePath ( int  step  )  [inline]

Where the player will be on the field at this step.

Parameters:
step The current step (starting from 0 to move_length - 1) of the current movement projection.
Returns:
Position on the field.
Note:
You have to make a successful call to moveLength before.

int Api::movePossible ( const Point to  )  [inline]

Determine if a move is possible for the selected player to the specified destination.

Parameters:
to Coordinate of destination.
Returns:
1 if this move is possible, 0 else.

int Api::myTeamId (  )  const [inline]

Grab your team id.

Returns:
A team identifiant, in the range [0, 1].

int Api::playerId ( const Point pos  )  [inline]

Get the player id at the specified position.

Parameters:
pos A position on the field.
Returns:
A player id, or -1 if there is nobody at this position.

int Api::remainingTime (  )  const [inline]

Get the remaining time, for the turn.

Returns:
The remaining time, in second.

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.

Parameters:
player_id Player identifier, in the range [0, MAX_PLAYER - 1].
Attention:
It is reset when selectTeam is called.

int Api::selectSkilledPlayer ( int  player_id  )  [inline]

Select player to use a skill with.

Further call to Api::doUseSkill(...) will concern this player.

Parameters:
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.

Parameters:
team_id 0 or 1 to select by team identifiant, US to select your team and THEM to select the other team.
See also:
eSelTeam

void Api::sendChatMessage ( const std::string &  msg  )  [inline]

Send a chat message.

Can be called every time.

Parameters:
msg Message to send.

int Api::teamId ( const Point pos  )  [inline]

Get the player team id at the specified position.

Parameters:
pos A position on the field.
Returns:
A team id, or -1 if there is nobody at this position.

int Api::turn (  )  const [inline]

Get the current turn.

Returns:
The current turn in the range of [1, 8], or 0 if in other state (kickoff, ...)


The documentation for this class was generated from the following files:
Generated on Sat Jun 23 16:09:14 2007 for Stechec/TBT by  doxygen 1.4.7