CharObj


NameCharObj JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/primal-coder/CharObj
SummaryA package for creating objects for a text-based RPG
upload_time2023-11-25 19:24:35
maintainer
docs_urlNone
authorJames Evans
requires_python>=3.7
licenseMIT
keywords game development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/primal-coder/CharActor) package, but can be used independently.

## Installation
To install CharObj, use the following command:

```bash
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:

```python
import CharObj
```

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

```bash
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.


```python
>>> 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
```bash
$ 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.

```bash
$ 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
    ```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/primal-coder/CharObj",
    "name": "CharObj",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "game development",
    "author": "James Evans",
    "author_email": "joesaysahoy@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5d/de/44ac4e470057359926c91ec2aeb86f4425be16b656c4399a59ccd167fad7/CharObj-0.2.1.tar.gz",
    "platform": null,
    "description": "# CharObj\n## Description\nCharObj 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](https://github.com/primal-coder/CharActor) package, but can be used independently.\n\n## Installation\nTo install CharObj, use the following command:\n\n```bash\npip install CharObj\n```\n\n## Usage\nCharObj can be used as a Python module or as a command-line tool.\n\n### Module\nTo use CharObj as a module, import it into your Python script:\n\n```python\nimport CharObj\n```\n\n### Command-Line\nTo use CharObj as a command-line tool, use the following command:\n\n```bash\npython -m CharObj -h\n# usage: CharObj [-h] {Get,Make} ...\n\n# options:\n#   -h, --help  show this help message and exit\n\n# Commands:\n#   {Get,Make}\n#     Get       Gather information about an item by name or id\n#     Make      Create an item\n```\n\n## Examples\n\n### Module\n\nEach 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.\n\n\n```python\n>>> import CharObj\n# Create a new instance of an item\n>>> gold_coin_1 = CharObj.Goods.goldcoin()\n>>> gold_coin_2 = CharObj.Goods.goldcoin()\n# Print the name of the item\n>>> print(gold_coin_1.name)\nGold Coin\n>>> print(gold_coin_2.name)\nGold Coin\n# Check if the two items are the same\n>>> print(gold_coin_1 == gold_coin_2)\nFalse\n```\n\n### Command-Line\n\n# Get\n```bash\n$ python -m CharObj Get 1\nGold Coin\n{'binding': 'UNBOUND',\n 'category': 'MISC',\n 'description': 'A gold coin',\n 'item_id': 1,\n 'material': 'GOLD',\n 'mundane': True,\n 'name': 'Gold Coin',\n 'quality': 'COMMON',\n 'quest_item': False,\n 'relic': False,\n 'stackable': True,\n 'value': [1, 'gp'],\n 'weight': [0.01, 'kg']}\n```\n\n# Make\n\nThe 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.\n\n```bash\n$ 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\n```\n\nOnce made an item can be accessed in the same way as a pre-existing item, using the CLI ...\n    \n    ```bash\n    $ python -m CharObj Get 'Dragonbone_Blade'\n    ```\n\nOr the module ...\n\n    ```python\n    >>> import CharObj\n    >>> dragonbone_blade = CharObj.Armory.dragonboneblade()\n    >>> print(dragonbone_blade.name)\n    ```\n\nMake can also be used interactively. The following example creates a new item in the 'Trade' category.\n\n    ```bash\n    >>> python -m CharObj Make -i\n    Create an item?\n    Press enter to continue. Press Ctrl+C to cancel.\n    What category of item would you like to create?\n    Options: (a)rmor, (w)eapon, (g)eneral, (t)rade, (T)oolt\n    Creating Trade item.\n    item_name:  Brightsteel Ore\n    category:  ORE\n    weight:  0.5 kg\n    material:  BRIGHTSTEEL\n    mundane:  True\n    description:  A chunk of brightsteel ore.\n    quality:  COMMON\n    value:  5 gp\n    binding:  False\n    quest_item:  False\n    relic:  False\n    ```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package for creating objects for a text-based RPG",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/primal-coder/CharObj"
    },
    "split_keywords": [
        "game",
        "development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5dde44ac4e470057359926c91ec2aeb86f4425be16b656c4399a59ccd167fad7",
                "md5": "38266b5fd1970646eb04f203c3fdab8c",
                "sha256": "7fc91e7926bfee411f6ed9dd7d6128745bafbbe889d1e617ae52ad56f1460798"
            },
            "downloads": -1,
            "filename": "CharObj-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "38266b5fd1970646eb04f203c3fdab8c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 24929,
            "upload_time": "2023-11-25T19:24:35",
            "upload_time_iso_8601": "2023-11-25T19:24:35.123252Z",
            "url": "https://files.pythonhosted.org/packages/5d/de/44ac4e470057359926c91ec2aeb86f4425be16b656c4399a59ccd167fad7/CharObj-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-25 19:24:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "primal-coder",
    "github_project": "CharObj",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "charobj"
}
        
Elapsed time: 0.16388s