Stellarcore.net

Stellarcore.net

The Pascal version of the script compiled using Free Pascal and verified to run under both Linux and Windows.

program levels;

Uses
   crt;

const
   max_lvl = 40;

var
   level, feats, stats, maxranks, feats_check, stat_check : integer;
   maxcc : real;
   xp : longint;
   level_out, feats_out, stats_out : String[10];

(* level_th foramts numbers into 1st,2nd,3rd.... *)
function level_th ( s_input : String[10] ) : String[10];

var 
   s_check : String[2];
   second_digit : integer;

begin
   (* Setup the exception check *)
   second_digit := Length(s_input);
   if ( second_digit > 1 ) then
      second_digit := second_digit - 1;
   s_check := Copy(s_input, second_digit, 2);

   (* Case *)
   case s_input[Length(s_input)] of
      '1': level_th := s_input + 'st';
      '2': level_th := s_input + 'nd';
      '3': level_th := s_input + 'rd';
      otherwise level_th := s_input + 'th'
   end;
   (* handle expections now *)
   if (s_check = '11') or (s_check = '12') or (s_check = '13') then
      level_th := s_input + 'th';
end;
(* End level_th *)

begin (* Main *)
   (* Column Header *)
   Clrscr;
   writeln ('Char ',' ':10,'Class Skill':15,'CC Skill ':15,' ':10,'Stat     ':12);
   writeln ('Level','XP':10,'Max Ranks':15,'Max Ranks':15,'Feats':10,'Increases':12);

   (*  Data loop *)
   level := 1;
   xp := 0;
   feats := 0;
   stats := 0;

   repeat
      xp := (xp + (level - 1) * 1000);
      maxranks := level + 3;
      maxcc := maxranks / 2.0;

      feats_check := level mod 3;
      feats_out := ('--');
      if (feats_check = 0) or ( level = 1) then
      begin
         feats := feats + 1;
         Str(feats, feats_out);
         feats_out := level_th (feats_out);
      end;

      stat_check := level mod 4;
      stats_out := ('--');
      if (stat_check = 0) then
      begin
         stats := stats + 1;
         Str(stats, stats_out);
         stats_out := level_th (stats_out);
      end;

      Str(level, level_out);
      level_out := level_th (level_out);

      writeln ( level_out:5, xp:10, maxranks:15, maxcc:15:1, feats_out:10, stats_out:12);
      level := level + 1;
   until level > max_lvl;

end. (* Main *)

(*
# vi: shiftwidth=3 tabstop=3 et
*)