diff --git a/pyproject.toml b/pyproject.toml index 287ccca..55776a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,3 +39,7 @@ remove-unused-variables = true # remove unused variables [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + + +[tool.poetry.scripts] +telisar_calendar = "reckoning.calendar:main" diff --git a/reckoning/calendar.py b/reckoning/calendar.py index 80b0319..2e025ac 100644 --- a/reckoning/calendar.py +++ b/reckoning/calendar.py @@ -3,7 +3,10 @@ A Telisaran calendaring tool. """ from . import telisaran +from rich import print from rich.table import Table +from rich.columns import Columns +from rich.panel import Panel class TelisaranCalendar: @@ -36,20 +39,37 @@ class TelisaranCalendar: day=1 ) - @property - def season(self): - table = Table( - *[n[0:2] for n in telisaran.Day.names], - title=self._start.season.name.upper() - ) + def _season(self, season, long=False): + if long: + headers = season.day_names + title = f"Season of the {season.name}, Year {season.year}" + else: + headers = [n[0:2] for n in season.day_names] + title = season.name.upper() + table = Table(*headers, title=title) row = [] - for day in self._start.season.days: - row.append("{:02d}".format(day.day_of_season)) + for day in season.days: + if season == self.today.season and day.day_of_season == self.today.day.number: + row.append(f"[bold]{day.day_of_season:02d}[/bold]") + else: + row.append(f"{day.day_of_season:02d}") if day.day_of_span == telisaran.Span.length_in_days: table.add_row(*row) row = [] return table + @property + def season(self): + return self._season(self._start.season, long=True) + + @property + def calendar(self): + return Panel(Columns( + [self._season(season) for season in telisaran.today.year.seasons], + equal=True, + expand=True, + ), title="The Telisaran Calendar", highlight=True, width=120) + @property def yesterday(self): try: @@ -63,3 +83,12 @@ class TelisaranCalendar: def __repr__(self): return "The Telisaran Calendar" + + +def main(): + print(TelisaranCalendar().calendar) + print(TelisaranCalendar().season) + + +if __name__ == '__main__': + main() diff --git a/reckoning/telisaran.py b/reckoning/telisaran.py index fd024ba..b6747ed 100644 --- a/reckoning/telisaran.py +++ b/reckoning/telisaran.py @@ -487,6 +487,7 @@ class Season(DateObject): year (int): The year in which this season falls. """ names = ['Fox', 'Owl', 'Wolf', 'Eagle', 'Shark', 'Lion', 'Raven', 'Bear'] + day_names = Day.names length_in_spans = 9 length_in_days = length_in_spans * Span.length_in_days length_in_seconds = length_in_days * Day.length_in_seconds @@ -522,6 +523,16 @@ class Season(DateObject): return "Season of the {}".format(self.name) +class HuntDay(Day): + + names = [ + "Syf's Hunt", + "Mimir's Hunt", + "Woden's Hunt", + "Thorus's Hunt", + "Freya's Hunt" + ] + class FestivalOfTheHunt(Season): """ The 9th season, which only has 5 days, occurring at the end of each year. @@ -538,13 +549,7 @@ class FestivalOfTheHunt(Season): name (str): The name of this special season year (Year): The year in which this festival falls """ - day_names = [ - "Syf's Hunt", - "Mimir's Hunt", - "Woden's Hunt", - "Thorus's Hunt", - "Freya's Hunt" - ] + day_names = HuntDay.names length_in_spans = 1 length_in_days = 5 length_in_seconds = length_in_days * Day.length_in_seconds @@ -553,6 +558,8 @@ class FestivalOfTheHunt(Season): self.season_of_year = 9 self.year = year self._days = [] + for i in range(1, self.length_in_days + 1): + self._days.append(HuntDay(i, season=self)) @property def name(self):