<?php // sjekk alle bankene for forandringer som skal gjøres med overføringsgebyret $result = \Kofradia\DB::get()->query("SELECT ff_id, ff_name, ff_params FROM ff WHERE ff_type = 3"); while ($row = $result->fetch()) { $params = new params_update($row['ff_params'], "ff", "ff_params", "ff_id = {$row['ff_id']}"); $change = $params->get("bank_overforing_tap_change", 0); $current = $params->get("bank_overforing_tap", 0); // ikke endre? if ($change == 0) { continue; } $next = $current + $change; // overstiger maks/min? $cancel = false; if ($next >= ff::$type_bank['bank_overforing_gebyr_max'] && $change > 0) { $next = ff::$type_bank['bank_overforing_gebyr_max']; $cancel = true; } elseif ($next <= ff::$type_bank['bank_overforing_gebyr_min'] && $change < 0) { $next = ff::$type_bank['bank_overforing_gebyr_min']; $cancel = true; } // lagre verdier $params->update("bank_overforing_tap", $next, false); // avbryte neste endring? if ($cancel) { $params->update("bank_overforing_tap_change", 0, false); } // lagre $params->commit(); // logg
/** * Regn ut progresjon */ public function get_progress() { if (!$this->data) { $this->load_active(); } if (!$this->data) { return null; } // kan ikke regne ut pregresjon? if (!$this->params->get("c") || !$this->a->params->get("count")) { return null; } return array("current" => $this->params->get("c"), "target" => $this->a->params->get("count")); }
/** * Marker forumet som sett */ public function forum_seen() { $this->params_load(); $container = new container($this->params_user->get("forums")); foreach ($container->items as $key => $row) { if ($row[0] != "ff") { continue; } if ($row[1] != $this->ff->id) { continue; } // må oppdatere antallet? if (isset($row[4]) && $row[4] > 0) { $this->params_user->lock(); $forums = $this->params_user->get("forums"); $container = new container($forums); foreach ($container->items as $key => $row) { if ($row[0] != "ff" || $row[1] != $this->ff->id) { continue; } // fjern antallet og lagre unset($container->items[$key][4]); $this->params_user->update("forums", $container->build()); $this->params_user->commit(); return true; } $this->params_user->commit(); return NULL; } return false; } return NULL; }
/** Fjern fra status */ public function status_remove() { $this->params->lock(); $status = unserialize($this->params->get("repliers")); // oppdater oppføringen for denne spilleren if (isset($status[login::$user->player->id])) { unset($status[login::$user->player->id]); } // lagre if (is_array($status) && count($status) == 0) { $this->params->remove("repliers", true); } else { $this->params->update("repliers", serialize($status), true); } }