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/change.inc

30 lines
653 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_rules_change {
function beta5_rules_change($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function run($pid, $rules) {
if (!count($rules)) {
return;
}
foreach ($rules as $r => $v) {
$this->db->query("UPDATE rule SET value=value+($v) WHERE player=$pid AND name='$r'");
}
$this->lib->mainClass->rules[$pl] = null;
$q = $this->db->query("SELECT h.handler,r.value FROM rule_handler h,rule r "
. "WHERE r.name IN ('" . join("','", array_keys($rules)) . "') AND r.player=$pid AND h.rule=r.name");
while ($r = dbFetchArray($q)) {
$this->lib->call("rh{$r[0]}", $pid, $r[1]);
}
}
}
?>