Фиксы запросов

This commit is contained in:
lopar
2018-02-27 04:48:51 +02:00
parent d37c2eeb87
commit 6c31594e9b
3 changed files with 123 additions and 267 deletions

View File

@@ -2,7 +2,7 @@
class fbattle
{
var $status = integer;
var $status = 0;
var $battle = array();
var $battle_data = array();
var $enemy = null;
@@ -40,7 +40,7 @@ class fbattle
function fbattle($battle_id)
{
global $mysql, $user, $_POST, $cavedata, $caverooms, $user, $cavebots, $party;
global $mysql, $user, $_POST, $cavedata, $caverooms, $cavebots, $party;
// соединяем мускуль и юзера
$this->mysql = $mysql;
$this->user = $user;
@@ -123,10 +123,8 @@ class fbattle
if ($_POST['enemy'] > 0) {
// ударяемся
$this->razmen_init($_POST['enemy'], $_POST['attack'], $_POST['defend']);
// header ("Location:main.php");
}
if (isset($_GET['smena'], $_POST['smena'])) {
$sm = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `battle`, `bot`, `hp` FROM `users` WHERE `login` = "' . mysql_real_escape_string($_POST['smena']) . '" AND `battle` = "' . $user['battle'] . '" AND `hp` > 0 LIMIT 1'));
if (isset($sm['id'])) {
@@ -662,28 +660,15 @@ class fbattle
$this->user_dress[8] += $bmfbron;
$this->user_dress[9] += $bmfbron;
//print_r($this->user);
//print_r($this->enemyhar);
// мои МФ в отношении противника
//mt_srand(microtime());
$mykrit = $this->user_dress[2] + $this->user['inta'] * 2.95 + $bmfkrit;
//if($mykrit < 1) { $mykrit = 1; } elseif ($mykrit > 50) { $mykrit = 50; }
$heakrit = ($this->enemy_dress[3] + $this->enemyhar['inta'] * 2.75 + $this->enemyhar['lovk']) * 0 + $bmfakrit1;
//if($heakrit < 1) { $heakrit = 1; } elseif ($heakrit > 50) { $heakrit = 50; }
$myuvorot = $this->user_dress[4] + $this->user['lovk'] * 5 + $bmfuv;
//if($myuvorot < 1) { $myuvorot = 1; } elseif ($myuvorot > 50) { $myuvorot = 50; }
$heauvorot = $this->enemy_dress[5] + $this->enemyhar['lovk'] * 4 + $this->enemyhar['inta'] * 1.35 + $bmfauv1;
//if($heauvorot < 1) { $heauvorot = 1; } elseif ($heauvorot > 50) { $heauvorot = 50; }
$mf['me'] = array(
'udar' => rand(floor($this->user['sila'] / 3) + 1 + $this->user_dress[0], floor($this->user['sila'] / 3) + 5 + $this->user_dress[1]) - mt_rand(0, $this->enemy_dress[5 + $myattack] / 1.25),
//'krit' => (0-$this->enemy_dress[3]-floor($this->enemyhar['inta']*4)+$this->user_dress[2]+floor($this->user['inta']*4)),
//'uvorot' => (0-$this->enemy_dress[5]-floor($this->enemyhar['lovk']*4)+$this->user_dress[4]+floor($this->user['lovk']*4)),
'krit' => $mykrit / $heakrit * 100 - 100, //(1-($heakrit+70)/($mykrit+70))*70, //(1 - $heakrit/$mykrit)*100, //
'uvorot' => $myuvorot / $heauvorot * 100 - 100 //(1-($heauvorot+80)/($myuvorot+80))*53, //(1 - $heauvorot/$myuvorot)*0.8*100, //
'krit' => $mykrit / $heakrit * 100 - 100,
'uvorot' => $myuvorot / $heauvorot * 100 - 100
);
if ($mf['me']['udar'] < 1) {
$mf['me']['udar'] = 1;
@@ -769,43 +754,33 @@ class fbattle
return $mf;
}
/*-------------------------------------------------------------------
выставляем команды, и противников/союзников
--------------------------------------------------------------------*/
/**
* Получаем тип оружия
* @param $idwep
* @return string
*/
function get_wep_type($idwep)
{
if ($idwep == 0 || $idwep == null || $idwep == '') {
return "kulak";
$wep = db::c()->query('SELECT `otdel` FROM `inventory` WHERE `id` = ?i', $idwep)->fetch_assoc();
switch ($wep['otdel']) {
case 1: return "noj"; break;
case 11: return "topor"; break;
case 12: return "dubina"; break;
case 13: return "mech"; break;
case 14: return "priklad"; break; //???
default: return "kulak"; break;
}
$wep = mysql_fetch_array(mysql_query('SELECT `otdel`,`minu` FROM `inventory` WHERE `id` = ' . $idwep . ' LIMIT 1;'));
if ($wep[0] == '1') {
return "noj";
} elseif ($wep[0] == '12') {
return "dubina";
} elseif ($wep[0] == '11') {
return "topor";
} elseif ($wep[0] == '13') {
return "mech";
} elseif ($wep[0] == 14) {
return "priklad";
} elseif ($wep[1] > 0) {
return "buket";
} else {
return "kulak";
}
}
/*-------------------------------------------------------------------
считаем опыт
--------------------------------------------------------------------*/
/**
* Процентник 1d100. Передавать значения от 1 до 100.
* @param $persent
* @return bool
*/
function get_chanse($persent)
{
//srand(microtime());
$mm = 1000000;
if (rand($mm, 100 * $mm) <= $persent * $mm) {
if (rand(1, 100) <= $persent ) {
return true;
} else {
return false;
@@ -819,8 +794,7 @@ class fbattle
function razmen_log($type, $kuda, $chem, $uron, $kto, $c1, $pokomy, $c2, $hp, $maxhp)
{
$this->write_stat(nick5($kto, $c1) . "|++|" . nick5($pokomy, $c2) . "|++|" . $type . "|++|" . $uron . "|++|" . $kuda . "|++|" . $chem);
//print_R(func_get_args());
//echo $this->user['login']."------------------<br>";
if ($this->enemyhar['sex'] && $kto == $this->enemyhar['id']) {
$sex1 = false;
}
@@ -1016,8 +990,6 @@ class fbattle
'3' => array(3, 4),
'4' => array(4, 1)
);
/* $this->write_stat_block(nick5($this->user['id'],$this->my_class)."|++|".implode('/',$blocks[$def]));
$this->write_stat_block(nick5($enemy,$this->en_class)."|++|".implode('/',$blocks[$this->battle[$enemy][$this->user['id']][1]]));*/
switch ($komy) {
case "me" :
if (!in_array($this->battle[$enemy][$this->user['id']][0], $blocks[$def])) {
@@ -1583,7 +1555,7 @@ class fbattle
/////////////////////////////////////////////////////////////////////////////////////////////////////
include "darkness_quest.php";
include "../darkness_quest.php";
$this->exp[$v] = round($this->exp[$v]);
$dop_exp = check_proc($this->user['id']);
@@ -1835,9 +1807,30 @@ class fbattle
function solve_exp($at_id, $def_id, $damage)
{
require_once('exp_koef.php');
$baseexp = array(
$mods = [
"perv" => 1.7,
"kulon" => 1.5,
"haos" => 2,
"alignprot" => 1.5,
"kulakpenalty" => 0.5,
"bloodb" => 3,
"btl_1" => 1,
"btl_2" => 0.5,
"btl_3" => 0,
"krov_oop" => 0.2,
"krov_bitv" => 30,
"krov_op" => 1.15,
"krov_sech" => 150,
"krovs_op" => 1.4,
"velikaya" => 40,
"vel_op'" => 1.1,
"velichayshaya" => 90,
"velich_op'" => 1.15,
"epohalnaya" => 200,
"epoh_op" => 1.35,
];
$baseexp = [
"0" => "5",
"1" => "10",
"2" => "20",
@@ -1854,7 +1847,7 @@ class fbattle
"13" => "1300",
"14" => "1400",
"15" => "1500"
);
];
if ($at_id > _BOTSEPARATOR_) {
$bots = mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `id` = ' . $at_id . ' LIMIT 1;'));
$at_id = $bots['prototype'];
@@ -1875,7 +1868,7 @@ class fbattle
// модификаторы опыта
// 100% опыта
$expmf = 2;
$expmf = 1;
// 200% опыта
//$expmf = 2;
@@ -1916,15 +1909,11 @@ class fbattle
if ($at['level'] > 1 && $kulak1[0] == 0 && $kulak2[0] == 0) {
$expmf = $expmf * $mods['kulakpenalty'];
}
//if($at['level'] > 1 && $at_cost[0] < $at['level']*50) {
// $expmf = $expmf*0.7;
// } elseif($at['level'] > 1) {
// $expmf = $expmf*1.3;
// }
if ($this->battle_data['blood']) {
$expmf = $expmf * $mods['bloodb'];
}
//$expmf = $expmf+($at_cost[0]/10000);
if ($this->battle_data['type'] == 1) {
$btfl = fopen('/tmpdisk/' . $at_id . '.btl', 'r');
$contents = fread($btfl, filesize('/tmpdisk/' . $at_id . '.btl'));
@@ -1963,11 +1952,7 @@ class fbattle
$mfit = 1.5;
}
/*if ($bot_active == true) {
$this->exp[$at_id] += ($baseexp[$def['level']])*($def_cost[0]/(($at_cost[0]+$def_cost[0])/2))*($damage/$def['maxhp'])*$expmf*$mfit*0.3;
}*/
$pls = count($this->t1) + count($this->t2);
$pls = count($this->t1) + count($this->t2);
if ($pls > 2) {
$mfbot = $bot_active == true ? 0.3 : 1;
$mfbot2 = $bot_def == true ? 0.7 : 1;
@@ -1977,8 +1962,6 @@ class fbattle
}
$expmf = 1;
$expek = ($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2;
#echo "<br>|$expek| [".$def['level']."]".($baseexp[$def['level']])."*(".$def_cost[0]."/((".$at_cost[0]."+".$def_cost[0].")/2))*($damage/".$def['maxhp'].")*$expmf*$mfit*$mfbot*$mfbot2<br>";
#die();
return $expek;
}