Stellarcore.net

Stellarcore.net

The Java version of the script

// Level Chart 
// 


import java.text.*;

public class levels {

   public static String[] getHeader() {
      String[] header = new String[2];
      header[0] = "Char\t \tClass Skill\tCC Skill\t \tStat\t";
      header[1] = "Level\tXP\tMax Ranks\tMax Ranks\tFeats\tIncreases\t";
      return header;
   }

   public static String level_th(String s_input) {
      String level_th;
      int second_digit = s_input.length();
      if ( second_digit > 1 ) {
         second_digit = second_digit - 2;
      }

      if ( s_input.endsWith("1") ) {
         level_th = s_input + "st";
      } else if ( s_input.endsWith("2") ) {
         level_th = s_input + "nd";
      } else if ( s_input.endsWith("3") ) {
         level_th = s_input + "rd";
      } else {
         level_th = s_input + "th";
      }

      String s_check = s_input.substring(second_digit);
      if ( s_check.equals("11") || s_check.equals("12") || s_check.equals("13") ) {
         level_th = s_input + "th";
      }
      return level_th;
   }

   public static void main(String[] args) {
      // clear screen no idea if this works under windows 
      System.out.print("\033c");
      // My variables
      int Max = 40;
      String[] myheader = getHeader();
      for (int i = 0; i < myheader.length; i++) {
         System.out.println(myheader[i]);
      }

      // Loop for levels
      for (int level = 1, xp = 0, feats = 0, stats = 0; level <= Max; level++) {
         // Calculate XP
         xp = (xp + ( level - 1) * 1000);

         // Calcualte Maxranks
         int maxranks = level + 3;

         // Calcualte Max Cross Class Ranks
         double maxcc = maxranks / 2.0;

         // Calculate Feats
         int s_feats = (level % 3);
         String out_feat = "--";
         if ( s_feats == 0 || level == 1 ) {
            feats++;
	         out_feat = level_th( String.valueOf(feats) );
         }

         // Calculate Stat bouns
         int s_stat = ( level % 4);
         String out_stat = "--";
         if ( s_stat == 0 ) {
            stats++;
	         out_stat = level_th( String.valueOf(stats) );
         }

         // Make level pretty
         String level_out = level_th( String.valueOf(level) );

         //Print
         System.out.println( level_out + "\t" + xp + "\t" + maxranks + "\t\t" + maxcc + "\t\t"
          + out_feat + "\t" + out_stat);
      }

   }

}

// vi: shiftwidth=3 tabstop=3 et