Skip to main content

A Text Engine for Text Stories

Project description

banner version pure python

Text Engine

Description

Text engine is an engine for creating text adventure games. It has utilities to help greatly improve efficiency and time. Its a pure python package, built for scalability and usability. It is designed for you to build apon the engine, creating whatever type of text adventure you want!


Features

Name Description
Entity A Basic living thing
Person An extension of Entity, has a built in inventory system and dialog system
Item A Basic item, you can stack them up till a customizable limit
Iteraction Interact between two people, remove or give items between people

Example Usage

Example 1: Using the Item and Stack Classes

from items import Item, Stack

# Create an iron sword item with a custom description
iron_sword = Item("Iron Sword", "A sturdy weapon made of iron.", stack_size=1)

# Create a stack of apples
apple = Item("Apple")
apple_stack = Stack(apple, stack_size=10)
apple_stack.push(5)

# Print the current stack size of the apple stack
print(f"Current stack size of apples: {len(apple_stack)}")

Example 2: Interacting with Characters and Inventory

from interaction import Interaction
from character import Person
from items import Item

# Create a character named "Player" with a custom inventory size and description
player = Person("Player", "A skilled adventurer.", (255, 255, 255), health=100, armor=50, inventory_size=20)

# Create a health potion item
health_potion = Item("Health Potion", "Restores health when consumed.")
health_potion_stack = Stack(health_potion, stack_size=5)

# Give the player a health potion
Interaction.give_item(player, health_potion)

# Try to give the player another health potion (inventory is full)
try:
    Interaction.give_item(player, health_potion)
except FullInventory as e:
    print(e)

# Take a health potion from the player's inventory
Interaction.take_item(player, health_potion)

# Try to take more health potions than available (error)
try:
    Interaction.take_item(player, health_potion, amount=3)
except ItemNotInInventory as e:
    print(e)

Example 3: Using Text Output for Character Interaction

from character import Person
from text import Text

# Create a character named "NPC" with a custom text color
npc = Person("NPC", "A friendly villager.", (0, 128, 0), health=80, armor=20)

# Create a text instance with custom color
text_handler = Text((255, 165, 0))

# Make the NPC say a message using colored text output
text_handler.say(npc.get_name(), "Hello, traveler! Welcome to our village.")

# Create a player character and make them say a message
player = Person("Player", "An adventurous soul.", (0, 0, 255), health=120, armor=60)
text_handler.say(player.get_name(), "Greetings! Thank you for your warm welcome.")

Contributing

We welcome contributions to improve Text Engine. If you'd like to contribute, please follow these guidelines:

  1. Fork the repository and create a new branch for your contributions.
  2. Make your changes or additions in your branch.
  3. Clearly describe your changes in your commits and pull request.
  4. Ensure your code follows the existing style and conventions of the project.
  5. Update any relevant documentation to reflect your changes.
  6. Open a pull request, providing a detailed description of your changes.

Example of Changes

When contributing, please list your changes or additions in your pull request. Here's an example of how your pull request message could be structured:

### Changes/Additions

- Added a new class `NewFeature` in `module.py`.
- Updated the `function_name` method to include additional parameters.
- Fixed a bug in `another_module.py` where values were not properly validated.

This project is licensed under the Apache V2 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TAE-1.0.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

TAE-1.0.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file TAE-1.0.1.tar.gz.

File metadata

  • Download URL: TAE-1.0.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for TAE-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9c54d347e02e4bd5a540f93d67c98e4482688909bdb02d099c61eaad85c075c1
MD5 9667837adfd5e1bdb7209d0d5b085f06
BLAKE2b-256 89a8063b26dc787c3e1e35e32d839e1f1b3def46442426068bba20b4de5f1939

See more details on using hashes here.

File details

Details for the file TAE-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: TAE-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for TAE-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a640dd108aab2b6815532fabede719396da581d3f05beee1c9f1ed812021120
MD5 9b813df40616fc28a5196f96b811b43e
BLAKE2b-256 6eff2a33ad973f6328ef92cc1a83e1309aad59751c4dc907c2efea981e63420e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page