Compare commits

...

No commits in common. "ca52ffd5ef0f875d8f60348097c0510321912570" and "main" have entirely different histories.

19 changed files with 162 additions and 414 deletions

190
.gitignore vendored
View file

@ -1,48 +1,162 @@
# These are some examples of commonly ignored file patterns. # ---> Python
# You should customize this list as applicable to your project. # Byte-compiled / optimized / DLL files
# Learn more about .gitignore: __pycache__/
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Node artifact files
node_modules/
dist/
# Compiled Python bytecode
*.py[cod] *.py[cod]
*$py.class
# Log files # C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log *.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Applications # Flask stuff:
*.app instance/
*.exe .webassets-cache
*.war
# Cache files for Sublime Text # Scrapy stuff:
*.tmlanguage.cache .scrapy
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific # Sphinx documentation
*.sublime-workspace docs/_build/
# Project files should be checked into the repository, unless a significant # PyBuilder
# proportion of contributors will probably not be using Sublime Text .pybuilder/
# *.sublime-project target/
# SFTP configuration file # Jupyter Notebook
sftp-config.json .ipynb_checkpoints
sftp-config-alt*.json
# Package control specific files # IPython
Package Control.last-run profile_default/
Package Control.ca-list ipython_config.py
Package Control.ca-bundle
Package Control.system-ca-bundle # pyenv
Package Control.cache/ # For a library or package, you might want to ignore these files since the code is
Package Control.ca-certs/ # intended to run in multiple environments; otherwise, check them in:
Package Control.merged-ca-bundle # .python-version
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt # pipenv
bh_unicode_properties.cache # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

9
LICENSE Normal file
View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2025 funkywaddle
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.

View file

@ -1,28 +0,0 @@
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "./venv/bin/python -u \"$file\""
}
],
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings":
{
"anaconda_linting": true,
"anaconda_linting_behaviour": "always",
"pep257": false,
"python_interpreter": "./venv/bin/python",
"test_command": "./venv/bin/python -m unittest discover",
"use_pylint": false,
"validate_imports": true
}
}

View file

@ -1,27 +1,2 @@
# Generic Lottery game number checker # # LotteryChecker
Currently includes Powerball and Megamillions.
You add your picks to {game}/picks.py, and run `./play -g {gamename}` eg `.play.py -g powerball`
The script will pull the current winning numbers from an rss feed, and compare them to each ticket you list in the picks.py file for that game.
The output per ticket:
```text
Winning Numbers: [2, 13, 32, 33, 48]
Winning Powerball: 22
Your Numbers: (1, 2, 3, 4, 5)
Your Powerball: 9
Matched Numbers: [2]
Matched Powerball: False
Not a Winner!
```
OR
```text
Winning Numbers: [2, 13, 32, 33, 48]
Winning Powerball: 22
Your Numbers: (1, 2, 3, 4, 5)
Your Powerball: 22
Matched Numbers: [2]
Matched Powerball: True
Ticket is worth: 8
```

View file

@ -1,79 +0,0 @@
class Ticket:
def __init__(self, my_picks, my_special_ball):
self.jackpot = 0
self.my_picks = my_picks
self.my_special_ball = my_special_ball
self.winning_numbers = []
self.special_ball = None
self.special_ball_name = 'Special Ball'
self.multiplier = None
self.matched_numbers = []
self.matched_special_ball = None
self.winnings = 0
self.feed = None
def get_jp_amount(self):
self.jackpot = self.feed.get_jackpot()
def get_winning_numbers(self):
winners = self.feed.get_winning_numbers()
self.winning_numbers = winners['numbers']
self.special_ball = winners['special_ball']
self.multiplier = winners['multiplier']
def process_ticket(self):
self.check_numbers()
self.check_special_ball()
self.get_jp_amount()
special_ball_wins = self.get_winnings_with_special_ball(self.jackpot)
non_special_ball_wins = self.get_winnings_without_special_ball()
self.process_winnings(special_ball_wins, non_special_ball_wins)
def check_numbers(self):
# for num in self.my_picks:
# if num in self.winning_numbers:
# self.matched_numbers.append(num)
self.matched_numbers = list(
set(self.my_picks).intersection(set(self.winning_numbers)))
def check_special_ball(self):
self.matched_special_ball = False
if self.special_ball is not None and self.my_special_ball == self.special_ball:
self.matched_special_ball = True
def process_winnings(self, special_ball_wins, non_special_ball_wins):
wins = non_special_ball_wins
if self.matched_special_ball:
wins = special_ball_wins
self.winnings = wins[self.multiplier][len(self.matched_numbers)]
self.output_ticket()
def get_ticket_winnings(self):
return self.winnings
def output_ticket(self):
special_ball = self.special_ball_name
print(f'Winning Numbers: {self.winning_numbers}')
print(f'Winning {special_ball}: {self.special_ball}')
print(f'Your Numbers: {self.my_picks}')
print(f'Your {special_ball}: {self.my_special_ball}')
print(f'Matched Numbers: {self.matched_numbers}')
print(
f'Matched {special_ball}: '
f'{"True" if self.matched_special_ball else "False"}'
)
if self.winnings > 0:
print(f'Ticket is worth: {self.winnings}')
else:
print(f'Not a Winner!')
print()
def get_winnings_with_special_ball(self, jp):
pass
def get_winnings_without_special_ball(self):
pass

