{"id":31807895,"url":"https://github.com/coffee-fueled-deadlines/pydnd","last_synced_at":"2025-10-11T04:38:50.025Z","repository":{"id":55143344,"uuid":"186937994","full_name":"Coffee-fueled-deadlines/PyDnD","owner":"Coffee-fueled-deadlines","description":"PyDnD is a Dungeons and Dragons SRD Library for Python3","archived":false,"fork":false,"pushed_at":"2024-09-07T21:19:26.000Z","size":97,"stargazers_count":27,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-09-08T21:36:29.824Z","etag":null,"topics":["dnd","dnd35","dungeons-and-dragons","pydnd","python","srd"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Coffee-fueled-deadlines.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"coffee_fueled_deadlines","open_collective":null,"ko_fi":"cfdeadlines","tidelift":null,"community_bridge":null,"custom":null}},"created_at":"2019-05-16T02:41:57.000Z","updated_at":"2024-09-07T21:18:12.000Z","dependencies_parsed_at":"2023-01-22T11:25:14.600Z","dependency_job_id":null,"html_url":"https://github.com/Coffee-fueled-deadlines/PyDnD","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Coffee-fueled-deadlines/PyDnD","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coffee-fueled-deadlines%2FPyDnD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coffee-fueled-deadlines%2FPyDnD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coffee-fueled-deadlines%2FPyDnD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coffee-fueled-deadlines%2FPyDnD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Coffee-fueled-deadlines","download_url":"https://codeload.github.com/Coffee-fueled-deadlines/PyDnD/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coffee-fueled-deadlines%2FPyDnD/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006244,"owners_count":26084061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dnd","dnd35","dungeons-and-dragons","pydnd","python","srd"],"created_at":"2025-10-11T04:38:44.389Z","updated_at":"2025-10-11T04:38:50.016Z","avatar_url":"https://github.com/Coffee-fueled-deadlines.png","language":"Python","funding_links":["https://patreon.com/coffee_fueled_deadlines","https://ko-fi.com/cfdeadlines"],"categories":[],"sub_categories":[],"readme":"# PyDnD\n\n**Description**:\nPython Dungeons and Dragons Library utilizing SRD\n\n**Status**:\nIncomplete/In-Development\n\n**Last Update**\n2024-09-02\n\n**Version**\n1.0.0\n\n**Note**: If you like and/or want to use this, a star or a follow would be appreciated. \n\n## Example Invocation\n\n```python\nfrom PyDnD import Player\n\nif __name__ == '__main__':\n\t\t\n\tnewPlayer = Player(name='Thor Odinson', age='34', gender='Male', description='Looks like a pirate angel', biography='Born on Asgard, God of Thunder')\n\t\t\n\t# newPlayer is created, lets display some stats\n\tprint( \"Name:\" + newPlayer.name )\n\tprint( \"Age: \" +newPlayer.age)\n\tprint( \"Gender:\" + newPlayer.gender )\n\tprint( \"Description: \" + newPlayer.description )\n\tprint( \"Biography: \" + newPlayer.biography )\n\tprint( \"\\n\" )\n\t\n\tprint( \"\\tLevel: \" + str( newPlayer.level ) ) # Level isn't specified in creation, so level is 1\n\tprint( \"\\tCurrent Experience: \" + str( newPlayer.experience ) ) # Level wasn't specified, so current xp is 0\n\tprint( \"\\tEXP to next Level: \" + str( newPlayer.nextLvlExperience ) ) # 1000 Experience is required to get to level 2\n\tprint( \"\\n\\t--Stats--\\n\")\n\tprint( \"\\t\\tStrength is: \" + str( newPlayer.strength ))\n\tprint( \"\\t\\tDexterity is: \" + str( newPlayer.dexterity ))\n\tprint( \"\\t\\tConstitution is: \" + str( newPlayer.constitution ))\n\tprint( \"\\t\\tWisdom is: \" + str( newPlayer.wisdom ))\n\tprint( \"\\t\\tIntelligence is: \" + str( newPlayer.intelligence ))\n\tprint( \"\\t\\tCharisma is: \" + str( newPlayer.charisma ))\n\tprint( \"\\n\\t--Inventory--\\n\" )\n\n\t# Lets give Thor his hammer\n\tnewPlayer.add_item_to_inventory(\"Mjolnir\")\n\tprint( f\"\\t\\tThor's inventory is: \\n\\t\\t\\t{newPlayer.get_inventory()}\\n\" )\n\t\n\t# Oh no he's not worthy\n\tnewPlayer.remove_item_from_inventory(\"Mjolnir\")\n\tprint( f\"\\t\\tThor's inventory is: \\n\\t\\t\\t{newPlayer.get_inventory()}\\n\" )\n\tprint( \"\\n\" )\n\n\tprint( \"LEVEL UP\")\n\n\tprint(\"\\n\\n\")\n\t# Lets see what Thor looks like as a level 2\n\tnewPlayer.giveExp(1000)\n\tprint( \"\\tNew Level: \" + str( newPlayer.level ) ) # newPlayer.level is automatically increased when XP threshold increases\n\tprint( \"\\tCurrent Experience: \" + str( newPlayer.experience ) ) # Current, experience after leveling up\n\tprint( \"\\tEXP to next Level: \" + str( newPlayer.nextLvlExperience ) ) # 3000 Experience total is required to get to level 3\n\tprint( \"\\n\\t--Stats--\\n\")\n\tprint( \"\\t\\tStrength is: \" + str( newPlayer.strength ))\n\tprint( \"\\t\\tDexterity is: \" + str( newPlayer.dexterity ))\n\tprint( \"\\t\\tConstitution is: \" + str( newPlayer.constitution ))\n\tprint( \"\\t\\tWisdom is: \" + str( newPlayer.wisdom ))\n\tprint( \"\\t\\tIntelligence is: \" + str( newPlayer.intelligence ))\n\tprint( \"\\t\\tCharisma is: \" + str( newPlayer.charisma ))\n\tprint( \"\\n\\t--Inventory--\\n\" )\n\n\t# Lets give Thor back his hammer\n\tnewPlayer.add_item_to_inventory(\"Mjolnir\")\n\tprint( f\"\\t\\tThor's inventory is: \\n\\t\\t\\t{newPlayer.get_inventory()}\\n\" )\n\t\n\t# Oh no he's not worthy again\n\tnewPlayer.remove_item_from_inventory(\"Mjolnir\")\n\tprint( f\"\\t\\tThor's inventory is: \\n\\t\\t\\t{newPlayer.get_inventory()}\\n\" )\n\tprint(\"\\n\\n\")\n\n\tprint( \"LEVEL DOWN\")\n\n\tprint(\"\\n\\n\")\n\t# Lets take away some of Thor's Experience\n\tnewPlayer.removeExp(500)\n\tprint( \"\\tNew Level: \" + str( newPlayer.level ) ) # newPlayer.level is automatically decreased when XP threshold decreases\n\tprint( \"\\tCurrent Experience: \" + str( newPlayer.experience ) ) # Current, experience after leveling down\n\tprint( \"\\tEXP to next Level: \" + str( newPlayer.nextLvlExperience ) ) # 500 Experience total is required to get to level 2\n\tprint( \"\\n\\t--Stats--\\n\")\n\tprint( \"\\t\\tStrength is: \" + str( newPlayer.strength ))\n\tprint( \"\\t\\tDexterity is: \" + str( newPlayer.dexterity ))\n\tprint( \"\\t\\tConstitution is: \" + str( newPlayer.constitution ))\n\tprint( \"\\t\\tWisdom is: \" + str( newPlayer.wisdom ))\n\tprint( \"\\t\\tIntelligence is: \" + str( newPlayer.intelligence ))\n\tprint( \"\\t\\tCharisma is: \" + str( newPlayer.charisma ))\n\tprint( \"\\n\\t--Inventory--\\n\" )\n\n\t# Lets give Thor back his hammer\n\tnewPlayer.add_item_to_inventory(\"Mjolnir\")\n\tprint( f\"\\t\\tThor's inventory is: \\n\\t\\t\\t{newPlayer.get_inventory()}\\n\" )\n\t\n\t# Oh no he's not worthy again\n\tnewPlayer.remove_item_from_inventory(\"Mjolnir\")\n\tprint( f\"\\t\\tThor's inventory is: \\n\\t\\t\\t{newPlayer.get_inventory()}\\n\" )\n\tprint(\"\\n\\n\")\n  ```\n***\n\n## Player Object\n\n  The Player Object is the core of this library and should not be omitted (unless you're just using PyDnD for the Dice roller).  All arguments for the player object technically can be omitted (and added later) to create a blank, level 1 character.  However, we recommend at least giving the player object a `name`.  When Initializing the object, it's important to key the arguments with their corresponding argument name (listed below).\n  \n#### Player Object — Arguments\n```\nname           (str): Player character's name\nage            (str): Player character's age\ngender         (str): Player character's gender\nalignment      (str): Player character's two letter alignment\ndescription    (str): Physical description of Player character\nbiography      (str): Backstory of Player character\t\nlevel          (int): Player character's starting level\nwealth         (int): Player character's starting wealth\t\nstrength       (int): Player character's starting strength Ability Score\ndexterity      (int): Player character's starting dexterity Ability Score\nconstitution   (int): Player character's starting constitution Ability Score\nwisdom         (int): Player character's starting wisdom Ability Score\nintelligence   (int): Player character's starting intelligence Ability Score\ncharisma       (int): Player character's starting charisma Ability Score\nhp             (int): Player character's starting hitpoint value\nmp             (int): Player character's starting mp value (may convert to SPD)\ninventory_size (int): Player character's inventory size\n```\n\n#### Examples\n```python\nfrom PyDnD import Player\n\n# Initialize the player object with some useful, accurate information\nmyPlayer = Player(name        = 'John Cougar Mellencamp',\n\t\t  age         = '900',\n\t\t  gender      = 'Male',\n\t\t  alignment   = 'CG',\n\t\t  description = 'Looks like an old musician',\n\t\t  biography   = 'Is an old musician reknown for his one good song',\n\t\t  level       = 1,\n\t\t  wealth      = 100)\t  \n\t\t  \n# Did we put the wrong name?  That's okay!  We can change it\nmyPlayer.name = 'Meatloaf'\n```\n***\n\n## Experience and Levels\n\n  Experience has multiple methods in this library.  However, only two of them should ever be directly called.  These two methods would be `object.giveExp(amount)` and `object.removeExp(amount)`.  The rest of the Experience and Level system is automated and updated anytime experience is awarded or removed.  If you wish to get the current experience of the player, use `object.experience` to display the integer value of it.\n\n#### Examples\n```python\n# Set Player Object\nnewPlayer = Player(name='Bob Ross',\n\t\t   level=1)\n\n# Current Experience\nprint(\"Current Experience:\", newPlayer.experience)\n\n# Experience until next level\nprint(\"Experience until Level Up:\", newPlayer.nextLvlExperience)\n\n# Give experience\nnewPlayer.giveExp(100)\n\n# Display new, updated Experience\nprint(\"Current Experience:\", newPlayer.experience)\n\n# Display new, updated Experience until next level\nprint(\"Experience until Level Up:\", newPlayer.nextLvlExperience)\n\n# Display players current level\nprint(\"Current Level:\", newPlayer.level)\n\n# Lets level up the player\nnewPlayer.giveExp(1000) # required Exp to reach level 2\nprint(\"Current Level:\", newPlayer.level)\nprint(\"Current Experience:\", newPlayer.experience)\nprint(\"Experience until Level Up:\", newPlayer.nextLvlExperience)\n```\n***\n\n## Inventory\n\n  The new inventory system is a tad bit more robust than the previous implementation, although it's still quite primitive and not necessarily related to inventory management in true SRD at all.  Instead, I allow the creator to set an `inventory_size` argument in the `Player` object upon initialization.  If it is not set, `inventory_size` will default to `10`.\n\n### Examples\n```python\n# Lets create our Character\ntheBagMan = Player(name=\"The Bagman\", inventory_size=10)\nprint(f\"Player Name: {theBagMan.name}\")\nprint(f\"Player Inventory Size: {theBagMan.get_inventory_max_size()}\")\n\n# Our inventory comes nice and empty\nprint(f\"Items in inventory: {theBagMan.get_inventory()}\")\n\n# Lets give The Bagman some stuff\ntheBagMan.add_item_to_inventory(\"Health Potion\")\nprint(f\"Items in inventory: {theBagMan.get_inventory()}\") # Our inventory now has a potion\n\n# Lets remove that potion\ntheBagMan.remove_item_from_inventory(\"Health Potion\")\nprint(f\"Items in inventory: {theBagMan.get_inventory()}\") # Bye bye\n```\n***\n\n## Roll and Dice\n\n  `Roll` and `Dice` are two new Modules in the PyDnD package.  The `Roll` module makes use of the `Dice` module, meaning that generally you won't or shouldn't interact directly with the `Dice` module itself.  Below are some examples of how to roll different types of dice.\n\n### Examples\n```python\nfrom PyDnD import Roll\n\n# Lets roll a D20\nprint( Roll.roll(num_dice=1, sides=20) )\n\n# Lets roll 2 D20\nprint( Roll.roll(num_dice=2, sides=20) )\n\n# Lets add a modifier\nprint( Roll.roll(num_dice=2, sides=20, modifier=4) )\n\n# Lets roll a Stat using 4d6 and drop the lowest one\nstrength_stat = Roll.roll(num_dice=4, sides=6, drop_lowest=1)\nprint( f\"Strength Stat is: {strength_stat}\" )\n\n# Now lets say that we want to see each of those rolls\n# Lets tell the roller\nstrength_stat = Roll.roll(num_dice=4, sides=6, drop_lowest=1, return_rolls=True)\nprint( f\"Strength Stat is: {strength_stat[0]} and the rolls where: {strength_stat[1]}\" )\n```\n***\n\n## Serialization/Deserialization (JSON)\n\n  PyDnD now supports JSON Serialization and Deserialization (This means that you can easily export your character to and from a .json file).  Below are some examples of how to Serialize a character:\n\n### Examples\n```python\n# Example of JSON Serialization\n\nfrom PyDnD import Player\n\n# Lets make a new Character\nnewPlayer = Player(name='Thor Odinson', age='34', gender='Male', description='Looks like a pirate angel', biography='Born on Asgard, God of Thunder')\n\n# Lets display some info\nprint( \"Name:\" + newPlayer.name )\nprint( \"Age: \" +newPlayer.age)\nprint( \"Gender:\" + newPlayer.gender )\nprint( \"Description: \" + newPlayer.description )\nprint( \"Biography: \" + newPlayer.biography )\n\n# Lets save this character to a .json file\nnewPlayer.serialize_to_json(\"./path/to/newPlayer.json\")\n```\n\n  Below is an example of deserialization from that same file:\n\n```python\n# Lets load our player from json\nnewPlayer = Player().deserialize_from_json(\"./path/to/newPlayer.json\")\n\n# Lets display some info\nprint( \"Name:\" + newPlayer.name )\nprint( \"Age: \" +newPlayer.age)\nprint( \"Gender:\" + newPlayer.gender )\nprint( \"Description: \" + newPlayer.description )\nprint( \"Biography: \" + newPlayer.biography )\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoffee-fueled-deadlines%2Fpydnd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoffee-fueled-deadlines%2Fpydnd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoffee-fueled-deadlines%2Fpydnd/lists"}