game/_incl_data/class/User/UserStats.php

97 lines
2.5 KiB
PHP

<?php
namespace User;
readonly class UserStats
{
public int $s1;
public int $s2;
public int $s3;
public int $s4;
public int $s5;
public int $s6;
public int $s7;
public int $a1;
public int $a2;
public int $a3;
public int $a4;
public int $a5;
public int $mg1;
public int $mg2;
public int $mg3;
public int $mg4;
public int $mg7;
//public int $hpAll;
//public int $mpAll;
public function __construct(
array $a
)
{
$this->s1 = $a['s1'] ?? 0;
$this->s2 = $a['s2'] ?? 0;
$this->s3 = $a['s3'] ?? 0;
$this->s4 = $a['s4'] ?? 0;
$this->s5 = $a['s5'] ?? 0;
$this->s6 = $a['s6'] ?? 0;
$this->s7 = $a['s7'] ?? 0;
$this->a1 = max($a['a1'] ?? 0, $a['aall'] ?? 0);
$this->a2 = max($a['a2'] ?? 0, $a['aall'] ?? 0);
$this->a3 = max($a['a3'] ?? 0, $a['aall'] ?? 0);
$this->a4 = max($a['a4'] ?? 0, $a['aall'] ?? 0);
$this->a5 = max($a['a5'] ?? 0, $a['aall'] ?? 0);
$this->mg1 = max($a['mg1'] ?? 0, $a['mall'] ?? 0);
$this->mg2 = max($a['mg2'] ?? 0, $a['mall'] ?? 0);
$this->mg3 = max($a['mg3'] ?? 0, $a['mall'] ?? 0);
$this->mg4 = max($a['mg4'] ?? 0, $a['mall'] ?? 0);
$this->mg7 = $a['mg7'] ?? 0;
//$this->hpAll = $this->hpAll();
//$this->mpAll = $this->mpAll();
}
/*private function hpAll(): int
{
$hpAll = $this->s4 * 5;
$hpAll += match (true){
$this->s4 >= 200 => 850,
$this->s4 >= 175 => 600,
$this->s4 >= 150 => 450,
$this->s4 >= 125 => 400,
$this->s4 >= 100 => 250,
$this->s4 >= 75 => 175,
$this->s4 >= 50 => 100,
$this->s4 >= 25 => 50,
default => 0
};
return $hpAll;
}
private function mpAll():int
{
$mpAll = $this->s6 * 10;
$mpAll += match (true) {
$this->s6 >= 200 => 1500,
$this->s6 >= 175 => 900,
$this->s6 >= 150 => 700,
$this->s6 >= 125 => 500,
$this->s6 >= 100 => 350,
$this->s6 >= 75 => 250,
$this->s6 >= 50 => 150,
$this->s6 >= 25 => 50,
default => 0
};
return $mpAll;
}*/
public function __toString():string
{
$arr = [];
foreach ($this as $k=>$v) {
if (empty($v)) {
continue;
}
$arr[$k] = $v;
}
return json_encode($arr);
}
}