Code smell.
This commit is contained in:
@@ -6,30 +6,31 @@ use Battles\Database\Db;
|
||||
|
||||
class Effects
|
||||
{
|
||||
public static function getStatMods(int $user_id)
|
||||
public static function getStatMods(int $userId)
|
||||
{
|
||||
return Db::getInstance()->ofetch("
|
||||
select
|
||||
sum(mod_strength) as effect_strength,
|
||||
sum(mod_dexterity) as effect_dexterity,
|
||||
sum(mod_intuition) as effect_intuition,
|
||||
sum(mod_endurance) as effect_endurance,
|
||||
sum(mod_intelligence) as effect_intelligence,
|
||||
sum(mod_wisdom) as effect_wisdom
|
||||
from
|
||||
users_effects
|
||||
where
|
||||
owner_id = ?
|
||||
", $user_id);
|
||||
return Db::getInstance()->ofetch(
|
||||
"select
|
||||
sum(mod_strength) as effect_strength,
|
||||
sum(mod_dexterity) as effect_dexterity,
|
||||
sum(mod_intuition) as effect_intuition,
|
||||
sum(mod_endurance) as effect_endurance,
|
||||
sum(mod_intelligence) as effect_intelligence,
|
||||
sum(mod_wisdom) as effect_wisdom
|
||||
from
|
||||
users_effects
|
||||
where
|
||||
owner_id = ?",
|
||||
$userId
|
||||
);
|
||||
}
|
||||
|
||||
public static function getAll(int $user_id): object
|
||||
public static function getAll(int $userId): object
|
||||
{
|
||||
return Db::getInstance()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $user_id);
|
||||
return Db::getInstance()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $userId);
|
||||
}
|
||||
|
||||
public static function count(int $user_id, int $type)
|
||||
public static function count(int $userId, int $type)
|
||||
{
|
||||
return Db::getInstance()->fetchColumn('select count(*) from users_effects where type = ? and owner_id = ?', [$type, $user_id]);
|
||||
return Db::getInstance()->fetchColumn('select count(*) from users_effects where type = ? and owner_id = ?', [$type, $userId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,38 +15,40 @@ class Stats
|
||||
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)
|
||||
public static function addOne(string $stat, int $userId)
|
||||
{
|
||||
|
||||
Db::getInstance()->execute("
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
$stat = $stat + 1,
|
||||
free_stat_points = free_stat_points - 1
|
||||
WHERE
|
||||
id = ?
|
||||
", $user_id);
|
||||
Db::getInstance()->execute(
|
||||
"UPDATE
|
||||
users
|
||||
SET
|
||||
$stat = $stat + 1,
|
||||
free_stat_points = free_stat_points - 1
|
||||
WHERE
|
||||
id = ?",
|
||||
$userId
|
||||
);
|
||||
}
|
||||
|
||||
public static function save(array $vars)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
update
|
||||
users
|
||||
set
|
||||
strength = ?,
|
||||
dexterity = ?,
|
||||
intuition = ?,
|
||||
Db::getInstance()->execute(
|
||||
'update
|
||||
users
|
||||
set
|
||||
strength = ?,
|
||||
dexterity = ?,
|
||||
intuition = ?,
|
||||
endurance = ?,
|
||||
intelligence = ?,
|
||||
wisdom = ?,
|
||||
health = ?,
|
||||
mana = ?,
|
||||
intelligence = ?,
|
||||
wisdom = ?,
|
||||
health = ?,
|
||||
mana = ?,
|
||||
free_stat_points = ?,
|
||||
level = ?
|
||||
where
|
||||
id = ?
|
||||
', $vars);
|
||||
level = ?
|
||||
where
|
||||
id = ?',
|
||||
$vars
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user