This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# combat_system.py | |
import logging | |
from datetime import timedelta # Needed for advancing game clock | |
# Assuming GameClock and Player will be passed in from main.py | |
# We won't import them directly here to avoid circular dependencies. | |
# Instead, the CombatSystem will receive instances of them. | |
# Configure logging for this module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
import logging | |
from datetime import datetime, timedelta | |
from typing import Optional | |
from astral import LocationInfo, sun, moon | |
import pytz # python time zones | |
from enum import Enum | |
from combat import CombatSystem, Monster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from enum import Enum, auto | |
# We only need one Enum to represent the stats internally. | |
class PlayerStat(Enum): | |
CHARISMA = auto() | |
CONSTITUTION = auto() | |
DEXTERITY = auto() | |
INTELLIGENCE = auto() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import random | |
from dataclasses import dataclass | |
from datetime import datetime, timedelta | |
from enum import Enum, auto, StrEnum | |
import textwrap | |
import doctest | |
class Translation(Enum): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kwargs practice | |
import logging | |
from enum import Enum, Flag | |
from typing import Callable, Optional | |
# original code: | |
# https://github.com/Pinacolada64/TADA/blob/e54fc3bb2ff14bae731942d24ce5addb96616216/server/text_editor.py | |
class DefaultLineRange(Enum): | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def time_delta_in_words(d1: datetime, d2: datetime): | |
years = abs(d1.year - d2.year) | |
months = abs(d1.month - d2.month) | |
# if d1.month - d2.month < 12 then less than an entire year between events. therefore subtract a year | |
if months < 12: | |
years -= 1 | |
print(f"less than 12 months between deltas, years now {years=}") | |
days = abs(d1.day - d2.day) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, Any | |
class Item: | |
def __init__(self, item_id: int, name: str, description: str, owner: Optional[None], prefix: str = "I"): | |
self.prefix = prefix | |
self.item_id = item_id | |
self.owner = owner # TODO: can be a Player, but moving this after Player breaks inheritance | |
self.name = name | |
self.description = description |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import random | |
from typing import Optional | |
from enum import Enum | |
# Dungeon map configuration | |
DUNGEON_SIZE = 20 | |
REVEAL_RADIUS = 2 | |
dungeon = [['.' for _ in range(DUNGEON_SIZE)] for _ in range(DUNGEON_SIZE)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
# Define your custom codec | |
class SimpleCodec(codecs.Codec): | |
def encode(self, input, errors='strict'): | |
# For simplicity, encoding is just the reverse. | |
return input[::-1], len(input) | |
def decode(self, input, errors='strict'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import enum | |
import logging | |
from dataclasses import dataclass | |
from enum import Enum | |
import codecs | |
import cbmcodecs2 | |
from colorama import init, Fore |
NewerOlder