View file

@ -1,34 +0,0 @@
import feedparser
class Feed:
def __init__(self):
self.feed = 'https://www.texaslottery.com/export/sites/lottery/rss/tlc_latest.xml'
self.parsed_feed = feedparser.parse(self.feed)
self.modifiers = {
'Billion': 1000000000,
'Million': 1000000
}
def get_winning_numbers(self):
nums_pre = self.parsed_feed.entries[2].summary
nums_pre = nums_pre.replace('MegaBall', '-').replace(' Megaplier', '-')
nums = nums_pre.split(' - ')
winning_numbers = nums[:5]
for idx, num in enumerate(nums[:5]):
winning_numbers[idx] = int(num)
special_ball = int(nums[5])
multiplier = int(nums[6])
return {'numbers': winning_numbers, 'special_ball': special_ball, 'multiplier': multiplier}
def get_jackpot(self):
jp_pre = self.parsed_feed.entries[3].summary
jp_pre = jp_pre[jp_pre.index('Cash'):]
jp_pre = jp_pre[jp_pre.index(':') + 3:]
jp_data = jp_pre.split()
return float(jp_data[0]) * self.modifiers[jp_data[1]]

View file

@ -1,18 +0,0 @@
from lib.Ticket import Ticket
from .Feed import Feed
from .winning_structure import get_winnings_mb, get_winnings_no_mb
class MegaMillions(Ticket):
def __init__(self, my_picks, my_special_ball):
super().__init__(my_picks, my_special_ball)
self.special_ball_name = 'MegaBall'
self.feed = Feed()
self.get_winning_numbers()
def get_winnings_with_special_ball(self, jp):
return get_winnings_mb(self.jackpot)
def get_winnings_without_special_ball(self):
return get_winnings_no_mb()

View file

@ -1,21 +0,0 @@
#! /usr/bin/python3
from .picks import my_picks
from .MegaMillions import MegaMillions
cur_picks = []
cur_pb = 0
winnings = {}
for idx, tkt in enumerate(my_picks):
cur_picks = tkt['picks']
cur_pb = tkt['mb']
tktnum = tkt['ticket']
pbtkt = MegaMillions(cur_picks, cur_pb)
pbtkt.process_ticket()
key = 'Ticket ' + str(tktnum)
if key not in winnings.keys():
winnings[key] = 0
winnings[key] += pbtkt.get_ticket_winnings()
print("Total Winnings:", winnings)

View file

@ -1,14 +0,0 @@
my_picks = [
{'picks': (9, 11, 42, 53, 69), 'mb': 22, 'ticket': 1},
{'picks': (6, 11, 24, 42, 69), 'mb': 17, 'ticket': 1},
{'picks': (2, 20, 24, 43, 48), 'mb': 13, 'ticket': 1},
{'picks': (3, 7, 20, 47, 68), 'mb': 13, 'ticket': 1},
{'picks': (5, 9, 13, 18, 25), 'mb': 9, 'ticket': 1},
# quick picks #
{'picks': (13, 37, 44, 50, 61), 'mb': 9, 'ticket': 2},
{'picks': (1, 36, 43, 55, 68), 'mb': 25, 'ticket': 2},
{'picks': (2, 13, 44, 52, 70), 'mb': 15, 'ticket': 2},
{'picks': (8, 21, 27, 63, 64), 'mb': 2, 'ticket': 2},
{'picks': (14, 42, 48, 57, 58), 'mb': 4, 'ticket': 2},
]

View file

@ -1,16 +0,0 @@
def get_winnings_mb(jackpot_cash):
return {
2: [4, 8, 20, 400, 20_000, jackpot_cash],
3: [6, 12, 30, 600, 30_000, jackpot_cash],
4: [8, 16, 40, 800, 40_000, jackpot_cash],
5: [10, 20, 50, 1_000, 50_000, jackpot_cash]
}
def get_winnings_no_mb():
return {
2: [0, 0, 0, 20, 1_000, 2_000_000],
3: [0, 0, 0, 30, 1_500, 3_000_000],
4: [0, 0, 0, 40, 2_000, 4_000_000],
5: [0, 0, 0, 50, 2_500, 5_000_000]
}

25
play.py
View file

@ -1,25 +0,0 @@
#!/usr/bin/python3
import getopt
import sys
import importlib
def main(argv):
usage = 'play.py -g <gamename>'
try:
opts, args = getopt.getopt(argv, "hg:", ["game="])
except getopt.GetoptError:
print(usage)
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print(usage)
sys.exit()
elif opt in ("-g", "--game"):
importlib.import_module(f'{arg}.game')
if __name__ == "__main__":
main(sys.argv[1:])

