diff --git a/command_line/cardlevelcalc.py b/command_line/cardlevelcalc.py index 274a728..0b716f8 100755 --- a/command_line/cardlevelcalc.py +++ b/command_line/cardlevelcalc.py @@ -87,10 +87,10 @@ def calc_exp_for_level(rarity, starting_level, starting_exp, desired_level): # subtract what we already have required_exp = required_exp - starting_exp # now tell the user - print "To get a %s card from level %d (with %d EXP) to %d requires %d EXP." % (rarity, starting_level, starting_exp, desired_level, required_exp) + print("To get a %s card from level %d (with %d EXP) to %d requires %d EXP." % (rarity, starting_level, starting_exp, desired_level, required_exp)) # calculate equivalent N cards (round up because we can't feed half of a card) number_of_n_cards = (required_exp // 100) + 1 - print "(the equivalent of about %d level-1 N cards fed to it)" % number_of_n_cards + print("(the equivalent of about %d level-1 N cards fed to it)" % number_of_n_cards) def calc_level_for_exp(rarity, starting_level, starting_exp, level_for_exp): current_exp = starting_exp @@ -121,25 +121,25 @@ def calc_level_for_exp(rarity, starting_level, starting_exp, level_for_exp): max_level_string = " (MAX LEVEL!)" else: max_level_string = "" - print "If you feed a %s card at level %d (with %d EXP) a total of %d EXP,\nit will end up at level %d.%s" % (rarity, starting_level, starting_exp, level_for_exp, level, max_level_string) + print("If you feed a %s card at level %d (with %d EXP) a total of %d EXP,\nit will end up at level %d.%s" % (rarity, starting_level, starting_exp, level_for_exp, level, max_level_string)) else: - print "Feeding %d EXP to a level %d %s card (with %d EXP) is not sufficient to\nlevel it up." % (level_for_exp, starting_level, rarity, starting_exp) + print("Feeding %d EXP to a level %d %s card (with %d EXP) is not sufficient to\nlevel it up." % (level_for_exp, starting_level, rarity, starting_exp)) def usage(): - print "Usage: %s [options]" % os.path.basename(__file__) - print "where [options] can be one or more of:" - print "[-H | --help] Print this help message" - print "[-r | --rarity] Card's rarity (REQUIRED, must be one of: N, R, SR, UR)" - print "[-l | --starting-level] Card's starting level (REQUIRED)" - print "[-e | --starting-exp] Card's starting EXP (optional, defaults to 0)" - print "" - print "Plus one of the following:" - print "" - print "TO CALCULATE AMOUNT OF EXP NEEDED TO GET TO A LEVEL:" - print "[-L | --desired-level] Card's desired level" - print "" - print "TO CALCULATE WHAT LEVEL A GIVEN AMOUNT OF XP WILL GET YOU TO:" - print "[-x | --level-for-exp] Calculate level that card will be at given EXP" + print("Usage: %s [options]" % os.path.basename(__file__)) + print("where [options] can be one or more of:") + print("[-H | --help] Print this help message") + print("[-r | --rarity] Card's rarity (REQUIRED, must be one of: N, R, SR, UR)") + print("[-l | --starting-level] Card's starting level (REQUIRED)") + print("[-e | --starting-exp] Card's starting EXP (optional, defaults to 0)") + print("") + print("Plus one of the following:") + print("") + print("TO CALCULATE AMOUNT OF EXP NEEDED TO GET TO A LEVEL:") + print("[-L | --desired-level] Card's desired level") + print("") + print("TO CALCULATE WHAT LEVEL A GIVEN AMOUNT OF XP WILL GET YOU TO:") + print("[-x | --level-for-exp] Calculate level that card will be at given EXP") def main(argv): rarity = None @@ -169,49 +169,49 @@ def main(argv): # first validate rarity if rarity is None: - print "Error: must specify rarity" + print("Error: must specify rarity") usage() sys.exit(1) else: # canonicalize it to uppercase rarity = rarity.upper() if rarity != "N" and rarity != "R" and rarity != "SR" and rarity != "UR": - print "Error: invalid rarity specified (%s)" % rarity + print("Error: invalid rarity specified (%s)" % rarity) usage() sys.exit(1) # now validate starting level if starting_level is None: - print "Error: must specify starting level" + print("Error: must specify starting level") usage() sys.exit(1) elif not check_level_cap(rarity, starting_level): - print "Error: invalid starting level: %d" % starting_level + print("Error: invalid starting level: %d" % starting_level) usage() sys.exit(1) # now validate starting level if desired_level is None and level_for_exp is None: - print "Error: you must choose one of -L or -x." + print("Error: you must choose one of -L or -x.") usage() sys.exit(1) # determine mode if desired_level is not None: if not check_level_cap(rarity, desired_level): - print "Error: invalid desired level: %d" % desired_level + print("Error: invalid desired level: %d" % desired_level) usage() sys.exit(1) # now do start+desired levels make sense? if desired_level <= starting_level: - print "Error: desired level must be greater than starting level" + print("Error: desired level must be greater than starting level") usage() sys.exit(1) # finally check to see if exp makes sense (can't be >= the number of exp for the next level) if not check_valid_exp(rarity, desired_level, starting_exp): - print "Error: invalid EXP (%d)" % starting_exp + print("Error: invalid EXP (%d)" % starting_exp) usage() sys.exit(1) @@ -223,4 +223,4 @@ def main(argv): ### main script starts here if __name__ == "__main__": - main(sys.argv[1:]) \ No newline at end of file + main(sys.argv[1:]) diff --git a/command_line/eventcalc.py b/command_line/eventcalc.py index 3faf73e..dc46cde 100755 --- a/command_line/eventcalc.py +++ b/command_line/eventcalc.py @@ -42,7 +42,7 @@ def center(string): global height string_length = len(string) horizontal_space = (width // 2) - (string_length // 2) - print "%s%s" % ((" " * horizontal_space), string) + print("%s%s" % ((" " * horizontal_space), string)) # NOTE: OS DEPENDENT SECTION - this basically returns a tuple containing the screen's size # (width,height). This code will work on Mac OS X systems and probably Linux as well, but @@ -94,7 +94,7 @@ def calc(year, month, day, hour, minute, fullscreen = False): absolutely_unused_variable = os.system("clear") number_of_blank_lines = (height // 2) - (8 // 2) + 1 for x in range(1, number_of_blank_lines): - print "" + print("") center("CURRENT TIME") center(today.strftime("%Y-%m-%d %H:%M:%S UTC")) print("") @@ -109,18 +109,18 @@ def calc(year, month, day, hour, minute, fullscreen = False): skip_lines = number_of_blank_lines if today_minute == 35: skip_lines = skip_lines - 3 - print "" + print("") center("Check @sifen_trackbot for a tier update:") center("https://twitter.com/sifen_trackbot") if hours > 0 and hours < 6: skip_lines = skip_lines - 2 - print "" + print("") center("*** THE RUSH IS ON!!! ***") if today_hour == 0 and today_minute == 0: skip_lines = skip_lines - 2 - print "" + print("") if today_seconds % 2 == 0: - print "" + print("") else: # NOTE: OS DEPENDENT SECTION - this commands plays an alert sound on Mac OS X machines. # You will need to change it to a different command that plays a sound on Linux or Windows machines. @@ -128,28 +128,28 @@ def calc(year, month, day, hour, minute, fullscreen = False): absolutely_unused_variable = os.system("afplay /System/Library/Sounds/Glass.aiff 2>/dev/null &") center("*** Be sure and claim your daily Login Gift ***") for x in range(1, skip_lines): - print "" + print("") else: - print " Current time: %s" % today.strftime("%Y-%m-%d %H:%M:%S UTC") - print " Event ends: %04d-%02d-%02d %02d:%02d:%02d UTC" % (year, month, day, hour, minute, 0) + print(" Current time: %s" % today.strftime("%Y-%m-%d %H:%M:%S UTC")) + print(" Event ends: %04d-%02d-%02d %02d:%02d:%02d UTC" % (year, month, day, hour, minute, 0)) if s <= 0: - print "Time remaining: *** EVENT HAS ENDED ***" + print("Time remaining: *** EVENT HAS ENDED ***") else: - print "Time remaining: %d:%02d:%02d (%dd%dh%dm)" % (hours, minutes, seconds, days, days_hours, days_minutes) + print("Time remaining: %d:%02d:%02d (%dd%dh%dm)" % (hours, minutes, seconds, days, days_hours, days_minutes)) if hours < 6: - print "*** THE RUSH IS ON!!! ***" + print("*** THE RUSH IS ON!!! ***") def usage(): - print "Usage: %s [options]" % os.path.basename(__file__) - print "where [options] can be one or more of:" - print " [-H | --help] Print this help message" - print " [-y | --year] Event year (optional, defaults to current year)" - print " [-M | --month] Event month (optional, defaults to current month)" - print " [-d | --day] Event day (REQUIRED)" - print " [-h | --hour] Event hour (REQUIRED)" - print " [-m | --minute] Event minute (optional, defaults to 0)" - print " [-c | --continuous] Continuously updating display (defaults to off)" - print "Note: event time should be specified in UTC." + print("Usage: %s [options]" % os.path.basename(__file__)) + print("where [options] can be one or more of:") + print(" [-H | --help] Print this help message") + print(" [-y | --year] Event year (optional, defaults to current year)") + print(" [-M | --month] Event month (optional, defaults to current month)") + print(" [-d | --day] Event day (REQUIRED)") + print(" [-h | --hour] Event hour (REQUIRED)") + print(" [-m | --minute] Event minute (optional, defaults to 0)") + print(" [-c | --continuous] Continuously updating display (defaults to off)") + print("Note: event time should be specified in UTC.") def main(argv): global scr @@ -187,11 +187,11 @@ def main(argv): continuous_mode = True if day is None: - print "Error: must specify day" + print("Error: must specify day") usage() sys.exit(1) elif hour is None: - print "Error: must specify hour" + print("Error: must specify hour") usage() sys.exit(1) else: @@ -210,4 +210,4 @@ def main(argv): ### main script starts here if __name__ == "__main__": - main(sys.argv[1:]) \ No newline at end of file + main(sys.argv[1:]) diff --git a/command_line/gemcalc.py b/command_line/gemcalc.py index 06fc119..9a238da 100755 --- a/command_line/gemcalc.py +++ b/command_line/gemcalc.py @@ -80,8 +80,8 @@ def validate(date_text): def calc_gems_on_date(current_gems, target_date, verbose=False): now = datetime.datetime.now() target_datetime = datetime.datetime.strptime(target_date, '%m/%d/%Y') - print "Today is %02d/%02d/%04d and you currently have %d love gems." % (now.month, now.day, now.year, current_gems) - print "(Assuming you collected any gems you got today and already counted those.)" + print("Today is %02d/%02d/%04d and you currently have %d love gems." % (now.month, now.day, now.year, current_gems)) + print("(Assuming you collected any gems you got today and already counted those.)") gems = current_gems now = now + timedelta(days=1) while now < target_datetime: @@ -92,18 +92,18 @@ def calc_gems_on_date(current_gems, target_date, verbose=False): gems = gems + 5 if verbose: if is_gem_day(now.day) and is_bday: - print "%02d/%02d/%04d: free gem as login bonus AND it's %s's birthday! You get 6 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems) + print("%02d/%02d/%04d: free gem as login bonus AND it's %s's birthday! You get 6 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems)) elif is_gem_day(now.day): - print "%02d/%02d/%04d: free gem as login bonus, which brings you to %d gems." % (now.month, now.day, now.year, gems) + print("%02d/%02d/%04d: free gem as login bonus, which brings you to %d gems." % (now.month, now.day, now.year, gems)) elif is_bday: - print "%02d/%02d/%04d: it's %s's birthday! You get 5 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems) + print("%02d/%02d/%04d: it's %s's birthday! You get 5 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems)) now = now + timedelta(days=1) - print "You will have %d love gems on %02d/%02d/%04d. Good things come to those who wait!" % (gems, target_datetime.month, target_datetime.day, target_datetime.year) + print("You will have %d love gems on %02d/%02d/%04d. Good things come to those who wait!" % (gems, target_datetime.month, target_datetime.day, target_datetime.year)) def calc_desired_gems(current_gems, desired_gems, verbose=False): now = datetime.datetime.now() - print "Today is %02d/%02d/%04d and you currently have %d love gems." % (now.month, now.day, now.year, current_gems) - print "(Assuming you collected any gems you got today and already counted those.)" + print("Today is %02d/%02d/%04d and you currently have %d love gems." % (now.month, now.day, now.year, current_gems)) + print("(Assuming you collected any gems you got today and already counted those.)") gems = current_gems while gems < desired_gems: now = now + timedelta(days=1) @@ -114,27 +114,27 @@ def calc_desired_gems(current_gems, desired_gems, verbose=False): gems = gems + 5 if verbose: if is_gem_day(now.day) and is_bday: - print "%02d/%02d/%04d: free gem as login bonus AND it's %s's birthday! You get 6 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems) + print("%02d/%02d/%04d: free gem as login bonus AND it's %s's birthday! You get 6 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems)) elif is_gem_day(now.day): - print "%02d/%02d/%04d: free gem as login bonus, which brings you to %d gems." % (now.month, now.day, now.year, gems) + print("%02d/%02d/%04d: free gem as login bonus, which brings you to %d gems." % (now.month, now.day, now.year, gems)) elif is_bday: - print "%02d/%02d/%04d: it's %s's birthday! You get 5 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems) - print "You will have %d love gems on %02d/%02d/%04d. Good things come to those who wait!" % (gems, now.month, now.day, now.year) + print("%02d/%02d/%04d: it's %s's birthday! You get 5 gems, which brings you to %d gems." % (now.month, now.day, now.year, name, gems)) + print("You will have %d love gems on %02d/%02d/%04d. Good things come to those who wait!" % (gems, now.month, now.day, now.year)) def usage(): - print "Usage: %s [options]" % os.path.basename(__file__) - print "where [options] can be one or more of:" - print "[-H | --help] Print this help message" - print "[-g | --current-gems] Current number of love gems (optional, default=0)" - print "[-v | --verbose] Verbosely print out when gems are collected" - print "" - print "Plus one of the following:" - print "" - print "TO CALCULATE NUMBER OF LOVE GEMS YOU'LL HAVE ON A GIVEN DATE:" - print "[-d | --date] Date to calculate gem count for (MM/DD/YYYY)" - print "" - print "TO CALCULATE HOW LONG UNTIL YOU WILL GET A CERTAIN NUMBER OF GEMS:" - print "[-G | --desired-gems] Calculate date when you will have that number of gems" + print("Usage: %s [options]" % os.path.basename(__file__)) + print("where [options] can be one or more of:") + print("[-H | --help] Print this help message") + print("[-g | --current-gems] Current number of love gems (optional, default=0)") + print("[-v | --verbose] Verbosely print out when gems are collected") + print("") + print("Plus one of the following:") + print("") + print("TO CALCULATE NUMBER OF LOVE GEMS YOU'LL HAVE ON A GIVEN DATE:") + print("[-d | --date] Date to calculate gem count for (MM/DD/YYYY)") + print("") + print("TO CALCULATE HOW LONG UNTIL YOU WILL GET A CERTAIN NUMBER OF GEMS:") + print("[-G | --desired-gems] Calculate date when you will have that number of gems") def main(argv): current_gems = 0 @@ -166,17 +166,17 @@ def main(argv): calc_gems_on_date(current_gems, target_date, verbose) elif desired_gems is not None: if desired_gems <= current_gems: - print "Error: desired gems must be greater than current gems" + print("Error: desired gems must be greater than current gems") usage() sys.exit(0) else: calc_desired_gems(current_gems, desired_gems, verbose) else: - print "Error: must specify either -d or -G." + print("Error: must specify either -d or -G.") usage() sys.exit(2) ### main script starts here if __name__ == "__main__": - main(sys.argv[1:]) \ No newline at end of file + main(sys.argv[1:]) diff --git a/command_line/rankcalc.py b/command_line/rankcalc.py index e31b367..e2ad045 100755 --- a/command_line/rankcalc.py +++ b/command_line/rankcalc.py @@ -41,29 +41,29 @@ def calc(game_version, starting_rank, starting_exp, desired_rank): required_exp = required_exp + required_exp_for_next_rank # account for exp we already have required_exp = required_exp - starting_exp - print "To get from rank %d (with %d EXP) to rank %d on %s requires %d EXP." % (starting_rank, starting_exp, desired_rank, game_version, required_exp) - print "Equivalent to playing the following number of songs of difficulty level:" + print("To get from rank %d (with %d EXP) to rank %d on %s requires %d EXP." % (starting_rank, starting_exp, desired_rank, game_version, required_exp)) + print("Equivalent to playing the following number of songs of difficulty level:") # round up because you can't play half of a song (although you can play a song half-assedly :P and I often do :P) easy_count = (required_exp // 12) + 1 normal_count = (required_exp // 26) + 1 hard_count = (required_exp // 46) + 1 ex_count = (required_exp // 83) + 1 - print "EASY (%d) NORMAL (%d) HARD (%d) EXPERT (%d)" % (easy_count, normal_count, hard_count, ex_count) + print("EASY (%d) NORMAL (%d) HARD (%d) EXPERT (%d)" % (easy_count, normal_count, hard_count, ex_count)) # calc LP LP = 25 + floor(min(desired_rank, 300) / 2) + floor(max(desired_rank - 300, 0) / 3) # calc friend slots friend_slots = 10 + floor(min(desired_rank, 50) / 5) + floor(max(desired_rank - 50, 0) / 10) # print the results - print "At rank %d you will have %d LP and %d friend slots." % (desired_rank, LP, friend_slots) + print("At rank %d you will have %d LP and %d friend slots." % (desired_rank, LP, friend_slots)) def usage(): - print "Usage: %s [options]" % os.path.basename(__file__) - print "where [options] can be one or more of:" - print "[-H | --help] Print this help message" - print "[-g | --game-version] Game version (one of: EN, JP, default EN)" - print "[-r | --starting-rank] Starting rank (REQUIRED, must be >= 34)" - print "[-e | --starting-exp] Starting EXP (optional, defaults to 0)" - print "[-R | --desired-rank] Desired rank (REQUIRED, must be >= starting-rank)" + print("Usage: %s [options]" % os.path.basename(__file__)) + print("where [options] can be one or more of:") + print("[-H | --help] Print this help message") + print("[-g | --game-version] Game version (one of: EN, JP, default EN)") + print("[-r | --starting-rank] Starting rank (REQUIRED, must be >= 34)") + print("[-e | --starting-exp] Starting EXP (optional, defaults to 0)") + print("[-R | --desired-rank] Desired rank (REQUIRED, must be >= starting-rank)") def main(argv): rarity = None @@ -93,31 +93,31 @@ def main(argv): # canonicalize it to uppercase game_version = game_version.upper() if game_version != "EN" and game_version != "JP": - print "Error: invalid game version (%s)" % game_version + print("Error: invalid game version (%s)" % game_version) usage() sys.exit(1) # now validate levels if starting_rank is None: - print "Error: must specify starting rank" + print("Error: must specify starting rank") usage() sys.exit(1) elif desired_rank is None: - print "Error: must specify desired rank" + print("Error: must specify desired rank") usage() sys.exit(1) elif starting_rank < 34: - print "Error: starting rank must be greater than or equal to 34" + print("Error: starting rank must be greater than or equal to 34") usage() sys.exit(1) elif desired_rank <= starting_rank: - print "Error: desired rank must be greater than starting rank" + print("Error: desired rank must be greater than starting rank") usage() sys.exit(1) # now validate starting exp if starting_exp < 0: - print "Error: invalid starting EXP (%d)" % starting_exp + print("Error: invalid starting EXP (%d)" % starting_exp) usage() sys.exit(1) @@ -127,4 +127,4 @@ def main(argv): ### main script starts here if __name__ == "__main__": - main(sys.argv[1:]) \ No newline at end of file + main(sys.argv[1:])