Stellarcore.net

Stellarcore.net

The Python version of the script, with it strict spacing Python always looks very clean.

#!/usr/bin/python

import os,string

def level_th(number):
   number_th = str(number)
   if number == 11 or number == 12 or number == 13:
      number_th = number_th + "th"
   elif number_th[-1] == "1":
      number_th = number_th + "st"
   elif number_th[-1] == "2":
      number_th = number_th + "nd"
   elif number_th[-1] == "3":
      number_th = number_th + "rd"
   else:
      number_th = number_th + "th"

   return number_th

#Globals
max_lvl = 40
xp = 0
feats = 0
stats = 0

#Main
os.system('clear') 
#Windows or DOS use
#os.system('cls') 

#Headers
print "Char \t \tClass Skill\tCC Skill\t \tStat\t"
print "Level\tXP\tMax Ranks\tMax Ranks\tFeats\tIncreases\t"

for i in range(1, max_lvl + 1):
   xp = (xp + (i - 1) * 1000) 
   maxranks = i + 3
   maxcc = maxranks / 2.0

   feat_check = i % 3
   feats_out = "--"
   if feat_check == 0 or i == 1:
      feats = feats + 1
      feats_out = level_th(feats)

   stat_check = i % 4
   stats_out = "--"
   if stat_check == 0:
      stats = stats + 1
      stats_out = level_th(stats)

   level_out = level_th(i)

   print " %s\t%d\t%d\t\t%g\t\t%s\t%s\t" % (level_out, xp, maxranks, maxcc, feats_out, stats_out)

# vi: shiftwidth=3 tabstop=3 et