diff options
author | raylu <raylu@gridium.com> | 2013-10-25 02:50:49 -0700 |
---|---|---|
committer | raylu <raylu@gridium.com> | 2013-10-25 02:50:49 -0700 |
commit | add49f431049363efc7fb918cfd4a85bb1ac6873 (patch) | |
tree | a529f565e50a28d57daddcf2eb557ca621d8d055 | |
parent | b2de2ff8f704a0fbbbd25c9b76e14b36107895f0 (diff) | |
download | ykill-add49f431049363efc7fb918cfd4a85bb1ac6873.tar.xz |
-rw-r--r-- | db/queries.py | 17 | ||||
-rw-r--r-- | web/static/js/kill.js | 27 |
2 files changed, 24 insertions, 20 deletions
diff --git a/db/queries.py b/db/queries.py index 435f4dc..45bbe1d 100644 --- a/db/queries.py +++ b/db/queries.py @@ -115,7 +115,7 @@ def kill(kill_id): # see update_costs for an explanation of the ORDER BY item_rows = db.query(c, ''' SELECT items.type_id, flag, dropped, destroyed, singleton, - cost, typeName AS item_name, capacity + cost, typeName AS item_name FROM items JOIN item_costs ON item_costs.type_id = items.type_id JOIN eve.invTypes ON items.type_id = typeID @@ -151,6 +151,21 @@ def kill(kill_id): slot = '???' items[slot].append(item) + module_slots = ['high', 'medium', 'low'] + fitting_items = set() + for slot in module_slots: + fitting_items.update(map(operator.itemgetter('type_id'), items[slot])) + # 11: requires low, 12: requires high, 13: requires medium; :CCP: + modules = db.query(c, ''' + SELECT DISTINCT typeID AS type_id FROM eve.dgmTypeEffects + WHERE typeID IN ({}) and effectID IN (11, 12, 13) + '''.format(','.join(map(str, fitting_items)))) + module_ids = set(map(operator.itemgetter('type_id'), modules)) + for slot in module_slots: + for item in items[slot]: + if item['type_id'] not in module_ids: + item['charge'] = True + slot_rows = db.query(c, ''' SELECT attributeID, valueInt, valueFloat FROM eve.dgmTypeAttributes WHERE typeID = ? AND attributeID IN (12, 13, 14, 1137, 1367) diff --git a/web/static/js/kill.js b/web/static/js/kill.js index c17c948..d04dfbd 100644 --- a/web/static/js/kill.js +++ b/web/static/js/kill.js @@ -65,21 +65,15 @@ window.addEvent('domready', function() { if (!items[slot]) return; + var has_charges = (['high', 'medium', 'low'].indexOf(slot) > -1); items[slot].each(function(item) { - var div = $('slot_' + item['flag']); - var bg_img = div.getStyle('background-image'); - if (bg_img == 'none') - set_item(div, item); - else { - var charge_div = $('charge_' + item['flag']); - if (item['capacity']) { - charge_div.setStyle('background-image', bg_img); - charge_div.grab(div.getChildren()[0]); - set_item(div, item); - } else { - set_item(charge_div, item); - } - } + var div; + if (has_charges && item['charge']) + div = $('charge_' + item['flag']); + else + div = $('slot_' + item['flag']); + div.setStyle('background-image', 'url(//image.eveonline.com/type/' + item['type_id'] + '_32.png)'); + div.grab(new Element('div', {'class': 'tooltip', 'html': item['item_name']})); }); }); @@ -167,11 +161,6 @@ window.addEvent('domready', function() { }); }); - function set_item(div, item) { - div.setStyle('background-image', 'url(//image.eveonline.com/type/' + item['type_id'] + '_32.png)'); - div.grab(new Element('div', {'class': 'tooltip', 'html': item['item_name']})); - } - function show_attacker(table, char) { var tr = new Element('tr'); |