Move everything into command line dir
This commit is contained in:
parent
a11c922880
commit
4ec8b10216
4 changed files with 0 additions and 0 deletions
226
command_line/cardlevelcalc.py
Executable file
226
command_line/cardlevelcalc.py
Executable file
|
@ -0,0 +1,226 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Card level-up requirements (EXP) calculator
|
||||
#
|
||||
# Part of SIFTools <https://github.com/dburr/SIFTools/>
|
||||
# By Donald Burr <dburr@DonaldBurr.com>
|
||||
# Copyright (c) 2015 Donald Burr.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
|
||||
# The EXP tables
|
||||
# data from: http://www59.atwiki.jp/lovelive-sif/pages/32.html
|
||||
# these have -1 as the first value because python arrays are 0-based and I am using <level> as the index
|
||||
# and am too lazy to do <level-1> to account for the 0-based-ness :P
|
||||
exp_table_n = [-1, 0, 6, 18, 28, 40, 51, 61, 72, 82, 93, 104, 114, 124, 135, 145, 156, 165, 176, 187, 196, 207, 217, 226, 238, 247, 257, 268, 277, 288, 297, 308, 317, 328, 337, 348, 358, 367, 377, 388, 397]
|
||||
exp_table_r = [-1, 0, 14, 31, 45, 55, 67, 76, 85, 94, 103, 110, 119, 125, 134, 140, 148, 155, 161, 168, 174, 181, 187, 193, 199, 206, 211, 217, 223, 228, 235, 240, 245, 251, 256, 262, 267, 272, 277, 283, 288, 292, 298, 303, 308, 313, 317, 323, 327, 332, 337, 342, 346, 351, 356, 360, 365, 370, 374, 378, 383]
|
||||
exp_table_sr = [-1, 0, 54, 98, 127, 150, 169, 187, 203, 218, 232, 245, 257, 269, 281, 291, 302, 311, 322, 331, 340, 349, 358, 366, 374, 383, 391, 398, 406, 413, 421, 428, 435, 442, 449, 456, 462, 469, 475, 482, 488, 494, 500, 507, 512, 518, 524, 530, 536, 541, 547, 552, 558, 563, 568, 574, 579, 584, 590, 594, 600, 605, 609, 615, 619, 625, 629, 634, 639, 643, 648, 653, 657, 662, 667, 670, 676, 680, 684, 689, 693]
|
||||
exp_table_ur = [-1, 0, 201, 294, 345, 382, 411, 438, 460, 481, 499, 517, 532, 547, 561, 574, 587, 598, 611, 621, 631, 642, 651, 661, 670, 679, 687, 696, 704, 712, 720, 727, 734, 742, 749, 755, 763, 769, 775, 782, 788, 794, 800, 806, 812, 818, 823, 829, 834, 840, 845, 850, 856, 860, 866, 870, 875, 880, 885, 890, 894, 899, 903, 908, 912, 917, 921, 925, 930, 933, 938, 942, 946, 950, 954, 959, 961, 966, 970, 974, 977, 981, 985, 988, 992, 996, 999, 1003, 1006, 1010, 1013, 1017, 1020, 1024, 1027, 1030, 1034, 1037, 1040, 1043, 1047]
|
||||
|
||||
# max levels
|
||||
# note we don't check whether the card is idolized or not
|
||||
# we assume that the user knows what they're doing
|
||||
level_cap_n = 40
|
||||
level_cap_r = 60
|
||||
level_cap_sr = 80
|
||||
level_cap_ur = 100
|
||||
|
||||
def check_level_cap(rarity, level):
|
||||
return_value = False
|
||||
if level >= 1:
|
||||
if rarity == "N":
|
||||
return_value = (level <= level_cap_n)
|
||||
elif rarity == "R":
|
||||
return_value = (level <= level_cap_r)
|
||||
elif rarity == "SR":
|
||||
return_value = (level <= level_cap_sr)
|
||||
elif rarity == "UR":
|
||||
return_value = (level <= level_cap_ur)
|
||||
return return_value
|
||||
|
||||
def check_valid_exp(rarity, level, exp):
|
||||
return_value = False
|
||||
if rarity == "N" and check_level_cap(rarity, level):
|
||||
return_value = (exp >= 0 and exp < exp_table_n[level])
|
||||
elif rarity == "R" and check_level_cap(rarity, level):
|
||||
return_value = (exp >= 0 and exp < exp_table_r[level])
|
||||
elif rarity == "SR" and check_level_cap(rarity, level):
|
||||
return_value = (exp >= 0 and exp < exp_table_sr[level])
|
||||
elif rarity == "UR" and check_level_cap(rarity, level):
|
||||
return_value = (exp >= 0 and exp < exp_table_ur[level])
|
||||
return return_value
|
||||
|
||||
def calc_exp_for_level(rarity, starting_level, starting_exp, desired_level):
|
||||
# assumes that all values fed into it have been checked already
|
||||
required_exp = 0
|
||||
# desired_level+1 because python ranges are not inclusive :P
|
||||
for level in range(starting_level+1, desired_level+1):
|
||||
if rarity == "N":
|
||||
required_exp = required_exp + exp_table_n[level]
|
||||
elif rarity == "R":
|
||||
required_exp = required_exp + exp_table_r[level]
|
||||
elif rarity == "SR":
|
||||
required_exp = required_exp + exp_table_sr[level]
|
||||
elif rarity == "UR":
|
||||
required_exp = required_exp + exp_table_ur[level]
|
||||
#print "WE ARE AT LEVEL %d and we need %d exp" % (level, required_exp)
|
||||
# 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)
|
||||
# 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
|
||||
|
||||
def calc_level_for_exp(rarity, starting_level, starting_exp, level_for_exp):
|
||||
current_exp = starting_exp
|
||||
level_cap = 0
|
||||
if rarity == "N":
|
||||
level_cap = level_cap_n
|
||||
elif rarity == "R":
|
||||
level_cap = level_cap_r
|
||||
elif rarity == "SR":
|
||||
level_cap = level_cap_sr
|
||||
elif rarity == "UR":
|
||||
level_cap = level_cap_ur
|
||||
for level in range(starting_level+1, level_cap+1):
|
||||
if rarity == "N":
|
||||
current_exp = current_exp + exp_table_n[level]
|
||||
elif rarity == "R":
|
||||
current_exp = current_exp + exp_table_r[level]
|
||||
elif rarity == "SR":
|
||||
current_exp = current_exp + exp_table_sr[level]
|
||||
elif rarity == "UR":
|
||||
current_exp = current_exp + exp_table_ur[level]
|
||||
#print "WE ARE AT LEVEL %d and we need %d exp" % (level, required_exp)
|
||||
if current_exp > level_for_exp:
|
||||
level = level - 1
|
||||
break
|
||||
if level > starting_level:
|
||||
if level == level_cap:
|
||||
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)
|
||||
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)
|
||||
|
||||
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"
|
||||
|
||||
def main(argv):
|
||||
rarity = None
|
||||
starting_level = None
|
||||
desired_level = None
|
||||
level_for_exp = None
|
||||
starting_exp = 0
|
||||
try:
|
||||
options, remainder = getopt.getopt(argv, "Hr:l:e:L:x:", ["help", "rarity=", "starting-level=", "starting-exp=", "desired-level=", "level-for-exp="])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
for opt, arg in options:
|
||||
if opt in ('-H', '--help'):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
elif opt in ('-r', '--rarity'):
|
||||
rarity = arg
|
||||
elif opt in ('-l', '--starting-level'):
|
||||
starting_level = int(arg)
|
||||
elif opt in ('-e', '--starting-exp'):
|
||||
starting_exp = int(arg)
|
||||
elif opt in ('-L', '--desired-level'):
|
||||
desired_level = int(arg)
|
||||
elif opt in ('-x', '--level-for-exp'):
|
||||
level_for_exp = int(arg)
|
||||
|
||||
# first validate rarity
|
||||
if rarity is None:
|
||||
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
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
# now validate starting level
|
||||
if starting_level is None:
|
||||
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
|
||||
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."
|
||||
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
|
||||
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"
|
||||
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
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
# all is well, go for it
|
||||
calc_exp_for_level(rarity, starting_level, starting_exp, desired_level)
|
||||
elif level_for_exp is not None:
|
||||
calc_level_for_exp(rarity, starting_level, starting_exp, level_for_exp)
|
||||
|
||||
### main script starts here
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
213
command_line/eventcalc.py
Executable file
213
command_line/eventcalc.py
Executable file
|
@ -0,0 +1,213 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Event time-remaining calculator
|
||||
#
|
||||
# Part of SIFTools <https://github.com/dburr/SIFTools/>
|
||||
# By Donald Burr <dburr@DonaldBurr.com>
|
||||
# Copyright (c) 2015 Donald Burr.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
# curses docs: https://docs.python.org/2/library/curses.html
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
import curses
|
||||
|
||||
scr = None
|
||||
width = None
|
||||
height = None
|
||||
|
||||
def center(string):
|
||||
global width
|
||||
global height
|
||||
string_length = len(string)
|
||||
horizontal_space = (width // 2) - (string_length // 2)
|
||||
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
|
||||
# will most likely not work properly on Windows machines. If nothing else, you can replace
|
||||
# this code with a simple "return" statement that returns a hard-coded value (e.g. "return (80,24")
|
||||
def getTerminalSize():
|
||||
import os
|
||||
env = os.environ
|
||||
def ioctl_GWINSZ(fd):
|
||||
try:
|
||||
import fcntl, termios, struct, os
|
||||
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
|
||||
'1234'))
|
||||
except:
|
||||
return
|
||||
return cr
|
||||
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
|
||||
if not cr:
|
||||
try:
|
||||
fd = os.open(os.ctermid(), os.O_RDONLY)
|
||||
cr = ioctl_GWINSZ(fd)
|
||||
os.close(fd)
|
||||
except:
|
||||
pass
|
||||
if not cr:
|
||||
cr = (env.get('LINES', 25), env.get('COLUMNS', 80))
|
||||
|
||||
### Use get(key[, default]) instead of a try/catch
|
||||
#try:
|
||||
# cr = (env['LINES'], env['COLUMNS'])
|
||||
#except:
|
||||
# cr = (25, 80)
|
||||
return int(cr[1]), int(cr[0])
|
||||
|
||||
def calc(year, month, day, hour, minute, fullscreen = False):
|
||||
global height
|
||||
today = datetime.datetime.utcnow()
|
||||
today_hour = today.hour
|
||||
today_minute = today.minute
|
||||
today_seconds = today.second
|
||||
delta = datetime.datetime(year, month, day, hour, minute, 0) - today
|
||||
s = delta.total_seconds()
|
||||
days, days_remainder = divmod(s, 86400)
|
||||
days_hours, days_hours_remainder = divmod(days_remainder, 3600)
|
||||
days_minutes, days_seconds = divmod(days_hours_remainder, 60)
|
||||
hours, remainder = divmod(s, 3600)
|
||||
minutes, seconds = divmod(remainder, 60)
|
||||
if fullscreen:
|
||||
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 ""
|
||||
center("CURRENT TIME")
|
||||
center(today.strftime("%Y-%m-%d %H:%M:%S UTC"))
|
||||
print("")
|
||||
center("EVENT ENDS")
|
||||
center("%04d-%02d-%02d %02d:%02d:%02d UTC" % (year, month, day, hour, minute, 0))
|
||||
print("")
|
||||
center("TIME REMAINING")
|
||||
if s <= 0:
|
||||
center("*** EVENT HAS ENDED ***")
|
||||
else:
|
||||
center("%d:%02d:%02d (%dd%dh%dm)" % (hours, minutes, seconds, days, days_hours, days_minutes))
|
||||
skip_lines = number_of_blank_lines
|
||||
if today_minute == 35:
|
||||
skip_lines = skip_lines - 3
|
||||
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 ""
|
||||
center("*** THE RUSH IS ON!!! ***")
|
||||
if today_hour == 0 and today_minute == 0:
|
||||
skip_lines = skip_lines - 2
|
||||
print ""
|
||||
if today_seconds % 2 == 0:
|
||||
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 ""
|
||||
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)
|
||||
if s <= 0:
|
||||
print "Time remaining: *** EVENT HAS ENDED ***"
|
||||
else:
|
||||
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!!! ***"
|
||||
|
||||
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."
|
||||
|
||||
def main(argv):
|
||||
global scr
|
||||
global width
|
||||
global height
|
||||
year = datetime.datetime.utcnow().year
|
||||
month = datetime.datetime.utcnow().month
|
||||
day = None
|
||||
hour = None
|
||||
minute = 0
|
||||
continuous_mode = False
|
||||
#scr = curses.initscr()
|
||||
(width, height) = getTerminalSize()
|
||||
#(width, height) = getmaxyx()
|
||||
try:
|
||||
options, remainder = getopt.getopt(argv, "Hy:M:d:h:m:c", ["help", "year=", "month=", "day=", "hour=", "minute=", "continuous"])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
for opt, arg in options:
|
||||
if opt in ('-H', '--help'):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
elif opt in ('-y', '--year'):
|
||||
year = int(arg)
|
||||
elif opt in ('-M', '--month'):
|
||||
month = int(arg)
|
||||
elif opt in ('-d', '--day'):
|
||||
day = int(arg)
|
||||
elif opt in ('-h', '--hour'):
|
||||
hour = int(arg)
|
||||
elif opt in ('-m', '--minute'):
|
||||
minute = int(arg)
|
||||
elif opt in ('-c', '--continuous'):
|
||||
continuous_mode = True
|
||||
|
||||
if day is None:
|
||||
print "Error: must specify day"
|
||||
usage()
|
||||
sys.exit(1)
|
||||
elif hour is None:
|
||||
print "Error: must specify hour"
|
||||
usage()
|
||||
sys.exit(1)
|
||||
else:
|
||||
if continuous_mode:
|
||||
while True:
|
||||
# NOTE: OS DEPENDENT SECTION - this commands clears the screen. This command should work on Mac and Linux systems.
|
||||
# For windows, you will need to change it to the following: (note, I have not tested this)
|
||||
# absolutely_unused_variable = os.system("cls")
|
||||
|
||||
absolutely_unused_variable = os.system("clear")
|
||||
calc(year, month, day, hour, minute, True)
|
||||
time.sleep(1)
|
||||
else:
|
||||
calc(year, month, day, hour, minute)
|
||||
|
||||
### main script starts here
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
182
command_line/gemcalc.py
Executable file
182
command_line/gemcalc.py
Executable file
|
@ -0,0 +1,182 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Love Gem (aka loveca) calculator
|
||||
#
|
||||
# Part of SIFTools <https://github.com/dburr/SIFTools/>
|
||||
# By Donald Burr <dburr@DonaldBurr.com>
|
||||
# Copyright (c) 2015 Donald Burr.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
import calendar
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
def is_muse_members_birthday(month, day):
|
||||
is_bday = False
|
||||
bday_name = None
|
||||
if month == 1 and day == 17:
|
||||
is_bday = True
|
||||
bday_name = "Hanayo"
|
||||
elif month == 3 and day == 15:
|
||||
is_bday = True
|
||||
bday_name = "Umi"
|
||||
elif month == 4 and day == 19:
|
||||
is_bday = True
|
||||
bday_name = "Maki"
|
||||
elif month == 6 and day == 9:
|
||||
is_bday = True
|
||||
bday_name = "Nozomi"
|
||||
elif month == 7 and day == 22:
|
||||
is_bday = True
|
||||
bday_name = "Nico"
|
||||
elif month == 8 and day == 3:
|
||||
is_bday = True
|
||||
bday_name = "Honoka"
|
||||
elif month == 9 and day == 12:
|
||||
is_bday = True
|
||||
bday_name = "Kotori"
|
||||
elif month == 10 and day == 21:
|
||||
is_bday = True
|
||||
bday_name = "Eli"
|
||||
elif month == 11 and day == 1:
|
||||
is_bday = True
|
||||
bday_name = "Rin"
|
||||
return (is_bday, bday_name)
|
||||
|
||||
def is_gem_day(day):
|
||||
# according the login bonus chart, gems are given out on days numbered 1,6,11,16,21,26,30
|
||||
if day == 1 or day == 6 or day == 11 or day == 16 or day == 21 or day == 26 or day == 30:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def validate(date_text):
|
||||
try:
|
||||
datetime.datetime.strptime(date_text, '%m/%d/%Y')
|
||||
return True
|
||||
except ValueError:
|
||||
raise ValueError("Incorrect date format, should be MM/DD/YYYY")
|
||||
|
||||
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.)"
|
||||
gems = current_gems
|
||||
now = now + timedelta(days=1)
|
||||
while now < target_datetime:
|
||||
if is_gem_day(now.day):
|
||||
gems = gems + 1
|
||||
(is_bday, name) = is_muse_members_birthday(now.month, now.day)
|
||||
if is_bday:
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
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.)"
|
||||
gems = current_gems
|
||||
while gems < desired_gems:
|
||||
now = now + timedelta(days=1)
|
||||
if is_gem_day(now.day):
|
||||
gems = gems + 1
|
||||
(is_bday, name) = is_muse_members_birthday(now.month, now.day)
|
||||
if is_bday:
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
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"
|
||||
|
||||
def main(argv):
|
||||
current_gems = 0
|
||||
target_date = None
|
||||
desired_gems = None
|
||||
verbose = False
|
||||
try:
|
||||
options, remainder = getopt.getopt(argv, "Hg:d:G:v", ["help", "current-gems=", "date=", "desired-gems=", "verbose"])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
for opt, arg in options:
|
||||
if opt in ('-H', '--help'):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
elif opt in ('-g', '--current-gems'):
|
||||
current_gems = int(arg)
|
||||
elif opt in ('-d', '--date'):
|
||||
target_date = arg
|
||||
elif opt in ('-G', '--desired-gems'):
|
||||
desired_gems = int(arg)
|
||||
elif opt in ('-v', '--verbose'):
|
||||
verbose = True
|
||||
|
||||
# now do something
|
||||
if target_date is not None:
|
||||
# validate it
|
||||
if validate(target_date):
|
||||
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"
|
||||
usage()
|
||||
sys.exit(0)
|
||||
else:
|
||||
calc_desired_gems(current_gems, desired_gems, verbose)
|
||||
else:
|
||||
print "Error: must specify either -d or -G."
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
### main script starts here
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
130
command_line/rankcalc.py
Executable file
130
command_line/rankcalc.py
Executable file
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Rank-up requirements (EXP) calculator
|
||||
#
|
||||
# Part of SIFTools <https://github.com/dburr/SIFTools/>
|
||||
# By Donald Burr <dburr@DonaldBurr.com>
|
||||
# Copyright (c) 2015 Donald Burr.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
from math import floor
|
||||
|
||||
# algorithm from: http://decaf.kouhi.me/lovelive/index.php?title=Gameplay#Ranks
|
||||
def calc(game_version, starting_rank, starting_exp, desired_rank):
|
||||
required_exp = 0
|
||||
for rank in range(starting_rank, desired_rank):
|
||||
required_exp_for_next_rank = round(34.45 * rank - 551)
|
||||
# account for half EXP on JP (only if rank < 100)
|
||||
if game_version == "JP" and rank < 100:
|
||||
required_exp_for_next_rank = required_exp_for_next_rank // 2
|
||||
#print "AT RANK %d NEED %d EXP" % (rank, required_exp_for_next_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:"
|
||||
# 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)
|
||||
# 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)
|
||||
|
||||
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)"
|
||||
|
||||
def main(argv):
|
||||
rarity = None
|
||||
game_version = "EN"
|
||||
starting_rank = None
|
||||
desired_rank = None
|
||||
starting_exp = 0
|
||||
try:
|
||||
options, remainder = getopt.getopt(argv, "Hg:r:e:R:", ["help", "game-version=", "starting-rank=", "starting-exp=", "desired-rank="])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
for opt, arg in options:
|
||||
if opt in ('-H', '--help'):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
elif opt in ('-g', '--game-version'):
|
||||
game_version = arg
|
||||
elif opt in ('-r', '--starting-rank'):
|
||||
starting_rank = int(arg)
|
||||
elif opt in ('-e', '--starting-exp'):
|
||||
starting_exp = int(arg)
|
||||
elif opt in ('-R', '--desired-rank'):
|
||||
desired_rank = int(arg)
|
||||
|
||||
# first validate game version
|
||||
# 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
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
# now validate levels
|
||||
if starting_rank is None:
|
||||
print "Error: must specify starting rank"
|
||||
usage()
|
||||
sys.exit(1)
|
||||
elif desired_rank is None:
|
||||
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"
|
||||
usage()
|
||||
sys.exit(1)
|
||||
elif desired_rank <= 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
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
# all is well, go for it
|
||||
calc(game_version, starting_rank, starting_exp, desired_rank)
|
||||
|
||||
### main script starts here
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
Loading…
Add table
Add a link
Reference in a new issue