Skip to content

Commit

Permalink
Merge pull request #53 from mmacy/items-in-treasure
Browse files Browse the repository at this point in the history
Items in treasure
  • Loading branch information
mmacy committed Feb 14, 2024
2 parents 8b7ed6b + c750b81 commit dbfdd33
Show file tree
Hide file tree
Showing 40 changed files with 340 additions and 312 deletions.
1 change: 0 additions & 1 deletion docs/reference/game_manager.md

This file was deleted.

1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ nav:
- dungeon_assistant: reference/dungeon_assistant.md
- encounter: reference/encounter.md
- enums: reference/enums.md
- game_manager: reference/game_manager.md
- inventory: reference/inventory.md
- item: reference/item.md
- item_factories: reference/item_factories.md
Expand Down
6 changes: 3 additions & 3 deletions osrgame/osrgame/osrgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from osrlib.constants import ADVENTURE_NAMES, DUNGEON_NAMES
from osrlib.dungeon import Dungeon
from osrlib.dungeon_assistant import DungeonAssistant
from osrlib.game_manager import logger
from osrlib.party import get_default_party
from osrlib.utils import logger
from osrlib.party import Party
from osrlib.enums import OpenAIModelVersion


Expand Down Expand Up @@ -86,7 +86,7 @@ def set_active_adventure(self, adventure: Adventure = None) -> None:

default_adventure.add_dungeon(dungeon)
default_adventure.set_active_dungeon(dungeon)
default_adventure.set_active_party(get_default_party())
default_adventure.set_active_party(Party.get_default_party())
self.adventure = default_adventure

