game/_incl_data/class/User/UserCalculatedStats.php
2023-11-09 19:24:47 +02:00

79 lines
2.0 KiB
PHP

<?php
namespace User;
class UserCalculatedStats
{
private UserStats $userStats;
private UserStats $baseUserStats;
public int $hpAll;
public int $mpAll;
public function __construct(
UserStats $userStats
)
{
$this->userStats = $userStats;
$this->baseUserStats = $userStats;
$this->hpAll = $this->hpAll();
$this->mpAll = $this->mpAll();
}
private function hpAll(): int
{
$hpAll = $this->userStats->s4 * 5;
$hpAll += match (true) {
$this->userStats->s4 >= 200 => 850,
$this->userStats->s4 >= 175 => 600,
$this->userStats->s4 >= 150 => 450,
$this->userStats->s4 >= 125 => 400,
$this->userStats->s4 >= 100 => 250,
$this->userStats->s4 >= 75 => 175,
$this->userStats->s4 >= 50 => 100,
$this->userStats->s4 >= 25 => 50,
default => 0
};
return $hpAll;
}
private function mpAll(): int
{
$mpAll = $this->userStats->s6 * 10;
$mpAll += match (true) {
$this->userStats->s6 >= 200 => 1500,
$this->userStats->s6 >= 175 => 900,
$this->userStats->s6 >= 150 => 700,
$this->userStats->s6 >= 125 => 500,
$this->userStats->s6 >= 100 => 350,
$this->userStats->s6 >= 75 => 250,
$this->userStats->s6 >= 50 => 150,
$this->userStats->s6 >= 25 => 50,
default => 0
};
return $mpAll;
}
public function __toString(): string
{
$arr = [];
foreach ($this as $k => $v) {
if (empty($v) || $k === 'us') {
continue;
}
$arr[$k] = $v;
}
return json_encode($arr);
}
public function __debugInfo()
{
$arr = [];
foreach ($this as $k => $v) {
if ($k === 'us') {
continue;
}
$arr[$k] = $v;
}
return $arr;
}
}