This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/beta5/player/library/getPlanetCount.inc

26 lines
527 B
PHP

<?php
class beta5_player_getPlanetCount {
var $pPlanets = array();
function beta5_player_getPlanetCount($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Returns the amount of planets a player controls
function run($pl) {
if (is_null($pl)) {
return 1;
}
if (!is_null($this->pPlanets[$pl])) {
return $this->pPlanets[$pl];
}
$q = $this->db->query("SELECT COUNT(*) FROM planet WHERE owner=$pl");
list($this->pPlanets[$pl]) = dbFetchArray($q);
return $this->pPlanets[$pl];
}
}
?>