prizes[] = [
$item->getImage(),
$item->getName(),
ltrim($prize['type'], $prize['type'][0]),
$prize['id'],
$prize['idgame'],
];
}
}
public function getPrizeListByRarity(): string
{
$prizelist = '';
$rarity = [1 => 'Частое', 'Нормальное', 'Нечастое', 'Редкое', 'Очень редкое', 'Невероятно редкое',];
$prizelistSortedByRarity = $this->prizes;
usort($prizelistSortedByRarity, fn($a, $b) => $a[self::PRIZE_RARITY] <=> $b[self::PRIZE_RARITY]);
foreach ($prizelistSortedByRarity as $prize) {
$prizelist .= '
';
$prizelist .= ' | ';
$prizelist .= '' . $prize[self::PRIZE_NAME] . ' | ';
$prizelist .= '' . $rarity[$prize[self::PRIZE_RARITY]] . ' выпадение | ';
$prizelist .= '
';
}
return $prizelist;
}
public function getPrizes(): array
{
return $this->prizes;
}
public function roll(): array
{
$result = [];
$prizes = $this->prizes;
shuffle($prizes);
$d100 = rand(1, 1000);
if ($d100 <= 5) {
$itemTier = 6;
} elseif ($d100 <= 10) {
$itemTier = 5;
} elseif ($d100 <= 30) {
$itemTier = 4;
} elseif ($d100 <= 70) {
$itemTier = 3;
} elseif ($d100 <= 150) {
$itemTier = 2;
} else {
$itemTier = 1;
}
foreach ($prizes as $prize) {
if (intval($prize[self::PRIZE_RARITY]) === $itemTier) {
$result = $prize;
break;
}
}
return [
'row_id' => $result[self::PRIZE_ROW_ID],
'item_id' => $result[self::PRIZE_ITEM_ID],
'name' => $result[self::PRIZE_NAME],
];
}
public static function freeRoll(string $uidCheck): void
{
$user = User::start()->info;
$am = new ActionModel($user['id']);
$titm = $am->getLastByValsAndTime('loto', 24 * 60 * 60);
if (intval($uidCheck) != $user['id']) {
echo 'No user!';
exit;
}
if ($titm) {
echo 'Wait asign!';
exit;
}
$loto = new Loto();
$prize = $loto->roll();
ItemsModel::addItem($prize['item_id'], $user['id'], '|frompisher=1|nosale=1' . $user['login']);
$cmsg = new ChatMessage();
$cmsg->setText("{$user['login']} выиграл в бесплатной рулетке {$prize['name']}!");
$cmsg->setType(6);
(new Chat())->sendMsg($cmsg);
ActionModel::new($user, 'loto', $prize['item_id']);
echo $prize['row_id'];
exit;
}
public static function paidRoll(string $uidCheck): void
{
$u = User::start();
if ($uidCheck == 'ekr') {
echo $u->info['money2'];
exit;
}
if (intval($uidCheck) != $u->info['id']) {
echo "No user!";
exit;
}
if ($u->info['money2'] < 5) {
echo "No Ekr!";
exit;
}
$loto = new Loto();
$prize = $loto->roll();
ItemsModel::addItem($prize['item_id'], $u->info['id'], '|frompisher=1|nosale=1' . $u->info['login']);
$u->info['money2'] = $u->info['money2'] - 5;
$u->addEkr(-5);
$cmsg = new ChatMessage();
$cmsg->setText("{$u->info['login']} выиграл в платной рулетке {$prize['name']}!");
$cmsg->setType(6);
(new Chat())->sendMsg($cmsg);
echo $prize['row_id'];
exit;
}
}