@@ -0,0 +1,52 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
public static function addOne(string $stat, int $user_id)
|
||||
{
|
||||
|
||||
Db::getInstance()->execute("
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
$stat = $stat + 1,
|
||||
free_stat_points = free_stat_points - 1
|
||||
WHERE
|
||||
id = ?
|
||||
", $user_id);
|
||||
}
|
||||
|
||||
public static function save(array $vars)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
update
|
||||
users
|
||||
set
|
||||
strength = ?,
|
||||
dexterity = ?,
|
||||
intuition = ?,
|
||||
endurance = ?,
|
||||
intelligence = ?,
|
||||
wisdom = ?,
|
||||
health = ?,
|
||||
mana = ?,
|
||||
free_stat_points = ?,
|
||||
level = ?
|
||||
where
|
||||
id = ?
|
||||
', $vars);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user