Source for file PlayerList.php

Documentation is available at PlayerList.php

  1. <?php
  2. /**
  3.  * Defines PlayerList class.
  4.  *
  5.  * @package recAnalyst
  6.  * @version $Id: PlayerList.php 18 2009-05-11 12:39:18Z biegleux $
  7.  * @author biegleux <biegleux[at]gmail[dot]com>
  8.  * @copyright copyright (c) 2008-2009 biegleux
  9.  * @license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  10.  * @link http://recanalyst.sourceforge.net/
  11.  * @filesource
  12.  */
  13.  
  14. /**
  15.  * Class PlayerList.
  16.  *
  17.  * PlayerList implements list of players in a game.
  18.  *
  19.  * @package recAnalyst
  20.  */
  21. class PlayerList extends TList
  22. {
  23.     /**
  24.      * Adds a player to the list.
  25.      *
  26.      * @param Player $player the player we wish to add
  27.      */
  28.     public function addPlayer (Player $player)
  29.     {
  30.         parent::addItem ($player);
  31.     }
  32.  
  33.     /**
  34.      * Returns a player at the specified offset.
  35.      *
  36.      * @param int an index of the player
  37.      * @return Player|boolthe player at the index or false if the index is out of the range
  38.      */
  39.     public function getPlayer ($index)
  40.     {
  41.         return parent::getItem ($index);
  42.     }
  43.  
  44.     /**
  45.      * Returns a player with the index property equal to the one defined.
  46.      *
  47.      * @param int $index player's index
  48.      * @return Player|boolfalse if no player has been found
  49.      */
  50.     public function getPlayerByIndex ($index)
  51.     {
  52.         for ($i 0$i $this->count$i++)
  53.         {
  54.             if ($this->list[$i]->index == $index)
  55.             {
  56.                 return $this->list[$i];
  57.             }
  58.         }
  59.         return false;
  60.     }
  61. }
  62. ?>

Documentation generated on Mon, 11 May 2009 16:43:37 +0200 by phpDocumentor 1.4.1