def start_session(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion osrgame/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion osrlib/osrlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""OSR Library is a Python library for powering old-school turn-based role-playing games (OSRPGs)."""
"""Python library for powering old-school turn-based role-playing games."""
54 changes: 27 additions & 27 deletions osrlib/osrlib/ability.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
"""Defines `PlayerCharacter` abilities and their modifiers.
Abilities are inherent traits that every [PlayerCharacter][osrlib.player_character.PlayerCharacter] possesses in
varying degrees. They provide different modifiers (bonuses or penalties) that can affect gameplay mechanics like dice
rolls during game play or core aspects of the character like whether they're especially hard to hit (lower AC) because
of a high [Dexterity][osrlib.ability.Dexterity] score or whether they know additional languages because of a high
An [Ability][osrlib.ability.Ability] is an inherent trait possessed by every
[PlayerCharacter][osrlib.player_character.PlayerCharacter]. There are several ability types, each of which can provide
modifiers (bonuses or penalties) that affect gameplay mechanics like dice rolls or other properties of the character.
For example, a high [Dexterity][osrlib.ability.Dexterity] score can make the character harder to hit in combat due to
an AC modifier, and the character might know an additional language or two because they also have a high
[Intelligence][osrlib.ability.Intelligence] score.
## Usage:
You typically wouldn't create an instance of an [Ability][osrlib.ability.Ability] directly. Instead, you create an
instance of [PlayerCharacter][osrlib.player_character.PlayerCharacter], and its abilities are instantiated as attributes
of the `PlayerCharacter` instance automatically. You can then "roll" the character's ability scores by calling a method
on `PlayerCharacter`.
```python
---8<--- "tests/test_doc_player_character.py:player_character_create"
```
"""

from abc import ABC, abstractmethod
Expand Down Expand Up @@ -152,12 +162,11 @@ def _init_modifiers(self) -> None:
"""Initialize Strength-specific ability modifiers.
Modifiers:
- TO_HIT (ModifierType.TO_HIT): Modifies melee (hand-to-hand) attack rolls.
- DAMAGE (ModifierType.DAMAGE): Modifies damage in melee combat.
- OPEN_DOORS (ModifierType.OPEN_DOORS): Modifies chances of opening stuck doors.
Each modifier is calculated based on the strength score of the character.
Each modifier is calculated based on the Strength score of the character.
"""
self.modifiers[ModifierType.TO_HIT] = self._get_modifier()
self.modifiers[ModifierType.DAMAGE] = self._get_modifier()
Expand All @@ -171,9 +180,7 @@ class Intelligence(Ability):
magical aptitude.
Modifiers:
- LANGUAGES (ModifierType.LANGUAGES): Modifies the number of additional languages the
character can read and write.
- LANGUAGES (ModifierType.LANGUAGES): Modifies the number of additional languages the character can read and write.
"""

def __init__(self, score: int):
Expand Down Expand Up @@ -203,11 +210,10 @@ def _init_modifiers(self) -> None:
"""Initialize Intelligence-specific ability modifiers.
Modifiers:
- LANGUAGES (ModifierType.LANGUAGES): Modifies the number of additional languages
the character can read and write.
The modifier is calculated based on the intelligence score of the character.
The modifier is calculated based on the Intelligence score of the character.
"""
self.modifiers[ModifierType.LANGUAGES] = self._get_modifier()

Expand All @@ -218,9 +224,7 @@ class Wisdom(Ability):
Wisdom measures a character's common sense, intuition, and willpower.
Modifiers:
- SAVING_THROWS (ModifierType.SAVING_THROWS): Modifies saving throws against spells and
magical effects.
- SAVING_THROWS (ModifierType.SAVING_THROWS): Modifies saving throws against spells and magical effects.
"""

def __init__(self, score: int):
Expand All @@ -237,10 +241,9 @@ def _init_modifiers(self) -> None:
"""Initialize Wisdom-specific ability modifiers.
Modifiers:
SAVING_THROWS (ModifierType.SAVING_THROWS): Modifies saving throws against spells
and magical effects.
SAVING_THROWS (ModifierType.SAVING_THROWS): Modifies saving throws against spells and magical effects.
Each modifier is calculated based on the wisdom score of the character.
Each modifier is calculated based on the Wisdom score of the character.
"""
self.modifiers[ModifierType.SAVING_THROWS] = self._get_modifier()

Expand Down Expand Up @@ -295,12 +298,11 @@ def _init_modifiers(self) -> None:
"""Initialize Dexterity-specific ability modifiers.
Modifiers:
- TO_HIT (ModifierType.TO_HIT): Modifies ranged attack rolls.
- AC (ModifierType.AC): Modifies armor class (lower is better).
- INITIATIVE (ModifierType.INITIATIVE): Modifies initiative rolls.
Each modifier is calculated based on the dexterity score of the character.
Each modifier is calculated based on the Dexterity score of the character.
"""
self.modifiers[ModifierType.AC] = -self._get_modifier()
self.modifiers[ModifierType.TO_HIT] = self._get_modifier()
Expand All @@ -314,8 +316,8 @@ class Constitution(Ability):
Modifiers:
- HP (ModifierType.HP): Modifies hit point (HP) rolls. For example, when initially rolling the
character or when the character gains a level.
- HP (ModifierType.HP): Modifies hit point (HP) rolls. For example, when initially rolling the character or when the
character gains a level.
"""

def __init__(self, score: int):
Expand All @@ -331,10 +333,10 @@ def _init_modifiers(self) -> None:
"""Initialize Constitution-specific ability modifiers.
Modifiers:
HP (ModifierType.HP): Modifies hit point (HP) rolls. For example, when initially rolling
the character or when the character gains a level.
HP (ModifierType.HP): Modifies hit point (HP) rolls. For example, when initially rolling the character or
when the character gains a level.
The modifier is calculated based on the constitution score of the character.
The modifier is calculated based on the Constitution score of the character.
"""
self.modifiers[ModifierType.HP] = self._get_modifier()

Expand All @@ -345,7 +347,6 @@ class Charisma(Ability):
Charisma measures force of personality, leadership ability, and physical attractiveness.
Modifiers:
- REACTION (ModifierType.REACTION): Modifies reaction rolls when interacting with NPCs.
"""

Expand Down Expand Up @@ -378,9 +379,8 @@ def _init_modifiers(self) -> None:
"""Initialize Charisma-specific ability modifiers.
Modifiers:
- REACTION (ModifierType.REACTION): Modifies reaction rolls when interacting with NPCs.
The modifier is calculated based on the charisma score of the character.
The modifier is calculated based on the Charisma score of the character.
"""
self.modifiers[ModifierType.REACTION] = self._get_modifier()
2 changes: 1 addition & 1 deletion osrlib/osrlib/adventure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DungeonAlreadyExistsError: Raised for duplicate dungeon additions.
"""
import json, os, datetime
from osrlib.game_manager import logger
from osrlib.utils import logger
from osrlib.dungeon import Dungeon
from osrlib.party import Party
from osrlib.quest import Quest
Expand Down
2 changes: 1 addition & 1 deletion osrlib/osrlib/character_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from osrlib.dice_roller import DiceRoll, roll_dice
from osrlib.enums import CharacterClassType
from osrlib.saving_throws import get_saving_throws_for_class_and_level
from osrlib.game_manager import logger
from osrlib.utils import logger


class ClassLevel:
Expand Down
2 changes: 1 addition & 1 deletion osrlib/osrlib/dungeon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import random, json, uuid
from openai import OpenAI
from osrlib.enums import Direction, OpenAIModelVersion
from osrlib.game_manager import logger
from osrlib.utils import logger
from osrlib.encounter import Encounter
from osrlib.dice_roller import roll_dice

Expand Down
3 changes: 1 addition & 2 deletions osrlib/osrlib/dungeon_assistant.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""The `dungeon_assistant` module contains the `DungeonAssistant` class that interfaces with the OpenAI API and performs the duties of the game's referee and guide (*game master* or *dungeon master* in some tabletop RPGs)."""

import asyncio
from openai import OpenAI
from osrlib.adventure import Adventure
from osrlib.enums import OpenAIModelVersion
from osrlib.game_manager import logger
from osrlib.utils import logger


dm_init_message = (
Expand Down
2 changes: 1 addition & 1 deletion osrlib/osrlib/encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from osrlib.party import Party
from osrlib.monster import MonsterParty
from osrlib.monster_manual import monster_stats_blocks
from osrlib.game_manager import logger, last_message_handler as pylog
from osrlib.utils import logger, last_message_handler as pylog
from osrlib.dice_roller import roll_dice
from osrlib.treasure import Treasure, TreasureType

Expand Down
51 changes: 0 additions & 51 deletions osrlib/osrlib/game_manager.py

This file was deleted.

2 changes: 1 addition & 1 deletion osrlib/osrlib/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Inventory:
```
"""
def __init__(self, player_character_owner: "PlayerCharacter"):
"""Creates a `PlayerCharacter` instance.
"""Creates an `Inventory` instance and assigns the specified `PlayerCharacter` as its owner.
Args:
player_character_owner (PlayerCharacter): The player character that owns the inventory.
Expand Down
Loading

0 comments on commit dbfdd33

Please sign in to comment.