player speccount methods

This commit is contained in:
kremsy
2014-02-08 20:29:50 +01:00
committed by Steffen Schröder
parent 0e118840fe
commit de54e45b59
2 changed files with 31 additions and 2 deletions

View File

@ -238,6 +238,36 @@ class PlayerManager implements CallbackListener {
return $this->players;
}
/**
* Gets the Count of all Player
* @return int
*/
public function getPlayerCount(){
$count = 0;
foreach($this->players as $player){
/** @var Player $player */
if(!$player->isSpectator){
$count++;
}
}
return $count;
}
/**
* Gets the Count of all Spectators
* @return int
*/
public function getSpectatorCount(){
$count = 0;
foreach($this->players as $player){
/** @var Player $player */
if($player->isSpectator){
$count++;
}
}
return $count;
}
/**
* Gets a Player by his index
*
@ -248,7 +278,6 @@ class PlayerManager implements CallbackListener {
foreach($this->players as $player) {
/** @var Player $player */
if ($player->index == $index) {
return $player;
}
}