Подрубил счётчик участий в турнирах #12

This commit is contained in:
Ivor Barhansky 2022-06-27 14:44:30 +03:00
parent 1666e39160
commit dc710a8cb1
3 changed files with 30 additions and 13 deletions

View File

@ -199,11 +199,25 @@ class Achievements
return $this->info;
}
public function updateTier($name)
private function addOne($name)
{
Db::sql("update users_achiv set $name = $name + 1 where id = ?", [$this->user->info['id']]);
}
public function updateTier($name)
{
if (in_array($name, array_keys($this->data))) {
$this->addOne($name . '_n');
}
}
public function updateCounter($name)
{
if (in_array($name, array_keys($this->data))) {
$this->addOne($name);
}
}
/**
* @return array[]
*/

View File

@ -1,6 +1,9 @@
<?php
namespace Insallah;
use Achievements;
use user;
class TournamentModel
{
@ -182,11 +185,11 @@ class TournamentModel
$db = new Db();
$db::sql('update tournaments_users set death_time = unix_timestamp() where uid = ?', [$uid]);
self::teleport($uid, 9);
(new Achievements(user::start()))->updateCounter('trn');
}
/**
* Узнаём id турнира по id игрока.
* todo Проверить, возможно можно обращаться к уровню игрока.
*
* @param int $uid
*

View File

@ -24,7 +24,7 @@ if (isset($_GET['nagr'])) {
$ai['klaszb'] > $ai['zb_n']
) {
$ai['zb_n'] += 1;
$a->updateTier('zb_n');
$a->updateTier('zb');
$a->givePrizeItems(10020, 'zb');
$nagrtxt .= 'Жетон успеха X' . $a->getData()['zb']['prize'][$ai['zb_n']];
} elseif ( //Хаот задание vx
@ -33,7 +33,7 @@ if (isset($_GET['nagr'])) {
$ai['klasvx'] > $ai['vx_n']
) {
$ai['vx_n'] += 1;
$a->updateTier('vx_n');
$a->updateTier('vx');
$u->addEkr($a->getData()['vx']['prize'][$ai['vx_n']]);
$nagrtxt .= $a->getData()['vx']['prize'][$ai['vx_n']] . $a->getData()['vx']['prize'][0];
} elseif ( //Сундуки трупожора snt
@ -42,7 +42,7 @@ if (isset($_GET['nagr'])) {
$ai['klassnt'] > $ai['snt_n']
) {
$ai['snt_n'] += 1;
$a->updateTier('snt_n');
$a->updateTier('snt');
$u->addEkr($a->getData()['snt']['prize'][$ai['snt_n']]);
$nagrtxt .= $a->getData()['snt']['prize'][$ai['snt_n']] . $a->getData()['snt']['prize'][0];
} elseif ( //Руны 8 лвл. rp
@ -51,7 +51,7 @@ if (isset($_GET['nagr'])) {
$ai['klasrp'] > $ai['rp_n']
) {
$ai['rp_n'] += 1;
$a->updateTier('rp_n');
$a->updateTier('rp');
$a->givePrizeItems(10038, 'rp');
$nagrtxt .= 'Плохие Заготовки X' . $a->getData()['rp']['prize'][$ai['rp_n']];
} elseif ( //Руны 9 лвл. rn
@ -60,7 +60,7 @@ if (isset($_GET['nagr'])) {
$ai['klasrn'] > $ai['rn_n']
) {
$ai['rn_n'] += 1;
$a->updateTier('rn_n');
$a->updateTier('rn');
$a->givePrizeItems(10039, 'rn');
$nagrtxt .= 'Нормальные Заготовки X' . $a->getData()['rn']['prize'][$ai['rn_n']];
} elseif ( //Руны 10 лвл. rb
@ -69,7 +69,7 @@ if (isset($_GET['nagr'])) {
$ai['klasrb'] > $ai['rb_n']
) {
$ai['rb_n'] += 1;
$a->updateTier('rb_n');
$a->updateTier('rb');
$a->givePrizeItems(10040, 'rb');
$nagrtxt .= 'Идеальные Заготовки X' . $a->getData()['rb']['prize'][$ai['rb_n']];
} elseif ( //Героик pg
@ -78,7 +78,7 @@ if (isset($_GET['nagr'])) {
$ai['klaspg'] > $ai['pg_n']
) {
$ai['pg_n'] += 1;
$a->updateTier('pg_n');
$a->updateTier('pg');
$a->givePrizeItems(10020, 'pg');
$nagrtxt .= 'Жетон Успеха X' . $a->getData()['pg']['prize'][$ai['pg_n']];
} elseif ( //Продать бабушке найденные вещи в пещере bv
@ -87,7 +87,7 @@ if (isset($_GET['nagr'])) {
$ai['klasbv'] > $ai['bv_n']
) {
$ai['bv_n'] += 1;
$a->updateTier('bv_n');
$a->updateTier('bv');
$u->addKr($a->getData()['bv']['prize'][$ai['bv_n']]);
$nagrtxt .= $a->getData()['bv']['prize'][$ai['bv_n']] . $a->getData()['bv']['prize'][0];
} elseif ( //Клан вар kw
@ -96,7 +96,7 @@ if (isset($_GET['nagr'])) {
$ai['klaskw'] > $ai['kw_n']
) {
$ai['kw_n'] += 1;
$a->updateTier('kw_n');
$a->updateTier('kw');
$a->givePrizeItems(4917, 'kw');
$nagrtxt .= 'Клановый опыт +50000 X' . $a->getData()['kw']['prize'][$ai['kw_n']];
} elseif ( //Башня смерти задание bs
@ -105,7 +105,7 @@ if (isset($_GET['nagr'])) {
$ai['klasbs'] > $ai['bs_n']
) {
$ai['bs_n'] += 1;
$a->updateTier('bs_n');
$a->updateTier('bs');
$u->addEkr($a->getData()['bs']['prize'][$ai['bs_n']]);
$nagrtxt .= $a->getData()['bs']['prize'][$ai['bs_n']] . $a->getData()['bs']['prize'][0];
} elseif ( //Турниры победы trn
@ -114,7 +114,7 @@ if (isset($_GET['nagr'])) {
$ai['klastrn'] > $ai['trn_n']
) {
$ai['trn_n'] += 1;
$a->updateTier('trn_n');
$a->updateTier('trn');
$u->addEkr($a->getData()['trn']['prize'][$ai['trn_n']]);
$nagrtxt .= $a->getData()['trn']['prize'][$ai['trn_n']] . $a->getData()['trn']['prize'][0];
}