Функция повышения статов и её тест.

This commit is contained in:
lopar 2018-12-11 21:21:49 +02:00
parent 4c40f562b9
commit 18e783db61
2 changed files with 20 additions and 24 deletions

View File

@ -2862,3 +2862,20 @@ function addToDelo($message, $user_id = 0, $type = 1)
db::c()->query('INSERT INTO `delo` (pers, text, type, date) VALUES (?i,"?s",?i,?i)', $user_id, $message, $type, time());
return true;
}
/**
* Апаем стат или мастерство на единицу.
* @param $name - техническое имя параметра, как в базе.
* @param null $param - выбор что повышать.
* @return bool
* @throws \Krugozor\Database\Mysql\Exception
*/
function addOnePoint($name, $param = null)
{
$allowed_stats = ['sila','lovk','inta','vinos','intel','mudra'];
$allowed_mastery = ['noj','mec','dubina','topor','mfire','mwater','mair','mearth','mlight','mgray','mdark'];
if ($param == 'stat' AND in_array($name, $allowed_stats) OR $param == 'mastery' AND in_array($name, $allowed_mastery)) {
db::c()->query('UPDATE `users` SET ?f = ?f + 1, `stats` = `stats` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']);
return true;
} else return false;
}

View File

@ -1553,7 +1553,7 @@ if (input::get('edit')) {
if (input::get('ups')) {
switch (input::get('ups')) {
case 11 :
ups('stats', 'sila', 'Сила');
#ups('stats', 'sila', 'Сила');
// if ($user['stats'] > 0 && $user['sid'] == $_GET['s4i']) {
// if ($user['stats'] >= (int)$_POST['stat'] && ((int)$_POST['stat'] > 0)) {
// $user['sila'] += (int)$_POST['stat'];
@ -1566,6 +1566,7 @@ if (input::get('edit')) {
// echo "<b style=\"color: Red;\">Недостаточно статов</b>";
// }
// }
if (addOnePoint('sila','stats')) err('Параметр Сила увеличен');
break;
case 12 :
ups('stats', 'lovk', 'Ловкость');
@ -1883,8 +1884,7 @@ if (input::get('edit')) {
$q = db::c()->query('SELECT `id` FROM `komplekt` WHERE `name` = "?s" AND `owner` = ?i', input::get('savecomplect'), $_SESSION['uid'])->getNumRows();
if (empty($q)) {
$items = [];
$sql = 'SELECT `id` FROM `inventory` WHERE `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i';
$q2 = db::c()->query($sql,
$q2 = db::c()->query('SELECT `id` FROM `inventory` WHERE `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i',
$user['sergi'], $user['kulon'], $user['perchi'], $user['weap'],
$user['bron'], $user['rybax'], $user['r1'], $user['r2'], $user['r3'],
$user['helm'], $user['shit'], $user['m1'], $user['m2'], $user['m3'],
@ -1967,7 +1967,6 @@ if (input::get('edit')) {
<? echo topsethp(); ?>
var groupItems = false;
$(document).ready(function () {
$('a').live('click', function () {
if ($(this).attr('ajax') != undefined) {
@ -1975,26 +1974,6 @@ if (input::get('edit')) {
switch (ajaxModule) {
case'mZeInventory':
$('#mZeInventory').html('<div align="center" style="padding:10px;background-color:#d4d2d2;color:grey;"><b>Загрузка...</b></div>');
$.ajax({
url: $(this).attr('href') + '&mZeAjax=' + ajaxModule,
cache: false,
dataType: 'html',
success: function (html) {
$('#mZeInventory').html(html);
}
});
break;
case'mZeFilter':
if (groupItems == true) {
$(this).html('Группировать предметы');
groupItems = false;
} else {
$(this).html('Разгруппировать предметы');
groupItems = true;
}
$('#mZeInventory').html('<div align="center" style="padding:10px;background-color:#d4d2d2;color:grey;"><b>Загрузка...</b></div>');
$.ajax({
url: $(this).attr('href') + '&mZeAjax=' + ajaxModule,