game/_incl_data/class/User/UserCalculatedStats.php

79 lines
2.0 KiB
PHP
Raw Normal View History

2023-11-06 00:40:12 +00:00
<?php
namespace User;
class UserCalculatedStats
{
2023-11-09 17:24:47 +00:00
private UserStats $userStats;
private UserStats $baseUserStats;
2023-11-06 00:40:12 +00:00
public int $hpAll;
public int $mpAll;
2023-11-09 17:24:47 +00:00
2023-11-06 00:40:12 +00:00
public function __construct(
2023-11-09 17:24:47 +00:00
UserStats $userStats
)
{
$this->userStats = $userStats;
$this->baseUserStats = $userStats;
2023-11-06 00:40:12 +00:00
$this->hpAll = $this->hpAll();
$this->mpAll = $this->mpAll();
}
private function hpAll(): int
{
2023-11-09 17:24:47 +00:00
$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,
2023-11-06 00:40:12 +00:00
default => 0
};
return $hpAll;
}
2023-11-09 17:24:47 +00:00
private function mpAll(): int
2023-11-06 00:40:12 +00:00
{
2023-11-09 17:24:47 +00:00
$mpAll = $this->userStats->s6 * 10;
2023-11-06 00:40:12 +00:00
$mpAll += match (true) {
2023-11-09 17:24:47 +00:00
$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,
2023-11-06 00:40:12 +00:00
default => 0
};
return $mpAll;
}
2023-11-09 17:24:47 +00:00
public function __toString(): string
2023-11-06 00:40:12 +00:00
{
$arr = [];
2023-11-09 17:24:47 +00:00
foreach ($this as $k => $v) {
2023-11-06 00:40:12 +00:00
if (empty($v) || $k === 'us') {
continue;
}
$arr[$k] = $v;
}
return json_encode($arr);
}
public function __debugInfo()
{
$arr = [];
2023-11-09 17:24:47 +00:00
foreach ($this as $k => $v) {
2023-11-06 00:40:12 +00:00
if ($k === 'us') {
continue;
}
$arr[$k] = $v;
}
return $arr;
}
}