Требование: PHP => 5.3
[cswowd.git] / module / show / show_item.php
blobfc13383f5dac7040ef130528f83083fc7e763a36
1 <?php
2 include_once("conf.php");
3 include_once("include/info_table_generator.php");
4 include_once("include/gameobject_table.php");
5 include_once("include/report_generator.php");
7 ##########
8 /*
9 Скрипт показывает вещь по entry
10 Показывает:
11 - Если часть набора - весь набор
12 - Если рецепт, что можно сделать
13 - Рандом энчанты вещи
14 - Список предметов которые можно обменять на нее
15 - Если заперта, что нужно для открытия
16 - Список предметов/go которые можно открыть предметом
17 - Начинает квест
18 - Лут вещи как с сундука
19 - Лут вещи как с руды
20 - Лут вещи как с растения (milling)
21 - Лут вещи дизэнчантом
22 - Используется в качестве реагента
23 - Создана спеллом
24 - Продавцы вещи
25 - Награда за квест
26 - Нужен для квеста
27 - Высылаемая по почте при завершении квеста
28 - Даётся при взятии квеста
29 - Лут с мобов
30 - Украсть у мобов
31 - Ошкурено с мобов
32 - Лут с обьектов
33 - Лут с очистки руды
34 - Лут с вещей
35 - Лут с дизэнчанта
36 - Лут с рыбалки
39 // Can be pointer ?item=g1000 - so need load and show item by guid
40 // Else load item by entry
41 $str = @$_REQUEST['item'];
42 if (substr($str,0,1) == 'g')
44 $item_data = getItemData(intval(substr($str,1,10)));
45 $entry = $item_data[ITEM_FIELD_ENTRY];
47 else
49 $item_data = 0;
50 $entry = intval($str);
52 $page = intval(@$_REQUEST['page']);
53 $mark = @$_REQUEST['mark'];
54 // Получаем вещь
55 $item = getItem($entry);
57 if (!$item)
59 RenderError("$lang[item_not_found]");
61 else
63 $baseLink = '?item='.$str;
64 if ($ajaxmode==0)
66 if ($lang['www_item'])
67 echo "<a href=\"".sprintf($lang['www_item'], $entry)."\" target=\"_blank\"\">".sprintf($lang['www_item'], $entry)."</a><br>";
68 echo "<table cellspacing=0 cellpadding=0 width=500><tbody><tr>";
69 echo "<td valign=top align=right width=20%>";
70 $icon = getItemIcon($item['displayid']);
71 echo "<br><a id='no_tip' href=\"?item=$entry\"><img height=64 width=64 border=0 src='$icon'></a></td>";
72 echo "<td>";generateItemTable($item,$item_data,0);echo "</td>";
73 echo "</tr></tbody></table>";
75 if ($item['minMoneyLoot']) echo "<b>$lang[Rew_money]</b>&nbsp;".money($item['minMoneyLoot']);
76 if (($item['maxMoneyLoot']) && ($item['maxMoneyLoot']>$item['minMoneyLoot'])) echo "&nbsp;-&nbsp;".money($item['maxMoneyLoot']);
78 if ($item['BuyPrice']) echo '<br>'.$lang['buy_price'].':&nbsp;'.money($item['BuyPrice']);
79 echo "<br />";
81 //********************************************************************************
82 // Если часть набора - выводим весь набор
83 //********************************************************************************
84 if ($item['itemset'])
86 $set = getItemSet($item['itemset']);
87 $setkey = array_keys($set);
88 if ($set)
90 echo "<table class=report width=500 border = 1>";
91 echo "<tbody>";
92 echo '<tr><td class=head>'.$lang['this_item_part_of_set'].'&nbsp;-&nbsp;';r_setName($set); echo '</td></tr>';
93 echo "<tr><td class=set>";r_setItems($set);echo "</td></tr>";
94 echo "<tr><td class=left>";r_setSpells($set);echo "</td></tr>";
96 else
97 echo "<tr><td>Unknown SET = $item[itemset]</td></tr>";
98 echo "</tbody></table>";
101 createReportTab();
102 //********************************************************************************
103 // Если item class -> recipe выводим что можно сделать
104 //********************************************************************************
105 if ($item['spellid_1'] == 483)
107 $recipe = new SpellReportGenerator;
108 $fields = array('SPELL_REPORT_ICON','SPELL_REPORT_RECIPE','SPELL_REPORT_REAGENTS', 'SPELL_REPORT_CREATE');
109 if ($recipe->Init($fields, $baseLink, 'recipeLIST', $config['fade_limit'], ''))
111 $recipe->doRequirest('`id` = ?d', $item['spellid_2']);
112 $recipe->createReport($lang['recipe_for']);
115 //********************************************************************************
116 // Рандом энчанты вещи
117 //********************************************************************************
118 if ($ajaxmode==0 AND ($item['RandomProperty'] OR $item['RandomSuffix']))
120 $randEnch = $item['RandomProperty'] ? $item['RandomProperty']:$item['RandomSuffix'];
121 $rows = $dDB->selectPage($totalRecords, "SELECT * FROM `item_enchantment_template` WHERE `entry` = ?d ORDER BY `chance` DESC", $randEnch);
122 if ($rows)
124 $points = getRandomPropertyPoint($item['ItemLevel'], $item['InventoryType'], $item['Quality']);
125 echo '<div class=reportContainer id=randList>';
126 addTab($lang['random_enchants'].' ('.$totalRecords.')', 'randList');
127 echo "<table class=report width=500>";
128 echo "<tbody>";
129 echo "<tr class=head><td colspan=4>$lang[random_enchants]</td></tr>";
130 echo "<tr><th>$lang[enchant_id]</th><th>$lang[random_enc_name]</th><th>$lang[random_enc_info]</th><th>$lang[random_enc_cnance]</th></tr>";
131 foreach ($rows as $i_ench)
133 echo "<tr>";
134 if ($item['RandomSuffix'])
136 $prop = getRandomSuffix($i_ench['ench']);
137 echo "<td class=small>".$prop['id']."</td>";
138 echo "<td class=left>&nbsp;... ".$prop['name']."</td>";
139 echo "<td class=left>";
140 for ($j=1;$j<=3;$j++)
141 if ($prop['EnchantID_'.$j])
143 $text = getEnchantmentDesc($prop['EnchantID_'.$j]);
144 echo str_ireplace('$i', round($points * $prop['Prefix_'.$j]/10000, 0), $text)."<br>";
146 echo "</td>";
147 echo "<td>$i_ench[chance]%</td>";
148 echo "</tr>";
150 else
152 $prop = getRandomProperty($i_ench['ench']);
153 echo "<td>".$prop['id']."</td>";
154 echo "<td>".$prop['name']."</td>";
155 echo "<td>";
156 for ($j=1;$j<=5;$j++)
157 if ($prop['EnchantID_'.$j])
158 echo getEnchantmentDesc($prop['EnchantID_'.$j])."<br>";
159 echo "</td>";
160 echo "<td align=center>$i_ench[chance]%</td>";
161 echo "</tr>";
164 echo "</tbody></table></div>";
168 //********************************************************************************
169 // Является ценой для других предметов
170 //********************************************************************************
171 $excost = new ExCostReportGenerator();
172 $fields = array('EXCOST_REPORT_ID', 'EXCOST_REPORT_ITEM', 'EXCOST_REPORT_COST');
173 if ($excost->Init($fields, $baseLink, 'excostLIST', $config['fade_limit'], 'cost'))
175 $excost->useItemAsCost($entry);
176 $excost->createReport($lang['item_is_ex_cost']);
178 //********************************************************************************
179 // How can possible open it (lock info)
180 //********************************************************************************
181 if ($item['lockid'])
183 $locked = new LockReportGenerator();
184 $fields = array('LOCK_REPORT_ID', 'LOCK_REPORT_KEY');
185 if ($locked->Init($fields, $baseLink, 'lockLIST', $config['fade_limit'], ''))
187 $locked->doRequirest('`id` = ?d', $item['lockid']);
188 $locked->createReport($lang['locked_item']);
191 //********************************************************************************
192 // This item is key for:
193 //********************************************************************************
194 $locked = new LockReportGenerator();
195 $fields = array('LOCK_REPORT_ID', 'LOCK_REPORT_HAVE');
196 if ($locked->Init($fields, $baseLink, 'lockLIST', $config['fade_limit'], ''))
198 $locked->haveItemAsKey($entry);
199 $locked->createReport($lang['can_unlock']);
201 //********************************************************************************
202 // Give quest list
203 //********************************************************************************
204 if ($item['startquest'])
206 $giveQuest = new QuestReportGenerator('item_giver');
207 $fields = array('QUEST_REPORT_LEVEL', 'QUEST_REPORT_NAME', 'QUEST_REPORT_REWARD');
208 if ($giveQuest->Init($fields, $baseLink, 'qgLIST', $config['fade_limit'], 'name'))
210 $giveQuest->oneQuest($item['startquest']);
211 $giveQuest->createReport($lang['give_quest']);
214 //********************************************************************************
215 // Лут с этой вещи
216 //********************************************************************************
217 if ($ajaxmode==0)
219 // Как с сундука
220 if ($item['Flags'] & ITEM_FLAGS_OPENABLE)
222 $page_seek = init_pagePerMark($mark, "lock_lootLIST", $page);
223 $rows = getLootList($item['entry'], "item_loot_template", $totalRecords, $page_seek, $config['fade_limit']);
224 renderLootTableList($rows, $lang['item_contain_loot'], $page_seek, $totalRecords, $baseLink, "lock_lootLIST");
226 // Как с руды
227 if ($item['Flags'] & ITEM_FLAGS_PROSPECTABLE)
229 $page_seek = init_pagePerMark($mark, "prospect_lootLIST", $page);
230 $rows = getLootList($item['entry'], "prospecting_loot_template", $totalRecords, $page_seek, $config['fade_limit']);
231 renderLootTableList($rows, $lang['contain_prospecting_loot'], $page_seek, $totalRecords, $baseLink, "prospect_lootLIST");
233 // Если растолочь
234 if ($item['Flags'] & ITEM_FLAGS_MILLABLE)
236 $page_seek = init_pagePerMark($mark, "milling_lootLIST", $page);
237 $rows = getLootList($item['entry'], "milling_loot_template", $totalRecords, $page_seek, $config['fade_limit']);
238 renderLootTableList($rows, $lang['contain_milling_loot'], $page_seek, $totalRecords, $baseLink, "milling_lootLIST");
240 // Как дизэнчантом
241 if ($item['DisenchantID'])
243 $page_seek = init_pagePerMark($mark, "disenchant_lootLIST", $page);
244 $rows = getLootList($item['DisenchantID'], "disenchant_loot_template", $totalRecords, $page_seek, $config['fade_limit']);
245 renderLootTableList($rows, $lang['contain_disenchant_loot'], $page_seek, $totalRecords, $baseLink, "disenchant_lootLIST");
248 //********************************************************************************
249 // Используется в качестве реагента
250 //********************************************************************************
251 $reagent_in = new SpellReportGenerator;
252 $fields = array('SPELL_REPORT_ICON','SPELL_REPORT_RECIPE','SPELL_REPORT_REAGENTS', 'SPELL_REPORT_CREATE');
253 if ($reagent_in->Init($fields, $baseLink, 'reagentLIST', $config['fade_limit'], 'icon'))
255 $reagent_in->useRegent($entry);
256 $reagent_in->createReport($lang['item_use_in_spell']);
258 //********************************************************************************
259 // Spell loot
260 //********************************************************************************
261 $created_by = new SpellReportGenerator;
262 $fields = array('SPELL_REPORT_ICON','SPELL_REPORT_RECIPE','SPELL_REPORT_REAGENTS', 'SPELL_REPORT_CREATE');
263 if ($created_by->Init($fields, $baseLink, 'createLIST', $config['fade_limit'], 'name'))
265 $created_by->createItem($entry);
266 $created_by->createReport($lang['create_from_spell']);
268 //********************************************************************************
269 // Создана спеллом
270 //********************************************************************************
271 $spell_loot = new SpellReportGenerator;
272 $fields = array('SPELL_REPORT_ICON','SPELL_REPORT_RECIPE', 'SPELL_REPORT_REAGENTS');
273 if ($spell_loot->Init($fields, $baseLink, 'spelllootLIST', $config['fade_limit'], 'name'))
275 $spell_loot->lootItem($entry);
276 $spell_loot->createReport($lang['loot_from_spell']);
278 //********************************************************************************
279 // Продавцы вещи
280 //********************************************************************************
281 $vendors = new CreatureReportGenerator('vendor');
282 $fields = array('NPC_REPORT_RNAME', 'VENDOR_REPORT_COST', 'VENDOR_REPORT_COUNT', 'VENDOR_REPORT_INCTIME', 'NPC_REPORT_MAP');
283 if ($vendors->Init($fields, $baseLink, 'vendorLIST', $config['fade_limit'], 'name'))
285 $vendors->soldItem($entry, $item['BuyPrice']);
286 $vendors->createReport($lang['npc_sold_loot']);
288 //********************************************************************************
289 // Quest list reward this item
290 //********************************************************************************
291 $qReward = new QuestReportGenerator();
292 $fields = array('QUEST_REPORT_LEVEL', 'QUEST_REPORT_NAME', 'QUEST_REPORT_GIVER', 'QUEST_REPORT_GIVER_END', 'QUEST_REPORT_REWARD');
293 if ($qReward->Init($fields, $baseLink, 'qrewardLIST', $config['fade_limit'], 'name'))
295 $qReward->rewardItem($entry);
296 $qReward->createReport($lang['quest_reward_loot']);
298 //********************************************************************************
299 // Required for quest (except if this item quest)
300 //********************************************************************************
301 $reqForQuest = new QuestReportGenerator();
302 $fields = array('QUEST_REPORT_LEVEL', 'QUEST_REPORT_NAME', 'QUEST_REPORT_GIVER', 'QUEST_REPORT_GIVER_END', 'QUEST_REPORT_REWARD');
303 if ($reqForQuest->Init($fields, $baseLink, 'qreqLIST', $config['fade_limit'], 'name'))
305 $reqForQuest->requireItem($entry, $item['startquest']);
306 $reqForQuest->createReport($lang['quest_req_loot']);
308 //********************************************************************************
309 // Give on quest take (except if this item quest)
310 //********************************************************************************
311 $srcForQuest = new QuestReportGenerator();
312 $fields = array('QUEST_REPORT_LEVEL', 'QUEST_REPORT_NAME', 'QUEST_REPORT_GIVER', 'QUEST_REPORT_GIVER_END', 'QUEST_REPORT_REWARD');
313 if ($srcForQuest->Init($fields, $baseLink, 'qgiveLIST', $config['fade_limit'], 'name'))
315 $srcForQuest->provideItem($entry, $item['startquest']);
316 $srcForQuest->createReport($lang['quest_src_loot']);
318 //********************************************************************************
319 // Quest mail loot
320 //********************************************************************************
321 $fields = array('QUEST_REPORT_LEVEL', 'QUEST_REPORT_NAME', 'QUEST_REPORT_GIVER', 'LOOT_REPORT_REQ', 'LOOT_REPORT_CHANCE');
322 $quest_loot = new QuestReportGenerator('mail_loot');
323 if ($quest_loot->Init($fields, $baseLink, 'qlootLIST', $config['fade_limit'], 'chance'))
325 $quest_loot->lootItem($entry);
326 $quest_loot->createReport($lang['quest_mail_loot']);
328 //********************************************************************************
329 // Лут с мобов
330 //********************************************************************************
331 $loot = new CreatureReportGenerator('loot');
332 $fields = array('NPC_REPORT_LEVEL', 'NPC_REPORT_RNAME', 'LOOT_REPORT_REQ', 'LOOT_REPORT_CHANCE', 'NPC_REPORT_MAP');
333 if ($loot->Init($fields, $baseLink, 'dropLIST', $config['fade_limit'], 'chance'))
335 $loot->lootItem($entry);
336 $loot->createReport($lang['drop_loot']);
338 //********************************************************************************
339 // Украдено у мобов
340 //********************************************************************************
341 $pick = new CreatureReportGenerator('pick');
342 $fields = array('NPC_REPORT_LEVEL', 'NPC_REPORT_RNAME', 'LOOT_REPORT_REQ', 'LOOT_REPORT_CHANCE', 'NPC_REPORT_MAP');
343 if ($pick->Init($fields, $baseLink, 'pickLIST', $config['fade_limit'], 'chance'))
345 $pick->lootItem($entry);
346 $pick->createReport($lang['pickpocketing_loot']);
348 //********************************************************************************
349 // Ошкурено с мобов
350 //********************************************************************************
351 $skin = new CreatureReportGenerator('skin');
352 $fields = array('NPC_REPORT_LEVEL', 'NPC_REPORT_RNAME', 'LOOT_REPORT_REQ', 'LOOT_REPORT_CHANCE', 'NPC_REPORT_MAP');
353 if ($skin->Init($fields, $baseLink, 'skinLIST', $config['fade_limit'], 'chance'))
355 $skin->lootItem($entry);
356 $skin->createReport($lang['skinning_loot']);
358 //************************************************************************************************************************
359 // Лут с обьектов
360 //********************************************************************************
361 $go_loot = new GameobjectReportGenerator('loot');
362 $fields = array('GO_REPORT_NAME', 'GO_REPORT_TYPE', 'LOOT_REPORT_REQ', 'LOOT_REPORT_CHANCE', 'GO_REPORT_MAP');
363 if ($go_loot->Init($fields, $baseLink, 'go_lootLIST', $config['fade_limit'], 'chance'))
365 $go_loot->lootItem($entry);
366 $go_loot->createReport($lang['go_drop_loot']);
368 //********************************************************************************
369 // Лут с вещей
370 //********************************************************************************
371 $item_loot = new ItemReportGenerator('loot');
372 $fields = array('ITEM_REPORT_ICON', 'ITEM_REPORT_NAME', 'LOOT_REPORT_REQ', 'LOOT_REPORT_CHANCE');
373 if ($item_loot->Init($fields, $baseLink, 'lootLIST', $config['fade_limit'], 'chance'))
375 $item_loot->lootItem($entry);
376 $item_loot->createReport($lang['item_lock_loot']);
378 //********************************************************************************
379 // Лут с очистки руды
380 //********************************************************************************
381 $item_loot = new ItemReportGenerator('prospect');
382 if ($item_loot->Init($fields, $baseLink, 'prospectLIST', $config['fade_limit'], 'chance'))
384 $item_loot->lootItem($entry);
385 $item_loot->createReport($lang['prospecting_loot']);
387 //********************************************************************************
388 // Лут с milling
389 //********************************************************************************
390 $milling_loot = new ItemReportGenerator('milling');
391 if ($milling_loot->Init($fields, $baseLink, 'millingLIST', $config['fade_limit'], 'chance'))
393 $milling_loot->lootItem($entry);
394 $milling_loot->createReport($lang['milling_loot']);
396 //********************************************************************************
397 // Лут с дизэнчанта
398 //********************************************************************************
399 $disenchant_loot = new ItemReportGenerator('disenchant');
400 if ($disenchant_loot->Init($fields, $baseLink, 'disenchantLIST', $config['fade_limit'], 'chance'))
402 $disenchant_loot->lootItem($entry);
403 $disenchant_loot->createReport($lang['disenchant_loot']);
406 if ($ajaxmode==0)
408 //********************************************************************************
409 // Лут с рыбалки
410 //********************************************************************************
411 $refLoot = & getRefrenceItemLoot($entry);
412 $refList = array_keys($refLoot); // Получаем список рефренс лута
414 $page_seek = init_pagePerMark($mark, "fishing_src_LIST", $page);
415 $rows = $dDB->selectPage($totalRecords,
416 "SELECT
417 `fishing_loot_template`.`entry` AS `loot_entry`,
418 `fishing_loot_template`.`ChanceOrQuestChance` AS `ChanceOrQuestChance`,
419 `fishing_loot_template`.`groupid` AS `groupid`,
420 `fishing_loot_template`.`mincountOrRef` AS `mincountOrRef`,
421 `fishing_loot_template`.`maxcount` AS `maxcount`,
422 `fishing_loot_template`.`condition_id` AS `condition_id`
423 FROM
424 `fishing_loot_template`
425 WHERE
426 (`fishing_loot_template`.`item` = ?d AND `fishing_loot_template`.`mincountOrRef` > 0)
427 { OR -`fishing_loot_template`.`mincountOrRef` IN (?a) }
428 ORDER BY
429 ABS(`ChanceOrQuestChance`) DESC
430 LIMIT ?d,?d",$item['entry'], empty($refList) ? DBSIMPLE_SKIP : $refList, $page_seek, $config['fade_limit']);
431 renderItemFishingList($rows, $refLoot, $lang['fishing_loot'], $page_seek, $totalRecords, $baseLink, "fishing_src_LIST");
432 } /**/