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/alliance/library/get.inc

30 lines
673 B
PHP

<?php
class beta5_alliance_get {
function beta5_alliance_get($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Get alliance data
function run($id) {
$q = $this->db->query("SELECT * FROM alliance WHERE id = $id");
if (!($q && dbCount($q) == 1)) {
return null;
}
$r = dbFetchHash($q);
$q = $this->db->query(
"SELECT COUNT(*),ROUND(AVG(s.x)),ROUND(AVG(s.y)) FROM player y,planet p,system s "
. "WHERE y.alliance=$id AND y.a_status='IN' AND p.owner=y.id AND s.id=p.system"
);
list($r['nplanets'],$r['avgx'],$r['avgy']) = dbFetchArray($q);
if (is_null($r['avgx'])) {
$r['avgx'] = $r['avgy'] = 0;
}
return $r;
}
}
?>