public function isValid() { if ($this->col) { $buff = $this->money; $this->money = $this->adena; $this->adena = $buff; } $valid = true; if (!$this->game || !$this->server || !$this->money || !$this->adena || !$this->nickname || !$this->contact) { $valid = false; } if (!is_numeric($this->money) || !is_numeric($this->adena)) { $valid = false; } $servers = getGameServers($this->link, $this->game); if (!$servers || sizeof($servers) <= 0) { $valid = false; } $serverExists = false; $serverId = 0; foreach ($servers as $i => $server) { if ($this->server == $server['server_name']) { $serverExists = true; $serverId = $server['id']; } } if (!$serverExists) { $valid = false; } $coefficients = getGameCoefficients($this->link, $this->game, $this->col); $serverCoefficients = []; foreach ($coefficients as $i => $coefficient) { if ($coefficient["server_id"] === $serverId) { array_push($serverCoefficients, new Coefficient($coefficient["cost"], $coefficient["sum"])); } } $coefficientId = findCoefficient($serverCoefficients, $this->adena); if (!isset($coefficientId)) { $valid = false; } $money = adenaToMoney($this->adena, $serverCoefficients[$coefficientId]); if ($money != $this->money) { $valid = false; } return $valid; }
// new Coefficient(10/($i+1), ($i+1)*1000), // new Coefficient(10/($i+2), ($i+2)*1000), // new Coefficient(10/($i+3), ($i+3)*1000), // ]; // $server = new Server("server".$i, $coefficients); // array_push($data, $server); //} $connection = Connection::getInstance(); $link = $connection->getLink(); if (!isset($_GET['game'])) { $game = 'lineage_classic_euro'; } else { $game = $_GET['game']; } $coefficients = getGameCoefficients($link, $game, $col); $servers = getGameServers($link, $game); foreach ($servers as $i => $server) { $serverCoefficients = array(); foreach ($coefficients as $j => $coefficient) { if ($coefficient["server_id"] === $server["id"]) { array_push($serverCoefficients, new Coefficient($coefficient["cost"], $coefficient["sum"])); } } $name = $server["server_name"]; $id = $server["id"]; $server = new Server($name, $serverCoefficients, $id); array_push($data, $server); } function toKK($value) { if (is_numeric($value)) {