View file

@ -1,34 +0,0 @@
import feedparser
class Feed:
def __init__(self):
self.feed = 'https://www.texaslottery.com/export/sites/lottery/rss/tlc_latest.xml'
self.parsed_feed = feedparser.parse(self.feed)
self.modifiers = {
'Billion': 1000000000,
'Million': 1000000
}
def get_winning_numbers(self):
nums_pre = self.parsed_feed.entries[0].summary
nums_pre = nums_pre.replace('Powerball', '-').replace(' Power Play', '-')
nums = nums_pre.split(' - ')
winning_numbers = nums[:5]
for idx, num in enumerate(nums[:5]):
winning_numbers[idx] = int(num)
special_ball = int(nums[5])
multiplier = int(nums[6])
return {'numbers': winning_numbers, 'special_ball': special_ball, 'multiplier': multiplier}
def get_jackpot(self):
jp_pre = self.parsed_feed.entries[1].summary
jp_pre = jp_pre[jp_pre.index('Cash'):]
jp_pre = jp_pre[jp_pre.index(':') + 3:]
jp_data = jp_pre.split()
return float(jp_data[0]) * self.modifiers[jp_data[1]]

View file

@ -1,18 +0,0 @@
from lib.Ticket import Ticket
from .Feed import Feed
from .winning_structure import get_winnings_pb, get_winnings_no_pb
class Powerball(Ticket):
def __init__(self, my_picks, my_special_ball):
super().__init__(my_picks, my_special_ball)
self.special_ball_name = 'Powerball'
self.feed = Feed()
self.get_winning_numbers()
def get_winnings_with_special_ball(self, jp):
return get_winnings_pb(self.jackpot)
def get_winnings_without_special_ball(self):
return get_winnings_no_pb()

View file

View file

@ -1,21 +0,0 @@
#! /usr/bin/python3
from .picks import my_picks
from .Powerball import Powerball
cur_picks = []
cur_pb = 0
winnings = {}
for idx, tkt in enumerate(my_picks):
cur_picks = tkt['picks']
cur_pb = tkt['pb']
tktnum = tkt['ticket']
pbtkt = Powerball(cur_picks, cur_pb)
pbtkt.process_ticket()
key = 'Ticket ' + str(tktnum)
if key not in winnings.keys():
winnings[key] = 0
winnings[key] += pbtkt.get_ticket_winnings()
print("Total Winnings:", winnings)

View file

@ -1,20 +0,0 @@
my_picks = [
{'picks': (9, 11, 42, 53, 69), 'pb': 22, 'ticket': 1},
{'picks': (6, 11, 24, 42, 69), 'pb': 17, 'ticket': 1},
{'picks': (2, 20, 24, 43, 48), 'pb': 13, 'ticket': 1},
{'picks': (3, 7, 20, 47, 68), 'pb': 13, 'ticket': 1},
{'picks': (5, 9, 13, 18, 25), 'pb': 9, 'ticket': 1},
# Quick Picks #
{'picks': (4, 10, 17, 36, 67), 'pb': 16, 'ticket': 2},
{'picks': (14, 20, 33, 41, 59), 'pb': 26, 'ticket': 2},
{'picks': (32, 39, 56, 58, 67), 'pb': 23, 'ticket': 2},
{'picks': (5, 12, 24, 61, 64), 'pb': 11, 'ticket': 2},
{'picks': (11, 13, 16, 24, 35), 'pb': 25, 'ticket': 2},
{'picks': (32, 38, 47, 54, 62), 'pb': 26, 'ticket': 3},
{'picks': (2, 10, 53, 62, 67), 'pb': 14, 'ticket': 3},
{'picks': (1, 19, 37, 52, 66), 'pb': 22, 'ticket': 3},
{'picks': (18, 35, 51, 65, 67), 'pb': 24, 'ticket': 3},
{'picks': (17, 35, 42, 48, 65), 'pb': 7, 'ticket': 3},
]

View file

@ -1,20 +0,0 @@
def get_winnings_pb(jackpot_cash):
return {
0: [4, 4, 7, 100, 50_000, jackpot_cash],
2: [8, 8, 14, 200, 100_000, jackpot_cash],
3: [12, 12, 21, 300, 150_000, jackpot_cash],
4: [16, 16, 28, 400, 200_000, jackpot_cash],
5: [20, 20, 35, 500, 250_000, jackpot_cash],
10: [40, 40, 70, 1_000, 500_000, jackpot_cash]
}
def get_winnings_no_pb():
return {
0: [0, 0, 0, 7, 100, 1_000_000],
2: [0, 0, 0, 14, 200, 2_000_000],
3: [0, 0, 0, 21, 300, 2_000_000],
4: [0, 0, 0, 28, 400, 2_000_000],
5: [0, 0, 0, 35, 500, 2_000_000],
10: [0, 0, 0, 70, 1_000, 2_000_000]
}

View file

@ -1,2 +0,0 @@
feedparser==6.0.8
sgmllib3k==1.0.0