defined('AntiBK') or die("Доступ запрещен!");
class Equip extends Char
{
public $guid;
public $db;
public $char;
function Init ($object)
{
$this->guid = $object->guid;
$this->db = $object->db;
$this->char = $object;
}
/*Вычисление цены продажи предмета*/
function getSellValue ($i_info, $text = false)
{
if (!$i_info)
return 0;
$price = ($i_info['price_euro'] > 0) ?$i_info['price_euro'] :$i_info['price'];
$tmax_diff = ($i_info['tear_max'] < $i_info['tear']) ?$price * 0.7 * (1 - $i_info['tear_max'] / $i_info['tear']) :0;
$price_diff = $price * 0.7 - $tmax_diff;
$tear_diff = ($i_info['tear_cur'] > 0) ?$price_diff * ($i_info['tear_cur'] / $i_info['tear_max']) :0;
$sell_price = $price * 0.75 - $tmax_diff - $tear_diff;
$sell_price = rdf($sell_price);
if ($sell_price < 0.01)
$sell_price = 0.01;
$sell_price = ($text) ?$sell_price." кр." :$sell_price;
return $sell_price;
}
/*Проверка характеристик предмета и персонажа*/
function checkItemStats ($item_id)
{
if (checki($item_id))
return false;
$dat = $this->db->selectRow("SELECT `i`.`min_level`,
`i`.`sex`, `i`.`orden`,
`i`.`min_str`, `i`.`min_dex`,
`i`.`min_con`, `i`.`min_vit`,
`i`.`min_int`, `i`.`min_wis`,
`i`.`min_mp_all`,
`i`.`min_sword`, `i`.`min_axe`,
`i`.`min_fail`, `i`.`min_knife`,
`i`.`min_staff`,
`i`.`min_fire`, `i`.`min_water`,
`i`.`min_air`, `i`.`min_earth`,
`i`.`min_light`, `i`.`min_gray`,
`i`.`min_dark`,
`c`.`is_personal`, `c`.`personal_owner`,
`c`.`tear_cur`, `c`.`tear_max`
FROM `character_inventory` AS `c`
LEFT JOIN `item_template` AS `i`
ON `c`.`item_entry` = `i`.`entry`
WHERE `c`.`guid` = ?d
and `c`.`id` = ?d", $this->guid ,$item_id);
$char_db = $this->getChar('char_db', 'level', 'sex', 'orden');
$char_stats = $this->getChar('char_stats', 'str', 'dex', 'con', 'vit', 'int', 'wis', 'mp_all', 'sword', 'axe', 'fail', 'knife', 'staff', 'fire', 'water', 'air', 'earth', 'light', 'gray', 'dark');
$char_feat = array_merge($char_db, $char_stats);
foreach ($char_feat as $key => $value)
{
if ($key != 'sex' && $key != 'orden' && $value < $dat['min_'.$key]) return false;
if ($key == 'sex' && $dat['sex'] != '' && $value != $dat['sex']) return false;
if ($key == 'orden' && $dat['orden'] != 0 && $value != $dat['orden']) return false;
}
if ($dat['is_personal'] && $dat['personal_owner'] != $this->guid)
return false;
if ($dat['tear_cur'] >= $dat['tear_max'])
return false;
return true;
}
/*Проверка годности предмета*/
function checkItemValidity ($item_id)
{
if (checki($item_id))
return false;
$date = $this->db->selectCell("SELECT `date` FROM `character_inventory` WHERE `guid` = ?d and `id` = ?d", $this->guid ,$item_id);
if ($date != 0 && $date < time())
return false;
return true;
}
/*Проверка отображения модификаторов*/
function checkHandStatus ($hand)
{
$char_equip = $this->getChar('char_equip', 'hand_l_free', 'hand_r_free', 'hand_l_type', 'hand_l', 'hand_r');
switch ($hand)
{
case 'r':
if ($char_equip['hand_r'] != 0 || ($char_equip['hand_l_free'] == 1 & $char_equip['hand_r_free'] == 1) || $char_equip['hand_l_type'] == 'shield')
return true;
case 'l':
if ($char_equip['hand_l'] != 0 && $char_equip['hand_l_type'] != 'shield')
return true;
}
return false;
}
/*Отображение снаряжения*/
function showCharacter ($type = '', $guid = 0)
{
$guid = $this->getGuid($guid);
$char_equip = $this->getChar('char_equip', '*', $guid);
$char_db = $this->getChar('char_db', 'level', 'login', 'shape', $guid);
$char_stats = $this->getChar('char_stats', 'str', 'dex', 'con', 'vit', 'int', 'wis', 'spi', 'hp', 'hp_all', 'hp_regen', 'mp', 'mp_all', 'mp_regen', $guid);
$char_feat = array_merge($char_db, $char_stats);
$lang = $this->getLang();
$char_type = 'clan';
switch ($type)
{
case 'inv':
$char_feat['name'] = "alt='$char_feat[login] (Перейти в \"$lang[abilities]\")' id='link' link='skills'";
break;
case 'fight':
global $behaviour;
$char_feat['name'] = "alt='$char_feat[login]";
foreach ($behaviour as $key => $min_level)
$char_feat['name'] .= ($char_feat['level'] >= $min_level) ?"
$lang[$key] $char_feat[$key]" :"";
$char_feat['name'] .= "'";
break;
default:
$char_feat['name'] = "alt='$char_feat[login] (Перейти в \"Инвентарь\")' id='link' link='inv'";
break;
}
$char_equip['armor'] = ($char_equip['cloak']) ?$char_equip['cloak'] :(($char_equip['armor']) ?$char_equip['armor'] :$char_equip['shirt']);
$char_equip['hand_l_s'] = (!$char_equip['hand_l_free']) ?"hand_l" :"hand_l_f";
echo $this->getLogin($char_type, $guid);
echo $this->getCharacterEquipped($char_equip, $char_feat, $type, $guid);
if ($type != 'smart')
echoScript("showHP($char_feat[hp], $char_feat[hp_all], $char_feat[hp_regen]);".
"showMP($char_feat[mp], $char_feat[mp_all], $char_feat[mp_regen]);");
}
/*Получение одетых вещей*/
function getCharacterEquipped ($char_equip, $char_feat, $type, $guid = 0)
{
if (!$char_equip || !$char_feat)
return;
$guid = $this->getGuid($guid);
$backup = ($type == 'smart') ?"" :"
";
$effects = $this->getEffects($type, $guid);
$equipped = "
" . $this->getItemEquiped($char_equip['helmet'], "helmet", $type, $guid) . $this->getItemEquiped($char_equip['bracer'], "bracer", $type, $guid) . $this->getItemEquiped($char_equip['hand_r'], "hand_r", $type, $guid) . $this->getItemEquiped($char_equip['armor'], "armor", $type, $guid) . $this->getItemEquiped($char_equip['belt'], "belt", $type, $guid) . " | " . "
| "
. "" . $this->getItemEquiped($char_equip['earring'], "earring", $type, $guid) . $this->getItemEquiped($char_equip['amulet'], "amulet", $type, $guid) . $this->getItemEquiped($char_equip['ring1'], "ring", $type, $guid) . $this->getItemEquiped($char_equip['ring2'], "ring", $type, $guid) . $this->getItemEquiped($char_equip['ring3'], "ring", $type, $guid) . $this->getItemEquiped($char_equip['gloves'], "gloves", $type, $guid) . $this->getItemEquiped($char_equip['hand_l'], $char_equip['hand_l_s'], $type, $guid) . $this->getItemEquiped($char_equip['pants'], "pants", $type, $guid) . $this->getItemEquiped($char_equip['boots'], "boots", $type, $guid) . " |
";
$return .= "![]() ";
$return .= " | ![]() ";
$return .= " | ";
$return .= " | ";
$return .= " | Отказаться"; $return .= " (".getFormatedTime($i_info['delivery_time'] + 5184000).")"; break; case 'money_in': $name = sprintf($name, $i_info['count']); $price_s = "$i_info[count] кр."; $mail_id = $i_info['id']; $return .= " ";
$return .= " | Отказаться"; $return .= " (".getFormatedTime($i_info['delivery_time'] + 5184000).")"; break; } $return .= " ";
$tear_show = compare($tear_cur, $tear_max * 0.90, "$tear_cur/$tear_max");
$required = array('dex', 'con', 'int', 'level', 'fire', 'water', 'air', 'earth', 'sword', 'axe', 'fail', 'knife', 'staff', 'vit', 'str', 'mp_all', 'wis', 'sex');
$modifiers = array('mf_critp', 'mf_acrit', 'mf_adodge', 'mf_parmour', 'mf_crit', 'mf_parry', 'mf_shieldb', 'mf_dodge', 'mf_contr', 'rep_magic',
'rep_fire', 'rep_water', 'rep_air', 'rep_earth', 'mf_magic', 'mf_fire', 'mf_water', 'mf_air', 'mf_earth', 'mf_light', 'mf_gray',
'mf_dark', 'mf_dmg', 'mf_sting', 'mf_slash', 'mf_crush', 'mf_sharp', 'all_magic', 'fire', 'water', 'air', 'earth', 'light', 'gray',
'dark', 'all_mastery', 'sword', 'axe', 'fail', 'knife', 'staff', 'res_magic', 'res_fire', 'res_water', 'res_air',
'res_earth', 'res_light', 'res_gray', 'res_dark', 'res_dmg', 'res_sting', 'res_slash', 'res_crush', 'res_sharp',
'add_hp', 'add_mp', 'mp_cons', 'mp_regen', 'hp_regen', 'add_hit_min', 'add_hit_max');
$w_modifiers = array('mf_adodge', 'mf_crit', 'mf_critp', 'mf_sting', 'mf_slash', 'mf_crush', 'mf_sharp', 'sword', 'axe', 'fail', 'knife', 'mf_parmour');
$chances = array('ch_sting', 'ch_slash', 'ch_crush', 'ch_sharp', 'ch_fire', 'ch_water', 'ch_air', 'ch_earth', 'ch_light', 'ch_dark');
$features = array('res_dmg', 'res_sting', 'res_slash', 'res_crush', 'res_sharp');
$brick = $i_info['brick'];
$def = array(
'h' => array($i_info['def_h'], ($i_info['def_h'] + $brick), $this->getFormatedBrick($i_info['def_h'], $brick)),
'a' => array($i_info['def_a'], ($i_info['def_a'] + $brick), $this->getFormatedBrick($i_info['def_a'], $brick)),
'b' => array($i_info['def_b'], ($i_info['def_b'] + $brick), $this->getFormatedBrick($i_info['def_b'], $brick)),
'l' => array($i_info['def_l'], ($i_info['def_l'] + $brick), $this->getFormatedBrick($i_info['def_l'], $brick))
);
$attack = $i_info['attack'];
$block = $i_info['block'];
$hands = $i_info['hands'];
$url = str_replace('.gif', '.html', $i_info['img']);
$orden = " ";
$need_orden = $i_info['orden'];
if ($need_orden != 0)
{
switch ($need_orden)
{
case 1: $orden_dis = "Белое братство"; break;
case 2: $orden_dis = "Темное братство"; break;
case 3: $orden_dis = "Нейтральное братство"; break;
case 4: $orden_dis = "Алхимик"; break;
case 5: $orden_dis = "Тюремный заключенный"; break;
}
$orden = " | ![]() ![]() ![]() $lang[price] $price_s"; $return .= " $lang[durability] $tear_show"; if (($mode == 'inv' || $mode == 'sell') && $validity > 0)$return .= " ".sprintf($lang['validity'], date('d.m.y H:i', $validity), getFormatedTime($validity)); else if ($mode == 'shop' && $validity > 0) $return .= " $lang[val_life] ".getFormatedTime($validity * 3600 + time()); $val = ""; $require = ""; foreach ($required as $key) { if (($key != 'sex' && $i_info['min_'.$key] <= 0) || ($key == 'sex' && $i_info[$key] == '')) continue; if (!$val) $val = " $lang[required]"; if ($key != 'sex' && $i_info['min_'.$key] > 0) $require .= " • ".(compare($i_info['min_'.$key], $char_feat[$key], "$lang[$key] ".$i_info['min_'.$key])); else if ($key == 'sex' && $i_info[$key] != '') $require .= " • ".(compare($i_info[$key], $char_feat[$key], "$lang[$key] ".$lang['sex_'.$i_info[$key]])); } $return .= $val.$require; $val = ""; if (($add['str'] != 0 || $add['dex'] != 0 || $add['con'] != 0 || $add['int'] != 0 || $i_info['def_h'] != 0 || $i_info['def_a'] != 0 || $i_info['def_b'] != 0 || $i_info['def_l'] != 0 || $inc_count > 0 || (!in_array($type, $weapons) && $attack != 0))) $val = " $lang[act]"; $inc = ($inc_count > 0) ?" • $lang[inc_count] $inc_count" :""; $modifier = ""; foreach ($modifiers as $key) { if ($i_info[$key] == 0) continue; if (!$val) $val = " $lang[act]"; if ($i_info[$key] > 0) $modifier .= " • $lang[$key] +".$i_info[$key]; else if ($i_info[$key] < 0) $modifier .= " • $lang[$key] ".$i_info[$key]; } $return .= $val.$inc.$modifier; foreach ($add as $key => $value) { if ($value == 0 && $mode == 'inv' && $inc_count > 0) $return .= " • $lang[$key] $value ".$this->getIncButton($item_id, $key); else if ($value > 0 && $mode == 'inv' && $inc_count > 0)$return .= " • $lang[$key] +$value ".$this->getIncButton($item_id, $key); else if ($value > 0) $return .= " • $lang[$key] +$value"; else if ($value < 0) $return .= " • $lang[$key] $value"; } foreach ($def as $key => $value) { if ($value[0] > 0) $return .= " • ".$lang['def_'.$key]." $value[0]-$value[1] $value[2]"; } if (in_array($type, $weapons)) { $return .= " $lang[behaviour]"; $return .= " • $lang[damage] $attack - ".($attack + $brick); foreach ($w_modifiers as $key) { if ($i_info[$key.'_h'] != 0) $return .= " • $lang[$key] ".$i_info[$key.'_h']; } if ($item_flags & 16) $return .= " • $lang[sec_hand]"; else if ($hands == 2) $return .= " • $lang[two_hands]"; $return .= " • $lang[blocks] "; if ($block == 1) $return .= "+"; else if ($block == 2) $return .= "++"; else $return .= "-"; $val = ""; $chance = ""; foreach ($chances as $key) { if ($i_info[$key] <= 0) continue; if (!$val) $val = " $lang[features]"; $this->getFormatedChance($i_info[$key]); $chance .= " • $lang[$key] ".$lang[$i_info[$key]]; } $return .= $val.$chance; } if (in_array($type, array_keys($armors))) { $val = ""; $armor = ""; foreach ($features as $key) { if ($i_info[$key.$armors[$type]] <= 0) continue; if (!$val) $val = " $lang[features]"; $armor .= " • $lang[$key] ".$i_info[$key.$armors[$type]]; } $return .= $val.$armor; } if ($i_info['description']) $return .= " $lang[description] $i_info[description]"; if ($made_in) $return .= " $lang[made_in] $made_in"; if (!($item_flags & 2)) $return .= " $lang[no_repair]"; $return .= " |