Переделан знак зодиака на более точный

This commit is contained in:
Igor Barkov (iwork) 2020-07-03 18:36:06 +03:00
parent 93d2fbae64
commit 0bf3143ec1
2 changed files with 65 additions and 19 deletions

View File

@ -12,6 +12,7 @@ require_once 'config.php';
*/ */
if (isset($_SESSION['uid'])) { if (isset($_SESSION['uid'])) {
$user = (new users_row($_SESSION['uid']))->result(); $user = (new users_row($_SESSION['uid']))->result();
$userr = new User($_SESSION['uid']);
} else { } else {
echo "Не могу проинициализировать игрока!"; echo "Не могу проинициализировать игрока!";
} }
@ -160,21 +161,17 @@ header("Cache-Control: no-cache");
function level_up($uid) function level_up($uid)
{ {
global $exptable; global $exptable;
$us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `exp`, `vinos`, `nextup`, `stats`, `master`, `maxhp`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc(); $us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `exp`, `nextup`, `stats`, `master`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc();
if (isset($us['id']) && $us['exp'] >= $us['nextup'] && !$us['in_tower']) { if (isset($us['id']) && $us['exp'] >= $us['nextup'] && !$us['in_tower']) {
if ($exptable[$us['nextup']][4] == 1) { if ($exptable[$us['nextup']][4] == 1) {
addch("Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень."); addch("Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень.");
addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый уровень. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}'); addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый уровень. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
} elseif ($exptable[$us['nextup']][4] == 0) {
addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый АП. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
} }
$us['nextup'] = $exptable[$us['nextup']][5]; $us['nextup'] = $exptable[$us['nextup']][5];
$us['stats'] += $exptable[$us['nextup']][0]; $us['stats'] += $exptable[$us['nextup']][0];
$us['master'] += $exptable[$us['nextup']][1]; $us['master'] += $exptable[$us['nextup']][1];
$us['vinos'] += $exptable[$us['nextup']][2];
$us['maxhp'] += ($exptable[$us['nextup']][2] * 6); db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['level'], $us['id']);
$us['money'] += $exptable[$us['nextup']][3];
db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `vinos` = ?i, `maxhp` = ?i, `money` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['vinos'], $us['maxhp'], $us['money'], $us['level'], $us['id']);
} }
} }
@ -183,9 +180,11 @@ function level_up($uid)
*/ */
if (isset($_SESSION['uid'])) { if (isset($_SESSION['uid'])) {
try { try {
$userInfo = db::c()->query('SELECT `id`, `exp`, `nextup`, `level` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); $userInfo = db::c()->query('SELECT `exp`, `nextup`, `level` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
if ($userInfo && ($userInfo['exp'] >= $userInfo['nextup']) && $userInfo['level'] < 50) { if ($userInfo && ($userInfo['exp'] >= $userInfo['nextup']) && $userInfo['level'] < 50) {
level_up($in_user['id']); level_up($_SESSION['uid']);
$levelUpArray = ['nextup' => $nextup, 'stats' =>];
db::c()->query('UPDATE users SET ?Ai, stats = (stats +2), level = (level +1) WHERE id = ?i', $levelUpArray, $_SESSION['uid']);
} }
} catch (\Krugozor\Database\Mysql\Exception $e) { } catch (\Krugozor\Database\Mysql\Exception $e) {
echo $e->getTraceAsString(); echo $e->getTraceAsString();
@ -327,7 +326,9 @@ HTML;
/** /**
* Функция отображает слот для свитков в окне персонажа. * Функция отображает слот для свитков в окне персонажа.
*
* @param $slot * @param $slot
*
* @throws \Krugozor\Database\Mysql\Exception * @throws \Krugozor\Database\Mysql\Exception
*/ */
function echoscroll($slot) function echoscroll($slot)
@ -1986,15 +1987,55 @@ function addlog($id, $log)
unset($id, $log); unset($id, $log);
} }
function star_sign($month, $day) //function star_sign($month, $day)
//{
// if (empty($month) || empty($day)) {
// $month = (int)sprintf("%02d", mt_rand(1, 12));
// $day = (int)sprintf("%02d", mt_rand(1, 29));
// }
// $signs = ["10", "11", "12", "01", "02", "03", "04", "05", "06", "07", "08", "09"];
// $signsstart = ['01' => 21, '02' => 20, '03' => 20, '04' => 20, '05' => 20, '06' => 20, '07' => 21, '08' => 22, '09' => 23, '10' => 23, '11' => 23, '12' => 23];
// return $day < $signsstart[$month + 1] ? $signs[$month - 1] : $signs[$month % 12];
//}
function star_sign($date)
{ {
if (empty($month) || empty($day)) { /*
$month = (int)sprintf("%02d", mt_rand(1, 12)); * 1 aries
$day = (int)sprintf("%02d", mt_rand(1, 29)); * 2 taurus
* 3 gemini
* 4 cancer
* 5 leo
* 6 virgo
* 7 libra
* 8 scorpio
* 9 sagittarios
* 10 capricorn
* 11 aquarius
* 12 pisches
*/
$zodiac[356] = "10";
$zodiac[326] = "09";
$zodiac[296] = "08";
$zodiac[266] = "07";
$zodiac[235] = "06";
$zodiac[203] = "05";
$zodiac[172] = "04";
$zodiac[140] = "03";
$zodiac[111] = "02";
$zodiac[78] = "01";
$zodiac[51] = "12";
$zodiac[20] = "11";
$zodiac[0] = "10";
$dayOfYear = date("z", $date);
$isLeapYear = date("L", $date); //Высокосный?
if ($isLeapYear && $dayOfYear >59) {
$dayOfYear = $dayOfYear - 1;
} }
$signs = ["10", "11", "12", "01", "02", "03", "04", "05", "06", "07", "08", "09"]; foreach ($zodiac as $day => $sign) {
$signsstart = ['01' => 21, '02' => 20, '03' => 20, '04' => 20, '05' => 20, '06' => 20, '07' => 21, '08' => 22, '09' => 23, '10' => 23, '11' => 23, '12' => 23]; if ($dayOfYear > $day) break;
return $day < $signsstart[$month + 1] ? $signs[$month - 1] : $signs[$month % 12]; }
return $sign;
} }
function SolveExp($at_id, $def_id, $damage) function SolveExp($at_id, $def_id, $damage)

11
inf.php
View File

@ -22,7 +22,10 @@ function private_access($uid)
} }
//$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user->id); //$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user->id);
function getnumrows() {} function getnumrows()
{
}
$presents = []; $presents = [];
if (empty($user->id)): ?> if (empty($user->id)): ?>
@ -61,7 +64,7 @@ if (empty($user->id)): ?>
<?php endif; ?> <?php endif; ?>
</td> </td>
<td style="vertical-align: top; width: 100px; text-align: center;"> <td style="vertical-align: top; width: 100px; text-align: center;">
<img src="i/zodiac/<?= star_sign(substr($user->borndate, 3, 2), substr($user->borndate, 0, 2)); ?>.png" alt="Родовой знак"> <img src="i/zodiac/<?php /*echo star_sign(substr($user->borndate, 3, 2), substr($user->borndate, 0, 2));*/ echo star_sign($user->borndate); ?>.png" alt="Родовой знак">
</td> </td>
</tr> </tr>
</table> </table>
@ -73,7 +76,9 @@ try {
if ($effect['time'] && !private_access($uid)) { if ($effect['time'] && !private_access($uid)) {
die('<h3>Персонаж обезличен!</h3>'); die('<h3>Персонаж обезличен!</h3>');
} }
} catch (Exception $e) {echo "<span class='error'>Не подтянулась таблица с эффектами. Не работает обезличка!</span>";} } catch (Exception $e) {
echo "<span class='error'>Не подтянулась таблица с эффектами. Не работает обезличка!</span>";
}
if (!empty($user->realname)) { if (!empty($user->realname)) {
echo "Имя: " . $user->realname . "<br>"; echo "Имя: " . $user->realname . "<br>";
} }