Inventory.useItem = function UseItem( item ) { switch (item.type) { // Usable item case Inventory.ITEM.HEALING: case Inventory.ITEM.USABLE: case Inventory.ITEM.USABLE_UNK: Inventory.onUseItem( item.index ); break; case Inventory.ITEM.USABLE_SKILL: break; // Equip item case Inventory.ITEM.WEAPON: case Inventory.ITEM.EQUIP: case Inventory.ITEM.PETEQUIP: if (item.IsIdentified && !item.IsDamaged) { Inventory.onEquipItem( item.index, item.location ); } break; case Inventory.ITEM.AMMO: break; } return; };
/** * Drop an item in the equipment, equip it if possible */ function onDrop(event) { var item, data; try { data = JSON.parse( event.originalEvent.dataTransfer.getData('Text') ); } catch (e) { } // Just support items for now ? if (data && data.type === 'item') { item = data.data; // Only for TYPE.WEAPON and TYPE.EQUIP if ((item.type === 4 || item.type === 5 || item.type === 10) && item.IsIdentified && !item.IsDamaged) { Equipment.ui.find('td').css('backgroundImage', 'none'); Equipment.onEquipItem(item.index, 'location' in item ? item.location : item.WearState); } } event.stopImmediatePropagation(); return false; }
.on('dblclick', '.item', function(event) { var matches = this.className.match(/(\w+) (\d+)/); var index = parseInt(matches[2], 10); var list; var i, count; for( i = 0, list = Inventory.list, count = list.length; i < count; ++i ) { if( list[i].index === index ) { switch( list[i].type ) { // Usable item case Inventory.ITEM.HEALING: case Inventory.ITEM.USABLE: //case Inventory.ITEM.USABLE_SKILL: case Inventory.ITEM.USABLE_UNK: Inventory.onUseItem( index ); overlay.hide(); break; // Equip item case Inventory.ITEM.WEAPON: case Inventory.ITEM.EQUIP: case Inventory.ITEM.PETEQUIP: if( list[i].IsIdentified && !list[i].IsDamaged ) { Inventory.onEquipItem( index, list[i].location ); overlay.hide(); } break; } break; } } event.stopImmediatePropagation(); return false; });