Skip to main content

RPG Loot Drop Engine

Project description

RPG Loot Drop Engine

What started as a personal project of getting better at python and learning about lootboxes turned into something that might be useful to others.

These sites helped me understand the basic concept and mechanics of loot boxes/tables:

When I stumbled across this two article series, I was "Booyah!!!!". The original code was written in C#. This project is my resulting translation.

Differences between the original and this engine:

  • The flag always will always drop at least one item from a table or of that item. Initial testing showed that always would always drop one and only one. To always drop one and only one always and unique will both need to be true.
  • The Randomizer was not implemented
  • The IRDSObjectCreator and subsequent code was not implemented. I didn't see the need, based on what I was trying to do.

Install

pip install drop-generator

Sample code

from dropgen.RDSTable import RDSTable
from dropgen.RDSItem import RDSItem

if __name__ == '__main__':
    loot_table = RDSTable(count=5)

    loot_table.add_entry(RDSItem("Ham Sandwich"))
    loot_table.add_entry(RDSItem("Felt Hat"))
    loot_table.add_entry(RDSItem("Diamond Ring"))
    loot_table.add_entry(RDSItem("Red Brick"))
    loot_table.add_entry(RDSItem("Feral Cat"))
    loot_table.add_entry(RDSItem("Empty Flask"))
    loot_table.add_entry(RDSItem("Someone's garbage"))

    results = loot_table.rds_result

    print("Simple loot drop. Everything has the same chance")
    for result in results:
        print(f"\t{result}")

Code changes to try out

Flags can be set at RDSItem or RDSTable creation time or set/adjusted upon being added to the parent RDSTable.

loot_table.add_entry(RDSItem("Feral Cat", probability=5))

and

loot_table.add_entry(RDSItem("Feral Cat"), probability=5)

These two statements functionally achieve the same thing.

The flags you can set.

  • always: An item or item from a table will always drop at least once. If enough items/tables are marked with always, then actual drops could actually exceed what is defined (count)in the parent table.
  • unique: If the item is selected, then it will be dropped only once.
  • probability: The probability of the item dropping. Wikipedia
  • enabled: Will this item drop.

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

drop-generator-0.0.35.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drop_generator-0.0.35-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file drop-generator-0.0.35.tar.gz.

File metadata

  • Download URL: drop-generator-0.0.35.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for drop-generator-0.0.35.tar.gz
Algorithm Hash digest
SHA256 391a7dba1c74319b1cddffd4795de60649267f0e349d94b0cb73bf3a606061ed
MD5 132b75f8a9bb1160b0912da50ad75aff
BLAKE2b-256 e858a8a33ffa1c2cfa98bcc255cd5786632f1a72a52c9cd8d68308a8e88d28bd

See more details on using hashes here.

File details

Details for the file drop_generator-0.0.35-py3-none-any.whl.

File metadata

  • Download URL: drop_generator-0.0.35-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for drop_generator-0.0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 4e41c0dc8b34f1f5298675b4aee88803ddff9691b4f037cc29042e7945d6d751
MD5 a04fc2dce8a316aead577c42e938358c
BLAKE2b-256 2ccd96a6aee0a27fb7c9bf0e88ebb71718619621e362588c73ab0ebdfbe0553f

See more details on using hashes here.

Supported by

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