Нападалка вынесена из Magic.php.

This commit is contained in:
2023-08-14 16:03:45 +03:00
parent f557dbcd1a
commit 63be6c94b3
6 changed files with 1655 additions and 560 deletions
+123 -3
View File
@@ -6,10 +6,91 @@ use Core\Db;
class Effects
{
public static function addCustom(array $values)
{
$sql = '
insert into eff_users
(
id_eff,
uid,
name,
data,
overType,
timeUse,
timeAce,
user_use,
v1,
v2,
img2,
x,
hod,
bj,
sleeptime,
no_Ace,
file_finish,
tr_life_user,
deactiveTime,
deactiveLast,
mark,
bs
) values (
:id_eff,
:uid,
:name,
:data,
:overType,
:timeUse,
:timeAce,
:user_use,
:v1,
:v2,
:img2,
:x,
:hod,
:bj,
:sleeptime,
:no_Ace,
:file_finish,
:tr_life_user,
:deactiveTime,
:deactiveLast,
:mark,
:bs
)';
$args = [
'id_eff' => null,
'uid' => null,
'name' => null,
'data' => '',
'overType' => 0,
'timeUse' => null,
'timeAce' => 0,
'user_use' => '',
'v1' => '0',
'v2' => 0,
'img2' => '',
'x' => 1,
'hod' => -1,
'bj' => '0',
'sleeptime' => 0,
'no_Ace' => 0,
'file_finish' => '',
'tr_life_user' => 0,
'deactiveTime' => 0,
'deactiveLast' => 0,
'mark' => 0,
'bs' => 0,
];
$args = array_replace($args, $values);
if (!isset($args['id_eff'], $args['uid'], $args['name'], $args['timeUse'])) {
return;
}
Db::sql($sql, $args);
}
/** Дать игроку эффект.
* @param int $uid id игрока
* @param int $id id эффекта
* @param int $id id эффекта
* @return void
*/
public static function addById(int $uid, int $id)
@@ -34,8 +115,47 @@ class Effects
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
public static function removeById(int $userId, int $id): void
{
Db::sql('update eff_users set delete = unix_timestamp() where id = ?', [$id]);
Db::sql('delete from eff_users where id = ? and uid = ?', [$id, $userId]);
}
public static function removeByIds(int $userId, ...$ids): void
{
Db::sql('delete from eff_users where id in (?) and uid = ?', [implode(',', $ids), $userId]);
}
public static function removeByOverType(int $userId, int $overType): void
{
Db::sql('delete from eff_users where overType = ? and uid = ?', [$overType, $userId]);
}
public static function hasAttackTimeLimit(int $attackerId): bool
{
return Db::getValue('select count(*) from eff_users where id_eff = 478 and `delete` = 0 and uid = ?', [$attackerId]) > 0;
}
public static function isImmuneToAttack(int $targetId): bool
{
return Db::getValue('select count(*) from eff_users where id_eff in (479, 480, 481) and `delete` = 0 and uid = ?', [$targetId]) > 0;
}
public static function giveAttackImmunity(int $userId)
{
Db::sql("insert into eff_users (no_Ace, id_eff, overType, uid, name, data, timeUse) values (1,479,112,?,'Защита от нападения','zashitatk=1',unix_timestamp())", [$userId]);
}
/**
* Духовность. Спасение.
* Из свитка нападения.
* @param $id
* @return void
*/
public static function addSpasenie($id): void
{
Db::sql('delete from eff_users where uid = ? and overType = 101');
Db::sql("insert into eff_users (id_eff, uid, name, data, overType, timeUse, user_use, v1, v2, img2, bj, mark)
values (22,?,'Спасение','add_spasenie=1',101,77,?,'priem',324,'preservation.gif','спасение',1)", [$id, $id]);
}
}
+11 -4
View File
@@ -58,7 +58,8 @@ class ItemsModel
public static function deleteItemsById(int $id, int $coldel = 1)
{
Db::sql(
'update items_users set `delete` = unix_timestamp() where id in (select id from items_users where item_id = ? and uid = ? and (`delete` = 0 or `delete` = 1000) order by inGroup desc limit ?)',
'update items_users set `delete` = unix_timestamp()
where id in (select id from items_users where item_id = ? and uid = ? and (`delete` = 0 or `delete` = 1000) order by inGroup desc limit ?)',
[$id, User::start()->info['id'], $coldel]
);
}
@@ -70,7 +71,8 @@ class ItemsModel
$stats = User::start()->stats;
return [
'now' => Db::getValue('select sum(massa) from items_users left join items_main on item_id = items_main.id where uid = ? and (`delete` = 0 or (`delete` = 1000 and inGroup > 0)) and inShop = 0 and inOdet = 0', [$uid]),
'now' => Db::getValue('select sum(massa) from items_users left join items_main on item_id = items_main.id
where uid = ? and (`delete` = 0 or (`delete` = 1000 and inGroup > 0)) and inShop = 0 and inOdet = 0', [$uid]),
'max' => 40 + ($stats['os7'] * 10) + $stats['s4'] + $stats['maxves'] + $stats['s1'] * 4,
'items' => Db::getValue('select count(*) from items_users where uid = ? and `delete` = 0 and inShop = 0 and inOdet = 0', [$uid]),
];
@@ -140,12 +142,17 @@ class ItemsModel
*/
public static function getOwnedItemById(int $itemId, int $ownerId): array
{
return Db::getRow('select * from items_users left join items_main on item_id = items_main.id where uid = ? and items_users.id = ? and `delete` = 0 and inOdet = 0 and inShop = 0', [$ownerId, $itemId]);
return Db::getRow('select * from items_users left join items_main on item_id = items_main.id
where uid = ? and items_users.id = ? and `delete` = 0 and inOdet = 0 and inShop = 0', [$ownerId, $itemId]);
}
public static function delete(int $id)
{
Db::sql('update items_users set `delete` = unix_timestamp() where id = ?', [$id]);
Db::sql('delete from items_users where id = ?', [$id]);
}
public static function getDressedEkrTotalPrice($uid)
{
return Db::getValue('select sum(2price) from items_users where inOdet > 0 and uid = ?', [$uid]);
}
}