game/modules_data/location/loto.php

385 lines
15 KiB
PHP
Raw Normal View History

2022-06-06 21:30:34 +00:00
<?php
use Core\Config;
use Location\Loto;
use Model\ActionModel;
if (!defined('GAME')) {
die();
}
if ($u->room['file'] != 'loto') {
return;
2022-06-06 21:30:34 +00:00
}
$loto = new Loto();
$am = new ActionModel($u->info['id']);
$titm = $am->getLastByVals($u->room['file']);
if ($_GET['get'] == '20' && isset($titm['id']) && $u->info['money2'] > 5) {
$u->info['money2'] = $u->info['money2'] - 5;
$u->addEkr(-5);
$am->deleteByVals($u->room['file']);
2022-06-06 21:30:34 +00:00
}
$titm = $am->getLastByValsAndTime($u->room['file'], 24 * 60 * 60);
2022-06-06 21:30:34 +00:00
?>
<TABLE width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" id="centerBlockLoto">
<div align="center" class="pH3"><h1>Ежедневная Бесплатная Рулетка</h1></div>
<br/>
2022-06-06 21:30:34 +00:00
<div id="winDiv">
2023-01-10 16:29:32 +00:00
<p class="testDiv">Ваш приз: <span id="win"></span></p>
2022-06-06 21:30:34 +00:00
<div id="imgWin"></div>
</div>
<div class="wraper">
<div class="arrowup"></div>
<div class="arrowdown"></div>
<div class="window">
<ul class="list"></ul>
</div>
</div>
<p style="text-align: center">
<?php if (!$titm): ?>
<button class="buttonRuletka" formmethod="get">Запустить игру!</button>
<?php else: ?>
<button class="buttonRuletka" disabled formmethod="get">
Приходите Завтра!
</button>
<?php endif; ?>
<button class="buttonsElements">Предметы и шансы</button>
2022-06-06 21:30:34 +00:00
<div id="tableItemChange" hidden>
<table>
<tr>
2023-01-10 16:29:32 +00:00
<th colspan="2">Предмет</th>
<th>Шанс выпадения</th>
2022-06-06 21:30:34 +00:00
</tr>
<?= $loto->getPrizeListByRarity() ?>
2022-06-06 21:30:34 +00:00
</table>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
2022-06-06 21:30:34 +00:00
<script>
let img = "<?= Config::get('img2') ?>/i/items";
let prizesArray = <?= json_encode($loto->getPrizes()) ?>;
let arrLiImg = [];
2022-06-06 21:30:34 +00:00
prizesArray.forEach(function (elem, key) {
arrLiImg.push(`<li><img src="${img}/${elem[0]}" title="${elem[1]}" alt="${elem[1]}" type="id${key}"></li>`);
});
2022-06-06 21:30:34 +00:00
let ulImg = document.getElementsByClassName("list")[0]
2022-06-06 21:30:34 +00:00
let finallyLiImg = arrLiImg.sort(() => 0.5 - Math.random())
2022-06-06 21:30:34 +00:00
for (let key of finallyLiImg) {
let htmlElementsMessage = new DOMParser().parseFromString(key, "text/html").getElementsByTagName("li")[0]
ulImg.append(htmlElementsMessage)
2022-06-06 21:30:34 +00:00
}
var $button = document.getElementsByClassName("buttonRuletka")[0]
var $winWindow = document.getElementById("winDiv")
var $win = document.getElementById("win")
var $wrapper = document.getElementsByClassName("wraper")[0]
var $imgWin = document.getElementById("imgWin")
$wrapper.style.marginTop = "110px"
$winWindow.hidden = true
var timeOutWin
2022-06-06 21:30:34 +00:00
$(document).ready(function () {
for (i = 0; i < 3; i++) {
$(".list li").clone().appendTo(".list");
}
$button.onclick = async function () {
$wrapper.style.marginTop = "110px"
if (timeOutWin) {
clearTimeout(timeOutWin)
$imgWin.innerHTML = ""
$winWindow.hidden = true
}
$imgWin.innerHTML = ""
2023-01-10 16:29:32 +00:00
$button.textContent = "Ожидание..."
2022-06-06 21:30:34 +00:00
$button.disabled = true
var response = await fetch("/lotowork.php", {
2022-06-06 21:30:34 +00:00
method: "POST",
body: <?= $u->info['id'] ?>
2022-06-06 21:30:34 +00:00
})
2022-06-06 21:30:34 +00:00
$('.window').css({
right: "0"
})
$('.list li').css({
border: '4px solid transparent'
})
2022-12-19 18:26:14 +00:00
var textFromResponse = await response.text()
var resultRegexp = textFromResponse.match(/\b[0-9]{0,2}\b/);
var idItem = '';
2022-12-19 18:26:14 +00:00
if (resultRegexp && resultRegexp[0] && resultRegexp[0] >= 0 && resultRegexp[0] <= 29) {
idItem = resultRegexp[0];
} else {
2023-01-10 16:29:32 +00:00
return ($button.textContent = 'Ошибка, нажмите F5!');
2022-06-06 21:30:34 +00:00
}
var elemRul = 0
var $winImg
for (var i = 60; i < 90; i++) {
if ($('.list li:eq(' + i + ')')[0].children[0].getAttribute("type") == `id${idItem}`) {
2022-06-06 21:30:34 +00:00
elemRul = $('.list li:eq(' + i + ')')[0].children[0].offsetLeft
$winImg = $('.list li:eq(' + i + ')')[0]
}
}
2022-06-06 21:30:34 +00:00
$('.window').animate({
right: elemRul - 452.5
}, 10000, () => {
setTimeout(() => {
2022-06-06 21:30:34 +00:00
var idThing = $winImg.children[0].getAttribute("type")
var titleThing = $winImg.children[0].getAttribute("title")
$wrapper.style.marginTop = "0px"
$winWindow.hidden = false
2023-01-10 16:29:32 +00:00
$button.textContent = "Приходите завтра!"
2022-06-06 21:30:34 +00:00
$win.textContent = titleThing
var $img = document.createElement("img")
$img.src = $winImg.children[0].getAttribute("src")
$imgWin.append($img)
timeOutWin = setTimeout(() => {
2022-06-06 21:30:34 +00:00
$imgWin.innerHTML = ""
$winWindow.hidden = true
$wrapper.style.marginTop = "110px"
}, 10000)
}, 300)
})
// });
2022-06-06 21:30:34 +00:00
}
});
var $buttonsElements = document.getElementsByClassName("buttonsElements")[0]
var $tableItemChange = document.getElementById("tableItemChange")
$buttonsElements.onclick = function (event) {
2022-12-19 18:26:14 +00:00
var contentIsHidden = $tableItemChange.hidden;
$tableItemChange.hidden = !contentIsHidden;
2023-01-10 16:29:32 +00:00
event.target.textContent = !contentIsHidden ? 'Предметы и шансы' : 'Скрыть шансы';
2022-06-06 21:30:34 +00:00
}
</script>
<style>
#centerBlockLoto {
display: flex;
flex-direction: column;
}
2022-06-06 21:30:34 +00:00
* {
padding: 0;
margin: 0;
}
li {
list-style: none;
display: inline-block;
float: left;
}
2022-06-06 21:30:34 +00:00
#tableItemChange table {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
2022-06-06 21:30:34 +00:00
font-size: 14px;
text-align: center;
margin: auto;
}
#tableItemChange table td, th {
border-style: solid;
border-width: 1px;
border-collapse: collapse;
border-color: rgb(47, 1, 1);
padding: 3px 5px;
}
2022-06-06 21:30:34 +00:00
#tableItemChange table tr th {
font-size: 16px;
}
#tableItemChange {
text-align: center;
border: 1px solid #1a96bf;
width: 70%;
margin-left: auto;
margin-right: auto;
padding: 5px;
}
.buttonsElements {
font-size: 17px;
padding: 5px;
width: 200px;
border: 1px solid #1a96bf;
background: rgba(182, 114, 4, 0.3);
}
.window {
padding: 5px 0;
overflow: hidden;
position: relative;
width: 25000px;
height: 82px;
right: 0;
2022-06-06 21:30:34 +00:00
}
.wraper {
position: relative;
margin: auto;
width: 982px;
overflow-x: hidden;
overflow-y: hidden;
border: 4px solid #1a96b7;
border-radius: 2px;
}
.list {
position: relative;
margin-left: 0;
display: inline-block;
}
.list li {
border: 4px solid transparent;
}
.list li img {
width: 75px;
height: 75px;
}
2022-06-06 21:30:34 +00:00
.arrowup {
position: absolute;
bottom: 0;
left: 487.5px;;
z-index: 1;
width: 0;
height: 0;
border-bottom: 20px solid #1a96bf;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
}
.arrowdown {
position: absolute;
top: 0;
left: 487.5px;;
z-index: 1;
width: 0;
height: 0;
border-top: 20px solid #1a96bf;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
}
2022-06-06 21:30:34 +00:00
.buttonRuletka {
font-size: 17px;
padding: 5px;
width: 200px;
border: 1px solid #1a96bf;
background: rgba(0, 149, 25, 0.33);
margin: 10px 0;
}
2022-06-06 21:30:34 +00:00
.buttonRuletka:hover, .buttonsElements:hover {
background: rgba(0, 102, 149, 0.33);
}
2022-06-06 21:30:34 +00:00
#winDiv {
text-align: center;
border-radius: 3px;
border: 1px solid #000;
width: auto;
margin: 10px auto 5px;
padding: 7px;
}
2022-06-06 21:30:34 +00:00
.testDiv {
font-size: 16px;
}
2022-06-06 21:30:34 +00:00
#win {
font-weight: 600;
}
</style>
<td width="50" valign="top">
<TABLE cellspacing="0" cellpadding="0">
<tr>
<TD width="100%">&nbsp;</TD>
<TD>
<table border="0" cellpadding="0" cellspacing="0">
<tr align="right" valign="top">
<td>
<?= $goLis; ?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td nowrap="nowrap">
<tr>
<td bgcolor="#D3D3D3">
<img src="<?= Config::get('img2') ?>/i/move/links.gif" width="9"
height="7">
</td>
<td bgcolor="#D3D3D3" nowrap>
<a
href="#"
id="greyText"
class="menutop"
onclick="location='main.php?loc=1.180.0.9&rnd=<?= PassGen::intCode(
) ?>';"
title="<?php thisInfRm('1.180.0.9', 1); ?>">
Центральная площадь
</a>
</td>
</tr>
<tr>
<td bgcolor="#D3D3D3">
<img src="<?= Config::get('img2') ?>/i/move/links.gif" width="9"
height="7">
</td>
<td bgcolor="#D3D3D3" nowrap>
<a
href="#"
id="greyText"
class="menutop"
onclick="location='main.php?loc=1.180.0.449&rnd=<?= PassGen::intCode(
) ?>';"
title="<?php thisInfRm('1.180.0.449', 1); ?>">
Платная Комната
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</TABLE>
</td>
</tr>
</table>
<br><br>
<div id="textgo" style="visibility:hidden;"></div>