Skip to content

Instantly share code, notes, and snippets.

@MarkLodato
Last active January 26, 2016 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkLodato/5aeed5ae1f832f664655 to your computer and use it in GitHub Desktop.
Save MarkLodato/5aeed5ae1f832f664655 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# Parse a crawl morgue file and print a pretty skill progression table.
# USAGE: python skill_graph.py < ./crawl/morgue/<filename>.txt
# Works best with 'note_all_skill_levels = true' in ~/.crawlrc.
#
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import collections
import fileinput
import re
# skills[name][xl] = max_skill_level
skills = collections.OrderedDict()
xl = 0
for line in fileinput.input():
m = re.search(r'Reached XP level ([0-9]+)', line)
if m:
xl = int(m.group(1))
continue
m = re.search(r'Reached skill level ([0-9]+) in (.*)', line)
if m:
level = int(m.group(1))
skill = m.group(2)
skills.setdefault(skill, {})[xl] = level
print 'Skill XL: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27'
print '----------------+---------------------------------------------------------------------------------'
for skill, values in skills.iteritems():
line = ' '.join(format(values.get(xl, ''), '2') for xl in range(1,28))
print '{:15} | {}'.format(skill[:15], line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment