SBall Class Reference
[Server Rules]

Ball for the server.It symbolizes the ball, checks all ball manipulations. More...

#include <SBall.hh>

Inheritance diagram for SBall:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 SBall (SRules *r, SMatch *m)
void setCoordinates (const Coordinates &coord, bool advertise_client=true)
 Sets ball coordinates and advertises the client if it changed.
void setOwner (SPlayer *p)
 Sets ball owner and advertises the client if it has changed.
void removeFromField ()
 Removes the ball from the field.
void bounce (int nb=1)
 Bounces the ball around.
void scatter (int nb)
 Scatters the ball in a random direction.
void throwIn ()
 Makes spectators throw the ball in the field.
void setThrown ()
bool hasBeenThrown () const
void resetTurn ()
void sendCoordinates (Coordinates old_coord) const
 Send change of ball's coordinates.

Detailed Description

Ball for the server.

It symbolizes the ball, checks all ball manipulations.

You will have only one instance of this class at runtime, handled by SRules class.


Member Function Documentation

void SBall::removeFromField (  ) 

Removes the ball from the field.

Note:
Use it before a kickoff.

References Ball< SPlayer >::coord_, sendCoordinates(), and setOwner().

void SBall::scatter ( int  nb  ) 

Scatters the ball in a random direction.

Parameters:
nb Number of squares covered.
Attention:
Kludge: It changes ball coordinates without advertising clients, because the ball might be scattered out of the field.

References Ball< SPlayer >::coord_, Field< T >::dirToCoord(), Match< T >::getField(), and Dice::roll().

void SBall::sendCoordinates ( Coordinates  old_coord  )  const

Send change of ball's coordinates.

Parameters:
old_coord Where the ball was just before.

References Coordinates::col, Ball< SPlayer >::coord_, Coordinates::row, and BaseSRules::sendPacket().

Referenced by removeFromField(), and setCoordinates().

void SBall::setCoordinates ( const Coordinates coord,
bool  advertise_client = true 
)

Sets ball coordinates and advertises the client if it changed.

Note:
Use this function instead of setCoordinates(coord), if you want to advertise the client in the same time.
Parameters:
coord Where to place the ball.
advertise_client Whether or not send a MSG_BALLCOORD to clients.

References Ball< SPlayer >::coord_, and sendCoordinates().

Referenced by SPlayer::finishBlockAction(), SPlayer::finishBlockPush(), and SPlayer::tryMove().


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 21:17:44 2010 for Stechec/TBT by  doxygen 1.6.3