battles/proba.php
2018-01-28 18:40:49 +02:00

39 lines
1.7 KiB
PHP

<?
include './config.php';
function solve_exp ($at_id,$def_id,$damage) {
$baseexp = array(
"0" => "5",
"1" => "10",
"2" => "20",
"3" => "30",
"4" => "60",
"5" => "120",
"6" => "180",
"7" => "300",
"8" => "450",
"9" => "600",
"10" => "1200",
);
$at = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$at_id."' LIMIT 1;"));
$at_cost = mysql_fetch_array(mysql_query("select sila+lovk+inta+vinos+intel+mudra+IFNULL((select SUM(cost) FROM inventory WHERE owner = users.id AND dressed=1),0), `align` FROM users WHERE id = ".$at_id." LIMIT 1;"));
$def = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$def_id."' LIMIT 1;"));
$def_cost = mysql_fetch_array(mysql_query("select sila+lovk+inta+vinos+intel+mudra+IFNULL((select SUM(cost) FROM inventory WHERE owner = users.id AND dressed=1),0), `align` FROM users WHERE id = ".$def_id." LIMIT 1;"));
// модификаторы опыта
$expmf = 1;
if($at['align']==4) {
$expmf = $expmf/2;
}
if((int)$at['align'] == 1 && $def['align'] == 3) {
$expmf = $expmf*2;
}
if((int)$def['align'] == 1 && $at['align'] == 3) {
$expmf = $expmf*2;
}
$expmf = $at_cost[0]/3000+1;
return ($baseexp[$def['level']])*($def_cost[0]/(($at_cost[0]+$def_cost[0])/2))*($damage/$def['maxhp'])*$expmf;
}
#echo round(solve_exp (9543,8548,27));
?>