Много рефактора

This commit is contained in:
2023-12-19 03:58:37 +02:00
parent 253eafca3b
commit 07f905ef64
24 changed files with 2748 additions and 3199 deletions
+7 -2
View File
@@ -31,7 +31,7 @@ class Clan
}
}
private function join(string $clanname)
private function join(string $clanname): void
{
Db::sql('update users set clan = (select id from clan where clan.name = ?) where id = ?', [$clanname, $this->userid]);
}
@@ -46,7 +46,7 @@ class Clan
return $this->status;
}
public function printClan()
public function printClan(): void
{
echo '<img style="vertical-align:text-bottom;" src="' . Config::img() . '/i/align/align' . $this->getAlign() . '.gif" alt="Склонность">' . $this->printLogoImage() . $this->getName();
}
@@ -88,4 +88,9 @@ class Clan
{
return !empty($this->id) && $this->status === 0;
}
public static function addExp(int $value, int $clanid): void
{
Db::sql('update clan set exp = exp + ? where id = ?',[max($value,0), $clanid]);
}
}
+9 -4
View File
@@ -148,6 +148,11 @@ insert into eff_users
Db::sql('delete from eff_users where id in (?) and uid = ?', [implode(',', $ids), $userId]);
}
public static function removePriems(int $userid): void
{
Db::sql("delete from eff_users where v1 = 'priem' and uid = ?", [$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;
@@ -166,14 +171,14 @@ insert into eff_users
/**
* Духовность. Спасение.
* Из свитка нападения.
* @param $id
* @param $uid
* @return void
*/
public static function addSpasenie($id): void
public static function addSpasenie($uid): void
{
Db::sql('delete from eff_users where uid = ? and overType = 101');
self::removeByOverType($uid, 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]);
values (22,?,'Спасение','add_spasenie=1',101,77,?,'priem',324,'preservation.gif','спасение',1)", [$uid, $uid]);
}
+13 -13
View File
@@ -12,21 +12,11 @@ class Reputation
public function __construct(int $userid)
{
$this->uid = $userid;
$this->r = Db::getRow(
'select *,
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
from rep where id = ?', [$this->uid]
);
$this->r = $this->getr();
if (empty($this->r)) {
Db::sql('insert into rep (id) value (?)', [$this->uid]);
$this->r = Db::getRow(
'select *,
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
from rep where id = ?', [$this->uid]
);
$this->r = $this->getr();
}
}
@@ -35,7 +25,7 @@ class Reputation
return $this->r;
}
public function addRep(string $dungeonName, int $value): int
public function addRep(string $dungeonName, int $value): mixed
{
if (!isset($this->r[$dungeonName]) || $value <= 0) {
return 0;
@@ -44,4 +34,14 @@ class Reputation
Db::sql("update rep set $dungeonName = ? where id = ?", [$value, $this->uid]);
return $this->r[$dungeonName];
}
private function getr()
{
return Db::getRow(
'select *,
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
from rep where id = ?', [$this->uid]
);
}
}
+73 -21
View File
@@ -123,16 +123,13 @@ class Stats
];
}
public function getStats(int|array|null $uid = null, $i1 = 0, $res = 0, $reimg = false, $btl_cache = false): array
public function getStats(int|array|null $uid = null, $i1 = 0, $reimg = false, $btl_cache = false): array
{
if (empty($uid) || $uid == $this->u->info['id'] && $res != 1) {
//$u = $this->u->info;
$u = User::getInfo($uid);
} elseif (is_array($uid)) {
$u = $uid;
} else {
$u = User::getInfo($uid);
}
$u = match (true) {
empty($uid) => User::getInfo($this->u->info['id']),
is_array($uid) => $uid,
default => User::getInfo($uid),
};
if (!isset($u['id'])) {
return [];
@@ -296,11 +293,13 @@ class Stats
//Бонусы комплектов
if (is_iterable($coms['new'])) {
foreach ($coms['new'] as $complect) {
$com = Db::getValue('select data from complects where com = ? and x <= ? order by x desc limit 1',
$com = Db::getValue(
'select data from complects where com = ? and x <= ? order by x desc limit 1',
[
(int)$complect,
(int)$coms['com'][$complect], // кол-во предметов данного комплекта
]);
]
);
if (!$com) {
continue;
@@ -513,8 +512,8 @@ class Stats
/** Собираем динамически создаваемые параметры. Если ключа нет - создаём.
* @param string $key
* @param int $value
* @param array $st
* @param int $value
* @param array $st
* @return void
*/
private function addKeyIfNotExist(string $key, int $value, array &$st): void
@@ -530,9 +529,11 @@ class Stats
{
//Характеристики от предметов //ТУТ tr_lvl
// Вся вторая строчка - спасибо Users.
$wearedItems = Db::getRows('select type, data, inOdet,
$wearedItems = Db::getRows(
'select type, data, inOdet,
item_id, inslot, useInBattle, btl_zd, iznosNOW, iznosMAX, magic_inci, name, items_users.id, img, `2h`
from items_users left join items_main on items_main.id = item_id where inOdet != 0 and uid = ?', [$uid]);
from items_users left join items_main on items_main.id = item_id where inOdet != 0 and uid = ?', [$uid]
);
$h = 0;
$hnd1 = 0;
@@ -1080,7 +1081,7 @@ class Stats
private function addIntelligenceBonuses(array &$st): void
{
//интелект
//интелект
if ($st['s5'] > 24 && $st['s5'] < 50) {
$st['m11'] += 10;
}
@@ -1110,7 +1111,7 @@ class Stats
private function addWisdomBonuses(array &$st): void
{
//мудрость
//мудрость
if ($st['s6'] > 24 && $st['s6'] < 50) {
$st['mpall'] += 150;
$st['speedmp'] += 100;
@@ -1151,7 +1152,8 @@ class Stats
private function addDungeonsBonuses(int $id, array &$st): void
{
$finishedDungeons = Db::getValue('select
$finishedDungeons = Db::getValue(
'select
if(repcapitalcity > 24999, 1, 0) +
if(repdemonscity > 24999, 1, 0) +
if(repangelscity > 24999, 1, 0) +
@@ -1161,7 +1163,8 @@ class Stats
if(repsandcity > 24999, 1, 0) +
if(repemeraldscity > 24999, 1, 0) +
if(repizlom > 24999, 1, 0) +
0 as finished from rep where id = ?', [$id]);
0 as finished from rep where id = ?', [$id]
);
//Бонус за количество полностью вырытых пещер.
$st['m10'] += 10 * $finishedDungeons;
@@ -1180,10 +1183,12 @@ class Stats
return;
}
Db::sql("update stats set
Db::sql(
"update stats set
tactic1 = tactic2 = tactic3 = tactic4 = tactic5 = tactic6 = tactic7 = 25,
priems_z = '0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|'
where id = ?", [$u['id']]);
where id = ?", [$u['id']]
);
}
/** Переименовывает элементы массива с несовпадающими с остальным скриптом именами полей.
@@ -1199,4 +1204,51 @@ class Stats
unset($st['level'], $st['hpnow'], $st['mpnow']);
}
public static function saveBattleStats(array $stats, int $id): void
{
if (!isset(
$stats['hpnow'],
$stats['mpNow'],
$stats['tactic1'],
$stats['tactic2'],
$stats['tactic3'],
$stats['tactic4'],
$stats['tactic5'],
$stats['tactic6'],
$stats['tactic7'],
$stats['enemy'],
$stats['battle_yron'],
$stats['battle_exp'],
$stats['last_hp'],
$stats['priems_z'],
)
) {
return;
}
Db::sql(
'update stats set hpNow = ?,mpNow = ?,
tactic1 = ?,tactic2 = ?,tactic3 = ?,tactic4 = ?,tactic5 = ?,tactic6 = ?,tactic7 = ?,
enemy = ?,battle_yron = ?,last_hp = ?,battle_exp = ?,priems_z = ?
where id = ?',
[
$stats['hpnow'],
$stats['mpNow'],
$stats['tactic1'],
$stats['tactic2'],
$stats['tactic3'],
$stats['tactic4'],
$stats['tactic5'],
$stats['tactic6'],
$stats['tactic7'],
$stats['enemy'],
$stats['battle_yron'],
$stats['battle_exp'],
$stats['last_hp'],
$stats['priems_z'],
$id,
]
);
}
}