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

53 lines
1.5 KiB
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_rules_library {
var $index = array(
'change',
'get'
);
function beta5_rules_library($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
$this->planets = $this->lib->game->getLib('beta5/planet');
}
//--------------------------------------------------------------------------------------------------------------------------------
// RULE HANDLERS
//--------------------------------------------------------------------------------------------------------------------------------
// Handler for modifications on planet_max_pop
function rhUpdateMaxPopulation($pid, $maxPop) {
$q = dbQuery("SELECT id FROM planet WHERE owner=$pid AND max_pop<".($maxPop-1500));
while ($r = dbFetchArray($q)) {
$this->planets->call('updateMaxPopulation', $r[0], $pid, $pid);
}
}
// Handler for modifications on the unhappiness factor
function rhUpdateHappiness($pid, $junk) {
$q = dbQuery("SELECT id FROM planet WHERE owner=$pid");
while ($r = dbFetchArray($q)) {
$this->planets->call('updateHappiness', $r[0]);
}
}
// Handler for modifications on ECM or ECCM techs
function rhUpdateCommTech($pid, $junk) {
$q = dbQuery("SELECT location FROM fleet WHERE owner=$pid AND location IS NOT NULL GROUP BY location");
while ($r = dbFetchArray($q)) {
$this->planets->call('updateMilStatus', $r[0]);
}
}
// Handler for modifications on fleet power rules
function rhUpdateFleetPower($pid, $junk) {
$this->rhUpdateHappiness($pid, '');
$this->rhUpdateCommTech($pid, '');
}
}
?>