lwb5-in-2025/scripts/game/beta5/alliance/library/getRankSize.inc

33 lines
676 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_alliance_getRankSize {
public function __construct($lib) {
2016-01-10 11:01:49 +01:00
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Get the number of alliance members at a certain rank
function run($aid, $rId) {
$a = $this->lib->call('get', $aid);
$qs = "SELECT COUNT(*) FROM player WHERE alliance=$aid AND a_status='IN' AND ";
if ($rId == $a['default_grade']) {
$qs .= "(a_grade=$rId OR a_grade IS NULL)";
} else {
$qs .= "a_grade=$rId";
}
if (!is_null($a['leader'])) {
$qs .= " AND id<>" . $a['leader'];
}
$q = $this->db->query($qs);
if (!($q && dbCount($q))) {
return 0;
}
list($r) = dbFetchArray($q);
return $r;
}
}
?>