Stellarcore.net

Stellarcore.net

The Original bash version of the script written by Steve Frostrom [with a few minor changes by me.]

#!/bin/bash

clear
max_lvl=40
fmt="%5s %9s %11s %11s %9s %9s\n"

printf "$fmt" ""        ""      "Class"     "Cross-Class"   ""      ""
printf "$fmt" "Char"    ""      "Skill"     "Skill"         ""      "Stat"
printf "$fmt" "Level"   "XP"    "Max Ranks" "Max Ranks"     "Feats" "Increases"

# function to format numbers
say () {
    case "$1" in
    0)              echo "--";;
    *1?|*0|*[4-9])  echo "${1}th";;
    *1)             echo "${1}st";;
    *2)             echo "${1}nd";;
    *3)             echo "${1}rd";;
    *)              echo "$*";; # shouldn't happen
    esac
}

    # loop level until max_lvl
for ((level = 1, xp = 0, feats = 1, stats = 0 ; level <= $max_lvl ; level++)) ; do

        # sum xp's
    ((xp = xp + (level - 1) * 1000))

        # calc max skill ranks (and print cc funny)
    ((maxranks = level + 3))
    ((maxcc = maxranks / 2, maxranks % 2)) && maxcc="${maxcc}.5"

        # new feat every 3 levels, but start with 1
    ((s_feats = (level % 3) ? (level == 1 ? 1 : 0) : ++feats))

        # stat bonus every 4 levels
    ((s_stats = (level % 4) ? 0 : ++stats))

        # print it 
    printf "$fmt" $(say $level) $xp $maxranks $maxcc $(say $s_feats) $(say $s_stats)
done