mirror of
https://github.com/onyx-and-iris/lottery-tui.git
synced 2026-04-19 18:13:29 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 039487cfc5 | |||
| 84fcbd326a |
BIN
img/tui.png
BIN
img/tui.png
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 23 KiB |
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "lottery-tui"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
description = "A terminal user interface for lottery games."
|
||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||
dependencies = ["textual>=8.0.0"]
|
||||
|
||||
@@ -12,7 +12,7 @@ class Result(NamedTuple):
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Return a string representation of the lottery result."""
|
||||
out = f'Numbers: {", ".join(str(n) for n in self.numbers)}'
|
||||
out = f'Numbers: {", ".join(str(n) for n in sorted(self.numbers))}'
|
||||
if self.bonus:
|
||||
match self.kind:
|
||||
case 'EuroMillions':
|
||||
@@ -23,7 +23,7 @@ class Result(NamedTuple):
|
||||
bonus_name = 'Thunderball'
|
||||
case _:
|
||||
bonus_name = 'Bonus Numbers'
|
||||
out += f'\n{bonus_name}: {", ".join(str(n) for n in self.bonus)}'
|
||||
out += f'\n{bonus_name}: {", ".join(str(n) for n in sorted(self.bonus))}'
|
||||
return out
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class Lottery(ABC):
|
||||
"""An abstract base class for different types of lotteries."""
|
||||
|
||||
@abstractmethod
|
||||
def draw(self):
|
||||
def draw(self) -> Result:
|
||||
"""Perform a lottery draw."""
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class UKlotto(Lottery):
|
||||
|
||||
POSSIBLE_NUMBERS = range(1, 60)
|
||||
|
||||
def draw(self):
|
||||
def draw(self) -> Result:
|
||||
"""Perform a UK Lotto draw."""
|
||||
result = random.sample(UKlotto.POSSIBLE_NUMBERS, 6)
|
||||
return Result(kind='UK Lotto', numbers=result, bonus=None)
|
||||
@@ -71,7 +71,7 @@ class EuroMillions(Lottery):
|
||||
POSSIBLE_NUMBERS = range(1, 51)
|
||||
POSSIBLE_BONUS_NUMBERS = range(1, 13)
|
||||
|
||||
def draw(self):
|
||||
def draw(self) -> Result:
|
||||
"""Perform a EuroMillions draw."""
|
||||
numbers = random.sample(EuroMillions.POSSIBLE_NUMBERS, 5)
|
||||
bonus = random.sample(EuroMillions.POSSIBLE_BONUS_NUMBERS, 2)
|
||||
@@ -88,7 +88,7 @@ class SetForLife(Lottery):
|
||||
|
||||
POSSIBLE_NUMBERS = range(1, 40)
|
||||
|
||||
def draw(self):
|
||||
def draw(self) -> Result:
|
||||
"""Perform a Set For Life draw."""
|
||||
numbers = random.sample(SetForLife.POSSIBLE_NUMBERS, 5)
|
||||
life_ball = [random.randint(1, 10)]
|
||||
@@ -105,7 +105,7 @@ class Thunderball(Lottery):
|
||||
|
||||
POSSIBLE_NUMBERS = range(1, 40) # Thunderball numbers range from 1 to 39
|
||||
|
||||
def draw(self):
|
||||
def draw(self) -> Result:
|
||||
"""Perform a Thunderball draw."""
|
||||
numbers = random.sample(Thunderball.POSSIBLE_NUMBERS, 5)
|
||||
thunderball = [random.randint(1, 14)]
|
||||
|
||||
Reference in New Issue
Block a user