Files
battles/classes/Battles/Models/User/Stats.php
T

55 lines
1.3 KiB
PHP
Raw Normal View History

2022-08-09 22:57:43 +03:00
<?php
# Date: 23.02.2022 (2:32)
namespace Battles\Models\User;
use Battles\Database\Db;
class Stats
{
/**
* @param int|string $user
*/
public static function getAll($user)
{
$col = ctype_digit(strval($user)) ? 'id' : 'login';
return Db::getInstance()->ofetch('select id, strength, dexterity, intuition, endurance, intelligence, wisdom, health, mana, free_stat_points, level from users where ' . $col . ' = ?', $user);
}
2022-12-17 01:20:43 +02:00
public static function addOne(string $stat, int $userId)
2022-08-09 22:57:43 +03:00
{
2022-12-17 01:20:43 +02:00
Db::getInstance()->execute(
"UPDATE
users
SET
$stat = $stat + 1,
free_stat_points = free_stat_points - 1
WHERE
id = ?",
$userId
);
2022-08-09 22:57:43 +03:00
}
public static function save(array $vars)
{
2022-12-17 01:20:43 +02:00
Db::getInstance()->execute(
'update
users
set
strength = ?,
dexterity = ?,
intuition = ?,
2022-08-09 22:57:43 +03:00
endurance = ?,
2022-12-17 01:20:43 +02:00
intelligence = ?,
wisdom = ?,
health = ?,
mana = ?,
2022-08-09 22:57:43 +03:00
free_stat_points = ?,
2022-12-17 01:20:43 +02:00
level = ?
where
id = ?',
$vars
);
2022-08-09 22:57:43 +03:00
}
2022-12-17 01:20:43 +02:00
}