summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db/queries.py35
-rwxr-xr-ximporter.py19
-rw-r--r--web/static/css/kill.ccss42
-rw-r--r--web/static/js/corporation.js6
-rw-r--r--web/static/js/kill.js70
-rw-r--r--web/templates/kill.html45
6 files changed, 167 insertions, 50 deletions
diff --git a/db/queries.py b/db/queries.py
index 6984f26..df64526 100644
--- a/db/queries.py
+++ b/db/queries.py
@@ -78,12 +78,12 @@ def kill(kill_id):
item_rows = db.query(c, '''
SELECT type_id, flag, dropped, destroyed, singleton,
- typeName AS item_name
+ typeName AS item_name, capacity
FROM items
JOIN eve.invTypes ON type_id = typeID
WHERE kill_id = ? ORDER BY flag ASC
''', kill_id)
- items = {}
+ items = defaultdict(list)
for item in item_rows:
flag = item['flag']
if 125 <= flag <= 132:
@@ -106,21 +106,32 @@ def kill(kill_id):
slot = 'implant'
else:
slot = '???'
+ items[slot].append(item)
- if slot not in items:
- items[slot] = {'dropped': {}, 'destroyed': {}}
- if item['dropped']:
- d = 'dropped'
- else:
- d = 'destroyed'
- item_key = '{},{}'.format(item['type_id'], item['singleton'])
- if item_key not in items[slot][d]:
- items[slot][d][item_key] = [0, item['item_name']]
- items[slot][d][item_key][0] += item[d]
+ slot_rows = db.query(c, '''
+ SELECT attributeID, valueFloat FROM eve.dgmTypeAttributes
+ WHERE typeID = ? AND attributeID in (12, 13, 14, 1137, 1367) and valueFloat != 0.0
+ ''', victim['ship_type_id'])
+ slot_mapping = {12: 'low', 13: 'medium', 14: 'high', 1137: 'rig', 1367: 'subsystem'}
+ slots = dict.fromkeys(slot_mapping.values(), 0)
+ for attr in slot_rows:
+ slot = slot_mapping[attr['attributeID']]
+ slots[slot] = int(attr['valueFloat']) # wtf CCP
+ if slots['subsystem']:
+ sub_ids = map(lambda s: str(s['type_id']), items['subsystem'])
+ modifier_rows = db.query(c, '''
+ SELECT attributeID, valueFloat FROM eve.dgmTypeAttributes
+ WHERE typeID IN ({}) AND attributeID in (1374, 1375, 1376) and valueFloat != 0.0
+ '''.format(','.join(sub_ids)))
+ slot_mapping = {1374: 'high', 1375: 'medium', 1376: 'low'} # that's right, it's backwards for subs!
+ for modifier in modifier_rows:
+ slot = slot_mapping[modifier['attributeID']]
+ slots[slot] += int(modifier['valueFloat']) # you may be wondering why i'm still not using valueInt. i am too
return {
'kill': kill,
'victim': victim,
'final_blow': final_blow,
'attackers': attackers,
'items': items,
+ 'slots': slots,
}
diff --git a/importer.py b/importer.py
index 6b87401..e318467 100755
--- a/importer.py
+++ b/importer.py
@@ -10,7 +10,6 @@ import oursql
import db
def insert_kill(c, kill):
- print('inserting', kill['killID'], end=' ')
try:
db.execute(c, 'INSERT INTO kills (kill_id, solar_system_id, kill_time, moon_id) VALUES(?, ?, ?, ?)',
kill['killID'], kill['solarSystemID'], kill['killTime'], kill['moonID'])
@@ -52,15 +51,13 @@ def insert_kill(c, kill):
''', parambatch
)
- print('done')
-
def main():
- conn = HTTPSConnection('zkillboard.com', timeout=10)
with db.cursor() as c:
groups = db.query(c, 'SELECT groupID FROM eve.invGroups WHERE categoryID = ?', 6)
groups = list(map(operator.itemgetter('groupID'), groups))
for i in range(0, len(groups), 10):
query_groups = list(map(str, groups[i:i+10]))
+ conn = HTTPSConnection('zkillboard.com', timeout=10)
last_kill_id = None
last_request_time = 0
while True:
@@ -71,11 +68,15 @@ def main():
if now - last_request_time < 10:
print('sleeping', 10 - (now - last_request_time))
time.sleep(10 - (now - last_request_time))
- conn.request('GET', path)
- response = conn.getresponse()
- if response.status != 200:
- raise Exception('got {} {} from zkb'.format(response.status, response.reason))
- kills = json.loads(response.read().decode('utf-8'))
+ try:
+ conn.request('GET', path)
+ response = conn.getresponse()
+ if response.status != 200:
+ raise Exception('got {} {} from zkb'.format(response.status, response.reason))
+ kills = json.loads(response.read().decode('utf-8'))
+ except Exception as e:
+ print(repr(e))
+ break
response.close()
print('inserting', len(kills), 'kills')
for kill in kills:
diff --git a/web/static/css/kill.ccss b/web/static/css/kill.ccss
index 2ea2e38..6fada2f 100644
--- a/web/static/css/kill.ccss
+++ b/web/static/css/kill.ccss
@@ -1,7 +1,45 @@
+#wrapper:
+ padding: 20px
+
#ship:
float: left
- width: 256px
- height: 256px
+ width: 356px // 256 + 32 * 2 + 32 (last 32 is for medium charges)
+ height: 320px
+ line-height: 0
+ background-position: 32px 32px
+ background-repeat: no-repeat
+
+ #high:
+ margin-left: 32px
+ #high_charges:
+ display: inline-block;
+ margin-left: 32px
+ #medium:
+ width: 32px
+ float: right
+ #medium_charges:
+ width: 32px
+ float: right
+ #rig:
+ width: 32px
+ float: left
+ margin-top: 48px
+ #subsystem:
+ width: 32px
+ float: left
+ margin-top: 16px
+ #low:
+ margin-left: 32px
+ #low_charges:
+ display: inline-block
+ margin: 16px 0 0 32px
+
+ .slot:
+ display: inline-block
+ width: 32px
+ height: 32px
+ .avail:
+ border: 1px solid #888
table#victim:
float: right
diff --git a/web/static/js/corporation.js b/web/static/js/corporation.js
index 5900477..e0573f3 100644
--- a/web/static/js/corporation.js
+++ b/web/static/js/corporation.js
@@ -26,9 +26,6 @@ window.addEvent('domready', function() {
ykill.portrait(victim['ship_type_id'], victim['ship_name'], 'type', '_32.png'),
ykill.portrait(victim['character_id'], victim['character_name'], 'character', '_32.jpg')
);
- if (victim['faction_id']) {
- td.grab(ykill.portrait(victim['faction_id'], victim['faction_name'], 'faction', '_32.png'));
- }
tr.grab(td);
td = new Element('td');
@@ -47,9 +44,6 @@ window.addEvent('domready', function() {
ykill.portrait(final_blow['ship_type_id'], final_blow['ship_name'], 'type', '_32.png'),
ykill.portrait(final_blow['character_id'], final_blow['character_name'], 'character', '_32.jpg')
);
- if (final_blow['faction_id']) {
- td.grab(ykill.portrait(final_blow['faction_id'], final_blow['faction_name'], 'faction', '_32.png'));
- }
tr.grab(td);
td = new Element('td');
diff --git a/web/static/js/kill.js b/web/static/js/kill.js
index 8fe142a..18ad6ab 100644
--- a/web/static/js/kill.js
+++ b/web/static/js/kill.js
@@ -36,7 +36,7 @@ window.addEvent('domready', function() {
if (victim['faction_id'])
table.grab(new Element('tr').adopt(
new Element('td').grab(
- ykill.portrait(victim['faction_id'], victim['faction_name'], 'faction', '_64.png')
+ ykill.portrait(victim['faction_id'], victim['faction_name'], 'alliance', '_64.png')
),
new Element('td', {'html': victim['faction_name']})
));
@@ -47,8 +47,30 @@ window.addEvent('domready', function() {
new Element('td', {'html': victim['ship_name']})
));
+ var items = data['items'];
var div = $('ship');
div.setStyle('background-image', 'url(//image.eveonline.com/render/' + victim['ship_type_id'] + '_256.png)');
+ Object.each(data['slots'], function(num, slot) {
+ var divs = $(slot).getChildren();
+ for (var i = 0; i < num; i++)
+ divs[i].addClass('avail');
+
+ items[slot].each(function(item) {
+ var div = $('slot_' + item['flag']);
+ var bg_img = div.getStyle('background-image');
+ if (bg_img == 'none')
+ set_bg_item(div, item['type_id']);
+ else {
+ var charge_div = $('charge_' + item['flag']);
+ if (item['capacity']) {
+ set_bg_item(div, item['type_id']);
+ charge_div.setStyle('background-image', bg_img);
+ } else {
+ set_bg_item(charge_div, item['type_id']);
+ }
+ }
+ });
+ });
table = $('attackers');
show_attacker(table, data['final_blow']);
@@ -57,7 +79,6 @@ window.addEvent('domready', function() {
});
table = $('items');
- var items = data['items'];
var slots = ['subsystem', 'high', 'medium', 'low', 'rig', 'drone bay', 'cargo', 'special hold', 'implant', '???'];
slots.each(function(slot) {
if (!items[slot])
@@ -65,27 +86,36 @@ window.addEvent('domready', function() {
table.grab(new Element('tr').grab(
new Element('td', {'html': slot, 'colspan': 3, 'class': 'slot'})
));
- var slot_items = items[slot];
- ['dropped', 'destroyed'].each(function(item_class) {
- Object.each(slot_items[item_class], function(item, item_ids) {
- var type_id = item_ids.split(',', 2)[0]
- var item_name = item[1];
- var count = item[0];
- table.grab(new Element('tr').adopt(
- new Element('td').grab(
- new Element('img', {
- 'src': '//image.eveonline.com/Type/' + type_id + '_32.png',
- 'alt': item_name,
- })
- ),
- new Element('td', {'html': item_name}),
- new Element('td', {'html': count, 'class': item_class})
- ));
- });
+ items[slot].each(function(item) {
+ var type_id = item['type_id'];
+ if (type_id instanceof String)
+ type_id = type_id.split(',', 2)[0];
+ var count, item_class;
+ if (item['dropped']) {
+ count = item['dropped'];
+ item_class = 'dropped';
+ } else {
+ count = item['destroyed'];
+ item_class = 'destroyed';
+ }
+ table.grab(new Element('tr').adopt(
+ new Element('td').grab(
+ new Element('img', {
+ 'src': '//image.eveonline.com/Type/' + type_id + '_32.png',
+ 'alt': item['item_name'],
+ })
+ ),
+ new Element('td', {'html': item['item_name']}),
+ new Element('td', {'html': count, 'class': item_class})
+ ));
});
});
});
+ function set_bg_item(div, type_id) {
+ div.setStyle('background-image', 'url(//image.eveonline.com/type/' + type_id + '_32.png)');
+ }
+
function show_attacker(table, char) {
var tr = new Element('tr');
@@ -96,7 +126,7 @@ window.addEvent('domready', function() {
if (char['alliance_id'])
td.grab(ykill.portrait(char['alliance_id'], char['alliance_name'], 'alliance', '_32.png'));
if (char['faction_id'])
- td.grab(ykill.portrait(char['faction_id'], char['faction_name'], 'faction', '_32.png'));
+ td.grab(ykill.portrait(char['faction_id'], char['faction_name'], 'alliance', '_32.png'));
tr.grab(td);
td = new Element('td');
diff --git a/web/templates/kill.html b/web/templates/kill.html
index 6a22ba1..48abdaa 100644
--- a/web/templates/kill.html
+++ b/web/templates/kill.html
@@ -10,7 +10,48 @@
{% block main %}
-<div id="ship"></div>
+<div id="ship">
+ <div id="high">
+ {% for i in range(27, 35) %}
+ <div id="slot_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="high_charges">
+ {% for i in range(27, 35) %}
+ <div id="charge_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="medium_charges">
+ {% for i in range(19, 27) %}
+ <div id="charge_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="medium">
+ {% for i in range(19, 27) %}
+ <div id="slot_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="rig">
+ {% for i in range(92, 95) %}
+ <div id="slot_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="subsystem">
+ {% for i in range(125, 130) %}
+ <div id="slot_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="low_charges">
+ {% for i in range(11, 19) %}
+ <div id="charge_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+ <div id="low">
+ {% for i in range(11, 19) %}
+ <div id="slot_{{ i }}" class="slot"></div>
+ {% end %}
+ </div>
+</div>
<table id="victim"></table>
<div class="clear"></div>
@@ -18,4 +59,6 @@
<table id="items"></table>
+<div class="clear"></div>
+
{% end %}