Created
September 17, 2013 02:54
-
-
Save coderanger/6589557 to your computer and use it in GitHub Desktop.
Script to format an Eve skill plan for BBCode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import copy | |
from gettext import ngettext | |
from bs4 import BeautifulSoup | |
attributes = { | |
'intelligence': 20, | |
'perception': 20, | |
'charisma': 19, | |
'willpower': 20, | |
'memory': 20, | |
} | |
skill_tree = BeautifulSoup(open('SkillTree.xml').read(), "xml") | |
skill_groups = skill_tree.eveapi.result.rowset | |
skills = {} | |
for group in skill_groups('row', recursive=False): | |
for skill in group.rowset('row', recursive=False): | |
if skill['published'] != '1': | |
continue | |
skills[skill['typeID']] = { | |
'name': str(skill['typeName']), | |
'id': str(skill['typeID']), | |
'rank': int(skill.rank.string), | |
'primary': str(skill.requiredAttributes.primaryAttribute.string), | |
'secondary': str(skill.requiredAttributes.secondaryAttribute.string), | |
} | |
def skill_time(skill): | |
base_sp = [0, 250, 1415, 8000, 45255, 256000] | |
total_sp = base_sp[skill['level']] * skill['rank'] | |
last_sp = base_sp[skill['level'] - 1] * skill['rank'] | |
remaining_sp = total_sp - last_sp | |
sp_per_min = attributes[skill['primary']] + (attributes[skill['secondary']] / 2) | |
return (remaining_sp / sp_per_min) * 60 | |
plan = BeautifulSoup(open('Plan.xml').read(), "xml") | |
plan_skills = [] | |
total_time = 0 | |
for skill in plan('entry'): | |
plan_skill = copy.deepcopy(skills[skill['skillID']]) | |
plan_skill['level'] = int(skill['level']) | |
plan_skill['time'] = skill_time(plan_skill) | |
total_time += plan_skill['time'] | |
plan_skill['total_time'] = total_time | |
plan_skills.append(plan_skill) | |
def format_time(time): | |
days, time = divmod(time, 60 * 60 * 24) | |
hours, time = divmod(time, 60 * 60) | |
minutes, seconds = divmod(time, 60) | |
parts = [] | |
if days: | |
parts.append(ngettext('%d day', '%d days', days) % days) | |
if hours: | |
parts.append(ngettext('%d hour', '%d hours', hours) % hours) | |
if minutes: | |
parts.append(ngettext('%d minute', '%d minutes', minutes) % minutes) | |
if seconds: | |
parts.append(ngettext('%d second', '%d seconds', seconds) % seconds) | |
return ' '.join(parts) | |
print '[LIST]' | |
for skill in plan_skills: | |
print '[*]{name} {level} [size=2][i]({formatted_time})[/i][/size][/*]'.format(formatted_time=format_time(skill['total_time']), **skill) | |
print '[/LIST]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment