Added full source code
This commit is contained in:
commit
33f8586698
1377 changed files with 123808 additions and 0 deletions
scripts/game/beta5/rules/library
29
scripts/game/beta5/rules/library/change.inc
Normal file
29
scripts/game/beta5/rules/library/change.inc
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
32
scripts/game/beta5/rules/library/get.inc
Normal file
32
scripts/game/beta5/rules/library/get.inc
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
class beta5_rules_get {
|
||||
function beta5_rules_get($lib) {
|
||||
$this->lib = $lib;
|
||||
$this->db = $this->lib->game->db;
|
||||
}
|
||||
|
||||
|
||||
// Loads rules for a player
|
||||
function run($pid) {
|
||||
$apid = is_null($pid) ? ' ' : $pid;
|
||||
if (is_array($this->lib->mainClass->rules[$apid])) {
|
||||
return $this->lib->mainClass->rules[$apid];
|
||||
}
|
||||
|
||||
$q = $this->db->query("SELECT name,value FROM rule"
|
||||
. (is_null($pid) ? "_def" : " WHERE player=$pid"));
|
||||
if (!($q && dbCount($q))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->lib->mainClass->rules[$apid] = array();
|
||||
while ($r = dbFetchArray($q)) {
|
||||
$this->lib->mainClass->rules[$apid][$r[0]] = $r[1];
|
||||
}
|
||||
|
||||
return $this->lib->mainClass->rules[$apid];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in a new issue