maxHealth = round(($this->endurance * 3) + ($this->endurance / 2) * ($this->level - 1) + ($this->endurance / 5) * (($this->level - 1) * ($this->level - 2) / 2)); $this->maxMana = round(($this->wisdom * 3) + ($this->wisdom / 2) * ($this->level - 1) + ($this->wisdom / 5) * (($this->level - 1) * ($this->level - 2) / 2)); } /** * Отдаёт информацию о базовом(!) стате. * * @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', * 'endurance', 'intelligence', 'wisdom'. * @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку * на повышение стата на 1, при условии наличия свободных очков статов. * * @return string */ public function getStat($stat_name, $isMainWindow = 0): string { if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) { return self::ERROR_STAT_UNKNOWN; } if ($this->free_stat_points && $isMainWindow && $this->$stat_name < self::STAT_MAXIMUM_AMOUNT) { $this->$stat_name .= " [+]"; } return $this->$stat_name; } /** * Повышает один из выбранных статов на 1, но не выше self::STAT_MAXIMUM_AMOUNT при условии наличия свободных очков * статов. * * @param string $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', * 'endurance', 'intelligence', 'wisdom'. * * @throws GameException */ public function addOnePointToStat(string $stat_name) { if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) { throw new GameException(self::ERROR_STAT_UNKNOWN); } if ($this->free_stat_points <= 0 || $this->$stat_name >= self::STAT_MAXIMUM_AMOUNT) { throw new GameException(self::ERROR_STAT_IS_MAXIMUM); } else { $query = "UPDATE users SET {$stat_name} = {$stat_name} + 1, free_stat_points = free_stat_points - 1 WHERE id = ?"; self::$db->execute($query, $this->id); } } /** * @return mixed */ public function getStrength() { return $this->strength; } /** * @return mixed */ public function getDexterity() { return $this->dexterity; } /** * @return mixed */ public function getIntuition() { return $this->intuition; } /** * @return mixed */ public function getEndurance() { return $this->endurance; } /** * @return mixed */ public function getIntelligence() { return $this->intelligence; } /** * @return mixed */ public function getWisdom() { return $this->wisdom; } /** * @return mixed */ public function getHealth() { return $this->health; } /** * @return mixed */ public function getMana() { return $this->mana; } /** * @return mixed */ public function getFreeStatPoints() { return $this->free_stat_points; } /** * @return float */ public function getMaxHealth(): float { return $this->maxHealth; } /** * @return float */ public function getMaxMana(): float { return $this->maxMana; } /** * @return int */ public function getMinDamage(): int { return $this->minDamage; } /** * @return int */ public function getMaxDamage(): int { return $this->maxDamage; } /** * @return int */ public function getHeadArmor(): int { return $this->headArmor; } /** * @return int */ public function getChestArmor(): int { return $this->chestArmor; } /** * @return int */ public function getLegArmor(): int { return $this->legArmor; } }