浏览代码

why do cap booster charges have capacity?

raylu 12 年之前
父节点
当前提交
add49f4310
共有 2 个文件被更改,包括 24 次插入20 次删除
  1. 16 1
      db/queries.py
  2. 8 19
      web/static/js/kill.js

+ 16 - 1
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)

+ 8 - 19
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');