lwb5-in-2025/scripts/game/beta5/player/library/getPlanetCount.inc

27 lines
518 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_player_getPlanetCount {
var $pPlanets = array();
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];
}
}
?>