Add love gem calculator

This commit is contained in:
Donald Burr 2015-10-12 05:52:00 -07:00
parent aa0ea76913
commit 1fd40c90c0
2 changed files with 258 additions and 2 deletions

View file

@ -105,9 +105,83 @@ EASY (1958) NORMAL (904) HARD (511) EXPERT (284)
At rank 80 you will have 65 LP and 23 friend slots.
```
## Bugs? Need help? Or want to chat?
## Love Gem (aka loveca) Calculator
I wouldn't be surprised if there are any bugs, and/or if I got some of the calculations wrong. If you have any bug reports (or better yet, bug fixes!) or if you need help using these (or if you just want to say hi and/or chat) please feel free to send them my way. Create a pull request on Github or just drop me an email.
```
Usage: gemcalc.py [options]
where [options] can be one or more of:
[-H | --help] Print this help message
[-g | --current-gems] Current number of love gems (optional, default=0)
[-v | --verbose] Verbosely print out when gems are collected
Plus one of the following:
TO CALCULATE NUMBER OF LOVE GEMS YOU'LL HAVE ON A GIVEN DATE:
[-d | --date] Date to calculate gem count for
TO CALCULATE HOW LONG UNTIL YOU WILL GET A CERTAIN NUMBER OF GEMS:
[-G | --desired-gems] Calculate level that card will be at given EXP
```
Example: How many love gems will you have on Christmas?
```
$ gemcalc.py -d 12/25/2015 -v
Today is 10/12/2015 and you currently have 0 love gems.
(Assuming you collected any gems you got today and already counted those.)
10/16/2015: free gem as login bonus, which brings you to 1 gems.
10/21/2015: free gem as login bonus AND it's Eli's birthday! You get 6 gems, which brings you to 7 gems.
10/26/2015: free gem as login bonus, which brings you to 8 gems.
10/30/2015: free gem as login bonus, which brings you to 9 gems.
11/01/2015: free gem as login bonus AND it's Rin's birthday! You get 6 gems, which brings you to 15 gems.
11/06/2015: free gem as login bonus, which brings you to 16 gems.
11/11/2015: free gem as login bonus, which brings you to 17 gems.
11/16/2015: free gem as login bonus, which brings you to 18 gems.
11/21/2015: free gem as login bonus, which brings you to 19 gems.
11/26/2015: free gem as login bonus, which brings you to 20 gems.
11/30/2015: free gem as login bonus, which brings you to 21 gems.
12/01/2015: free gem as login bonus, which brings you to 22 gems.
12/06/2015: free gem as login bonus, which brings you to 23 gems.
12/11/2015: free gem as login bonus, which brings you to 24 gems.
12/16/2015: free gem as login bonus, which brings you to 25 gems.
12/21/2015: free gem as login bonus, which brings you to 26 gems.
You will have 26 love gems on 12/25/2015. Good things come to those who wait!
```
Example: You have 18 love gems now. When will you be able to do a 10+1 scout (i.e. have at least 50 gems)?
```
$ gemcalc.py -g 18 -G 50 -v
Today is 10/12/2015 and you currently have 18 love gems.
(Assuming you collected any gems you got today and already counted those.)
10/16/2015: free gem as login bonus, which brings you to 19 gems.
10/21/2015: free gem as login bonus AND it's Eli's birthday! You get 6 gems, which brings you to 25 gems.
10/26/2015: free gem as login bonus, which brings you to 26 gems.
10/30/2015: free gem as login bonus, which brings you to 27 gems.
11/01/2015: free gem as login bonus AND it's Rin's birthday! You get 6 gems, which brings you to 33 gems.
11/06/2015: free gem as login bonus, which brings you to 34 gems.
11/11/2015: free gem as login bonus, which brings you to 35 gems.
11/16/2015: free gem as login bonus, which brings you to 36 gems.
11/21/2015: free gem as login bonus, which brings you to 37 gems.
11/26/2015: free gem as login bonus, which brings you to 38 gems.
11/30/2015: free gem as login bonus, which brings you to 39 gems.
12/01/2015: free gem as login bonus, which brings you to 40 gems.
12/06/2015: free gem as login bonus, which brings you to 41 gems.
12/11/2015: free gem as login bonus, which brings you to 42 gems.
12/16/2015: free gem as login bonus, which brings you to 43 gems.
12/21/2015: free gem as login bonus, which brings you to 44 gems.
12/26/2015: free gem as login bonus, which brings you to 45 gems.
12/30/2015: free gem as login bonus, which brings you to 46 gems.
01/01/2016: free gem as login bonus, which brings you to 47 gems.
01/06/2016: free gem as login bonus, which brings you to 48 gems.
01/11/2016: free gem as login bonus, which brings you to 49 gems.
01/16/2016: free gem as login bonus, which brings you to 50 gems.
You will have 50 love gems on 01/16/2016. Good things come to those who wait!
```
## Bugs? Need help? Got any suggestions/ideas for new features? Or want to chat?
I wouldn't be surprised if there are any bugs, and/or if I got some of the calculations wrong. If you have any bug reports (or better yet, bug fixes!), suggestions/ideas for new features, or if you need help using these (or if you just want to say hi and/or chat) please feel free to send them my way. Create a pull request on Github or just drop me an email.
Email: <dburr@DonaldBurr.com>
Twitter: [@dburr](https://twitter.com/dburr) (my personal Twitter account), [@otakunopodcast](https://twitter.com/otakunopodcast) (where I do most of my SIF-related tweeting)

182
gemcalc.py Executable file
View 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"
print ""
print "TO CALCULATE HOW LONG UNTIL YOU WILL GET A CERTAIN NUMBER OF GEMS:"
print "[-G | --desired-gems] Calculate level that card will be at given EXP"
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:])