Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing print statements to compatible with Python 3.x #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions command_line/cardlevelcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -223,4 +223,4 @@ def main(argv):
### main script starts here

if __name__ == "__main__":
main(sys.argv[1:])
main(sys.argv[1:])
50 changes: 25 additions & 25 deletions command_line/eventcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("")
Expand All @@ -109,47 +109,47 @@ 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.
# (it can also be removed safely, but you won't hear an alert sound when it's time to claim your daily login bonus)
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
Expand Down Expand Up @@ -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:
Expand All @@ -210,4 +210,4 @@ def main(argv):
### main script starts here

if __name__ == "__main__":
main(sys.argv[1:])
main(sys.argv[1:])
56 changes: 28 additions & 28 deletions command_line/gemcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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:])
main(sys.argv[1:])
Loading