Mass update
This commit is contained in:
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
use Core\Db;
|
||||
use User;
|
||||
|
||||
class Achievements
|
||||
{
|
||||
private $user;
|
||||
private User $user;
|
||||
private $info;
|
||||
private $data = [
|
||||
private array $data = [
|
||||
'zb' => [
|
||||
'questname' => 'Åæåäí.Çàäàíèÿ',
|
||||
'quest' => 'Âûïîëíèòü çàäàíèÿ áàáêè.',
|
||||
@@ -93,41 +96,51 @@ class Achievements
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(\User $user)
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->info = Db::getRow('select * from users_achiv where id = ?', [$user->info['id']]);
|
||||
}
|
||||
|
||||
private function prizeName($int, $string)
|
||||
//fixme: ñþäà èíîãäà ïðèõîäèò (NULL, NULL).
|
||||
private function prizeName(?int $int, ?string $string): string
|
||||
{
|
||||
return in_array($string, ['åêð.', 'êð.']) ? $int . ' ' . $string : $string . ' ' . $int;
|
||||
}
|
||||
|
||||
private function drawSunduk($nagr, $whatInside, $tier)
|
||||
private function drawSunduk($nagr, $whatInside, $tier): string
|
||||
{
|
||||
return vsprintf('<img onclick="%s" onmouseover="%s" onmouseout="%s" onmousedown="%s" class="cp" src="%s" alt="Ñóíäóê">',
|
||||
return vsprintf(
|
||||
'<img onclick="%s" onmouseover="%s" onmouseout="%s" onmousedown="%s" class="cp" src="%s" alt="Ñóíäóê">',
|
||||
[
|
||||
"location.href='\main.php?titul&nagr=$nagr'",
|
||||
"top.hi(this, '<b>Ñóíäóê $tier ðàíãà<hr>Ñîäåðæèò:<hr> $whatInside</b>', event, 2, 0, 1, 1, 'max-width:307px')",
|
||||
"top.hic();",
|
||||
"top.hic();",
|
||||
"https://img.new-combats.com/i/titul/nagr$tier.gif"
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function getList()
|
||||
public function getList(): string
|
||||
{
|
||||
$string = '';
|
||||
$this->calculateCurrent(1);
|
||||
|
||||
foreach ($this->data as $key => $value) {
|
||||
|
||||
//Áëÿ, êàêóþ õåðíþ ïðèõîäèòñÿ ãîðîäèòü!
|
||||
//Ïåðâîå ÷èñëî = òðåáîâàíèå ñëåäóþùåãî òèðà ìèíóñ òðåáîâàíèå òåêóùåãî òèðà (íàäî íàáðàòü)
|
||||
//Âòîðîå ÷èñëî = êîëè÷åñòâî äîñòèæåíèé ìèíóñ òðåáîâàíèå òåêóùåãî òèðà (íàáðàë)
|
||||
//Òðåáîâàíèÿ òåêóùåãî òèðà îòíèìàþòñÿ ÷òîáû êàæäûé òèð íà÷èíàë ñ÷èòàòü ïðîöåíò ñ 0.
|
||||
//Ïèçäû äàòü òîìó, êòî òàê óåáàíñêè íàçûâàåò ïåðåìåííûå, ÷òî íóæíî ïîëäíÿ âúåçæàòü ÷òî ïðîèñõîäèò.
|
||||
//È õåð ïîìåíÿåøü - âñ¸ ñëîìàåòñÿ. FFUUUUUUUUUUUUUU!!! Ins.
|
||||
|
||||
if (!is_numeric($value['check'][$this->info['klas' . $key]])) {
|
||||
// Ïîòîìû ÷òî ïåðâûé ýëåìåíò ìàññèâà - ñëîâî. Â ÐÍÐ5.4 ïðîêàòûâàëî, â ÐÍÐ7.4 - íåò.
|
||||
$value['check'][$this->info['klas' . $key]] = 0;
|
||||
}
|
||||
|
||||
$percentToSuccess = Math::get100Percentage(
|
||||
$value['check'][$this->info['klas' . $key] + 1] - $value['check'][$this->info['klas' . $key]],
|
||||
$this->info[$key] - $value['check'][$this->info['klas' . $key]]
|
||||
@@ -136,7 +149,8 @@ class Achievements
|
||||
$string .= '<h4>' . $questname . '</h4>';
|
||||
$string .= '<strong>' . $value['quest'] . '</strong><br>';
|
||||
$string .= 'Òåêóùèé Ðàíã: <strong>' . $this->info['klas' . $key] . '</strong> ';
|
||||
$string .= 'Êîëè÷åñòâî ' . mb_strtolower($value['check'][0]) . ': <strong>' . $this->info[$key] . ' =' . $percentToSuccess . '%</strong>';
|
||||
$string .= 'Êîëè÷åñòâî ' . mb_strtolower($value['check'][0]) . ': <strong>' . $this->info[$key] . ' = ' . $percentToSuccess . '%</strong>';
|
||||
//$string .= '<progress value="' . $percentToSuccess . '" max="100" style="accent-color:green; appearance: none;">' . $percentToSuccess . '</progress>';
|
||||
|
||||
$string .= Table::get([
|
||||
['Ðàíãè', 1, 2, 3, 4, 5],
|
||||
@@ -182,6 +196,10 @@ class Achievements
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($this->info[$k])) {
|
||||
$this->info[$k] = 0;
|
||||
}
|
||||
|
||||
$this->info["klas$k"] = 0;
|
||||
$this->info["name$k"] = $this->data[$k]['questname'];
|
||||
$this->info["klasP$k"] = Math::get100Percentage($this->data[$k]['check'][1], $this->info[$k]);
|
||||
@@ -203,10 +221,10 @@ class Achievements
|
||||
}
|
||||
}
|
||||
|
||||
public function getInfo($user_id = null)
|
||||
public function getInfo(?int $uid = null)
|
||||
{
|
||||
if (!is_null($user_id)) {
|
||||
$this->info = Db::getRow('select * from users_achiv where id = ?', [$user_id]);
|
||||
if (!is_null($uid)) {
|
||||
$this->info = \Core\Db::getRow('select * from users_achiv where id = ?', [$uid]);
|
||||
}
|
||||
$this->calculateCurrent();
|
||||
return $this->info;
|
||||
@@ -220,7 +238,7 @@ class Achievements
|
||||
|
||||
private function addOne($name)
|
||||
{
|
||||
Db::sql("update users_achiv set $name = $name + 1 where id = ?", [$this->user->info['id']]);
|
||||
\Core\Db::sql("update users_achiv set $name = $name + 1 where id = ?", [$this->user->info['id']]);
|
||||
}
|
||||
|
||||
public function updateTier($name)
|
||||
@@ -240,12 +258,12 @@ class Achievements
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function getData()
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function hasNoTier4Access($nagr)
|
||||
public function hasNoTier4Access($nagr): bool
|
||||
{
|
||||
return $this->user->info['level'] < 9 && in_array($nagr, [14, 15, 24, 25, 34, 35, 44, 45, 54, 55, 64, 65, 74, 75, 84, 85, 94, 95, 104, 105]);
|
||||
}
|
||||
@@ -257,7 +275,7 @@ class Achievements
|
||||
}
|
||||
}
|
||||
|
||||
public function getTypes()
|
||||
public function getTypes(): array
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user