Skip to main content

CharObj

Description

CharObj is a package to allow for the creation/management of items for use in a text-based RPG game. It is designed to be used with the CharActor package, but can be used independently.

Installation

To install CharObj, use the following command:

pip install CharObj

Usage

CharObj can be used as a Python module or as a command-line tool.

Module

To use CharObj as a module, import it into your Python script:

import CharObj

Command-Line

To use CharObj as a command-line tool, use the following command:

python -m CharObj -h
# usage: CharObj [-h] {Get,Make} ...

# options:
#   -h, --help  show this help message and exit

# Commands:
#   {Get,Make}
#     Get       Gather information about an item by name or id
#     Make      Create an item

Examples

Module

Each already existing item is stored in its respective json file in the 'dict' directory. Upon importing the module items are accessible through the 'CharObj.Goods' or 'CharObj.Armory' classes. A new instance of the item can be created by simply calling its name as a function.

>>> import CharObj
# Create a new instance of an item
>>> gold_coin_1 = CharObj.Goods.goldcoin()
>>> gold_coin_2 = CharObj.Goods.goldcoin()
# Print the name of the item
>>> print(gold_coin_1.name)
Gold Coin
>>> print(gold_coin_2.name)
Gold Coin
# Check if the two items are the same
>>> print(gold_coin_1 == gold_coin_2)
False

Command-Line

Get

$ python -m CharObj Get 1
Gold Coin
{'binding': 'UNBOUND',
 'category': 'MISC',
 'description': 'A gold coin',
 'item_id': 1,
 'material': 'GOLD',
 'mundane': True,
 'name': 'Gold Coin',
 'quality': 'COMMON',
 'quest_item': False,
 'relic': False,
 'stackable': True,
 'value': [1, 'gp'],
 'weight': [0.01, 'kg']}

Make

The Make command can be used to create a new item. CharObj Make can be followed by the item's category. Each category can be executed with the -h flag to see the required arguments. The following example creates a new item in the 'Weapon' category.

$ python -m CharObj Make Weapon --item_name 'Dragonbone Blade' --slot MAIN_HAND --weight '3.5 kg' --material DRAGONBONE --mundane True --description 'A sharpened blade crafted from the bones of a defeated dragon.' --quality RARE --value '100 gp' --binding False --quest_item False --relic False --damage '1 d12' --damage_type SLASHING --range '5 FEET' --properties 'FINESSE LIGHT VERSATILE' --proficiency MARTIAL

Once made an item can be accessed in the same way as a pre-existing item, using the CLI ...

```bash
$ python -m CharObj Get 'Dragonbone_Blade'
```

Or the module ...

```python
>>> import CharObj
>>> dragonbone_blade = CharObj.Armory.dragonboneblade()
>>> print(dragonbone_blade.name)
```

Make can also be used interactively. The following example creates a new item in the 'Trade' category.

```bash
>>> python -m CharObj Make -i
Create an item?
Press enter to continue. Press Ctrl+C to cancel.
What category of item would you like to create?
Options: (a)rmor, (w)eapon, (g)eneral, (t)rade, (T)oolt
Creating Trade item.
item_name:  Brightsteel Ore
category:  ORE
weight:  0.5 kg
material:  BRIGHTSTEEL
mundane:  True
description:  A chunk of brightsteel ore.
quality:  COMMON
value:  5 gp
binding:  False
quest_item:  False
relic:  False
```

Release files for CharObj 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CharObj 0.2.1
File Size Uploaded
CharObj-0.2.1.tar.gz 24.9 kB Details

Release files / CharObj-0.2.1.tar.gz

Download URL CharObj-0.2.1.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7fc91e7926bfee411f6ed9dd7d6128745bafbbe889d1e617ae52ad56f1460798
BLAKE2b-256 checksum
How to use checksums
5dde44ac4e470057359926c91ec2aeb86f4425be16b656c4399a59ccd167fad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0b4+

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page