Browse Source

fix BPC costs

raylu 12 years ago
parent
commit
4072a99b40
4 changed files with 17 additions and 6 deletions
  1. 3 1
      db/queries.py
  2. 4 1
      update_costs.py
  3. 2 2
      web/static/css/kill.ccss
  4. 8 2
      web/static/js/kill.js

+ 3 - 1
db/queries.py

@@ -112,13 +112,15 @@ def kill(kill_id):
 		except db.NoRowsException:
 			victim['ship_cost'] = 0
 
+		# 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
 			FROM items
 			JOIN item_costs ON item_costs.type_id = items.type_id
 			JOIN eve.invTypes ON items.type_id = typeID
-			WHERE kill_id = ? ORDER BY flag ASC
+			WHERE kill_id = ?
+			ORDER BY (cost * (dropped + destroyed) / (singleton * 499.5 + 1)) DESC
 			''', kill_id)
 		items = defaultdict(list)
 		for item in item_rows:

+ 4 - 1
update_costs.py

@@ -49,8 +49,11 @@ def update_kill(kill_id):
 			c.nextset()
 		else:
 			cost = 0
+		# singleton is 0 normally and for BPOs and 2 for BPCs
+		# we want to divide by 1 for BPOs and by 1000 for BPCs
 		c.execute('''
-			SELECT SUM(cost * (dropped + destroyed)) FROM items AS i
+			SELECT SUM(cost * (dropped + destroyed) / (singleton * 499.5 + 1))
+			FROM items AS i
 			JOIN item_costs AS ic ON i.type_id = ic.type_id WHERE kill_id = ?
 			''', (kill_id,))
 		r = c.fetchone()

+ 2 - 2
web/static/css/kill.ccss

@@ -117,9 +117,9 @@ table#items:
 	th:nth-child(1):
 		width: 33px
 	th:nth-child(2):
-		width: 300px
+		width: 285px
 	th:nth-child(3):
-		width: 50px
+		width: 65px
 	th:nth-child(4):
 		width: 117px
 

+ 8 - 2
web/static/js/kill.js

@@ -134,8 +134,14 @@ window.addEvent('domready', function() {
 			}
 			items[slot].each(function(item) {
 				var type_id = item['type_id'];
+				var item_name = item['item_name'];
 				var item_class = item['dropped'] ? 'dropped' : 'destroyed';
 				var count = item[item_class];
+				var cost = item['cost'] * count;
+				if (item['singleton'] == 2) {
+					item_name += ' (copy)';
+					cost /= 1000;
+				}
 				table.grab(new Element('tr').adopt(
 					new Element('td').grab(
 						new Element('img', {
@@ -143,9 +149,9 @@ window.addEvent('domready', function() {
 							'alt': item['item_name'],
 						})
 					),
-					new Element('td', {'html': item['item_name']}),
+					new Element('td', {'html': item_name}),
 					new Element('td', {'html': count, 'class': item_class}),
-					new Element('td', {'html': ykill.format_isk(item['cost'])})
+					new Element('td', {'html': ykill.format_isk(cost)})
 				));
 			});
 		});