2016-01-10 11:01:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class beta5_player_getPlanetCount {
|
|
|
|
var $pPlanets = array();
|
|
|
|
|
2024-12-31 00:25:05 +01:00
|
|
|
public function __construct($lib) {
|
2016-01-10 11:01:49 +01:00
|
|
|
$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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|