game/_incl_data/class/User/Effects.php

42 lines
1.3 KiB
PHP

<?php
namespace User;
use Core\Db;
class Effects
{
/** Дать игроку эффект.
* @param int $uid id игрока
* @param int $id id эффекта
* @return void
*/
public static function addById(int $uid, int $id)
{
$eff = Db::getRow('select mname, mdata, oneType, id2 from eff_main where id2 = ?', [$id]);
if (!$eff['id2']) {
return;
}
Db::sql(
'insert into eff_users (overType, id_eff, uid, name, timeUse, data) values (?,?,?,?,unix_timestamp(),?)',
[$eff['oneType'], $eff['id2'], $uid, $eff['mname'], $eff['mdata']]
);
}
public static function hasInjury(int $uid): bool
{
return Db::getValue('select count(*) from eff_users where id_eff in (4,5) and `delete` = 0 and uid = ?', [$uid]) > 0;
}
public static function hasAddiction(int $addictionId, int $uid): bool // пристрастие
{
return Db::getValue('select count(*) from eff_users where (id_eff between 301 and 304 or id_eff between 321 and 332) and id = ? and uid = ?', [$addictionId, $uid]) > 0;
}
public static function removeById(int $id): void
{
Db::sql('update eff_users set delete = unix_timestamp() where id = ?', [$id]);
}
}