Skip to main content

A library for creating spell card images for the game Wizard101

Reason this release was yanked:

Bugged builds

Project description

Notes

This is the library for creating spell card images for the game Wizard101. There is an example python script at the root literally named example.py, however for api layout simply look in spellgen.pyi

TODO

  • Add multi spell image support (remember that KI's version for some reason renders above the border...)
  • Figure out issue with over time icon and parenthasees

API Documentation

SpellCard Class

The SpellCard class represents a spell card with all its properties.

Constructor Arguments

  • title (str): The title/name of the spell (default: "")
  • description (str): The description text of the spell (default: "")
  • description_alignment (TextAlignment): Alignment of the description text (default: TextAlignment.center())
  • frame (str|None): Path to the frame image file (default: None)
  • spell_image (str|None): Path to the main spell image file (default: None)
  • additional_spell_images (list|None): List of paths to additional spell images (default: None)
  • cost (SpellCost|None): The cost of casting the spell (default: SpellCost(0, False, 0, 0, 0, 0, 0, 0, 0, 0))
  • school_icon (str|None): Path to the school icon image (default: None)
  • type_icon (str|None): Path to the type icon image (default: None)
  • accuracy (str|None): Accuracy percentage as string (default: '0%')
  • accuracy_colour (tuple|None): RGBA color tuple for accuracy text (default: None)
  • booster_pack (str|None): Path to the booster pack image (default: None)
  • cloaked (bool): Whether the spell is cloaked (default: False)
  • no_pvp (bool): Whether the spell cannot be used in PvP (default: False)
  • no_pve (bool): Whether the spell cannot be used in PvE (default: False)
  • pierce (int): Pierce value of the spell (default: 0)
  • level_requirement (int): Level required to use the spell (default: 0)
  • cannot_discard (bool): Whether the spell cannot be discarded (default: False)
  • essence_collection (bool): Whether the spell has the Animus collection icon (default: False)
  • single_use (bool): Whether the spell is single use (default: False)

SpellCost Class

The SpellCost class represents the pip cost of a spell.

Constructor Arguments

  • base_cost (int): The base pip cost (default: 0)
  • variable_cost (bool): Whether the cost is variable (default: False)
  • shadow (int): Shadow pip cost (default: 0)
  • balance (int): Balance pip cost (default: 0)
  • death (int): Death pip cost (default: 0)
  • fire (int): Fire pip cost (default: 0)
  • ice (int): Ice pip cost (default: 0)
  • life (int): Life pip cost (default: 0)
  • myth (int): Myth pip cost (default: 0)
  • storm (int): Storm pip cost (default: 0)

TextAlignment Class

The TextAlignment class provides text alignment options.

Static Methods

  • center(): Returns a center-aligned TextAlignment object
  • left(): Returns a left-aligned TextAlignment object

CardFactory Class

The CardFactory class is used to generate spell card images.

Constructor

  • CardFactory(settings: CardFactorySettings): Creates a new CardFactory with the given settings

CardFactorySettings Class

The CardFactorySettings class contains configuration for the CardFactory.

Constructor Arguments

  • assets_path (str): Path to the assets directory (default: "")
  • glyph_defs_path (str): Path to the glyph definitions XML file (default: "")
  • spell_title_font_path (str): Path to the spell title font XML file (default: "")
  • spell_description_font_path (str): Path to the spell description font XML file (default: "")
  • shadow_school_pip_path (str): Path to the shadow school pip icon (default: "")
  • balance_school_pip_path (str): Path to the balance school pip icon (default: "")
  • death_school_pip_path (str): Path to the death school pip icon (default: "")
  • fire_school_pip_path (str): Path to the fire school pip icon (default: "")
  • ice_school_pip_path (str): Path to the ice school pip icon (default: "")
  • life_school_pip_path (str): Path to the life school pip icon (default: "")
  • myth_school_pip_path (str): Path to the myth school pip icon (default: "")
  • storm_school_pip_path (str): Path to the storm school pip icon (default: "")
  • rank_number_icons (list): List of 21 paths to rank number icons (0-20) (default: [])
  • rank_minus_icon (str): Path to the rank minus icon (default: "")
  • rank_plus_icon (str): Path to the rank plus icon (default: "")
  • rank_x_icon (str): Path to the rank X icon (default: "")
  • cloak_icon (str): Path to the cloak icon (default: "")
  • cloak_frame_icon (str): Path to the cloak frame icon (default: "")
  • pvp_only_icon (str): Path to the PvP only icon (default: "")
  • pve_only_icon (str): Path to the PvE only icon (default: "")
  • banned_icon (str): Path to the banned icon (default: "")
  • single_use_icon (str): Path to the single use icon (default: "")
  • cannot_discard_icon (str): Path to the cannot discard icon (default: "")
  • essence_collection_icon (str): Path to the essence collection icon (default: "")
  • pierce_icon (str): Path to the pierce icon (default: "")
  • pierce_frame_icon (str): Path to the pierce frame icon (default: "")
  • level_requirement_icon (str): Path to the level requirement icon (default: "")
  • default_icon_size (tuple): Default size for icons as (width, height) (default: (16, 16))
  • default_wide_icon_size (tuple): Default size for wide icons as (width, height) (default: (32, 16))
  • cache_madlibs (bool): Whether to cache madlibs (default: True)

CardImage Class

The CardImage class represents a generated spell card image.

Methods

  • save(path: str): Saves the image to the given path. The extension matters for the output format.
  • to_memory(): Writes the image to a webp format in memory and returns the buffer.

Usage Example

import spellgen

# Create settings for the card factory
settings = spellgen.CardFactorySettings(
    assets_path="assets",
    glyph_defs_path="glyph_defs/SpellDescription.xml",
    # ... other settings ...
)

# Create a card factory
factory = spellgen.CardFactory(settings)

# Create a spell card
card = spellgen.SpellCard(
    title="Fire Cat",
    description="Deals 85-105 Fire damage",
    cost=spellgen.SpellCost(2, False, 0, 0, 1, 0, 0, 0, 0, 0),
    school_icon="school_icons/Icon_Fire.png",
    spell_image="spell_icons/Spell_Fire_FireCat.dds",
    type_icon="type_icons/Type_Damage.png",
    accuracy="85%"
)

# Generate the card image
img = factory.generate(card)

# Save the image
img.save("fire_cat.webp")

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

spellgen-0.1.0-cp312-cp312-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.12Windows x86-64

spellgen-0.1.0-cp311-cp311-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.11Windows x86-64

spellgen-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

spellgen-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

spellgen-0.1.0-cp310-cp310-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.10Windows x86-64

spellgen-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

spellgen-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file spellgen-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: spellgen-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for spellgen-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3f0d37b7dc13c579cea6d4143bccda8546844c851870c6018d5c1cd9d798c215
MD5 4278a13af3654316e78af28b65548fcb
BLAKE2b-256 7d9352b14f08f9e4679623be74a889fabc3c3e4453a8ba674fa0cc23629bc324

See more details on using hashes here.

File details

Details for the file spellgen-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: spellgen-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spellgen-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bf5b3610735502ea4810ec5b55e016cf11049764bfac796e7a5ccde810c6ed4a
MD5 cdd2cc7cf48e3981f0320315f0c7ea73
BLAKE2b-256 0305e08a884640f64ba99021e52a8da9e3ed1a4ee33b8964f0a4b7f08e7cea29

See more details on using hashes here.

File details

Details for the file spellgen-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for spellgen-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 988c47b84dee304fd7f691c932a5f8337cf46ad69773e51dcf7a9f9a9fc42a0d
MD5 6b4c03a0ee066ded8c2d9970e0cfbfa6
BLAKE2b-256 19f457bcff1d317e669a6afb1e425c1c7d207e59bf4ee3729371d093ea72ca36

See more details on using hashes here.

File details

Details for the file spellgen-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spellgen-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29e1408ee23c14b8150abde76cd5d1718f79f5f5a6c868b34be4a62603d21c95
MD5 efbe5faf7e3aa690b76d3feef6992f0a
BLAKE2b-256 8a8a9e9425f7e5d1ad8449a05cfd522cefe2c52dc7223adf90e44b0a0003e953

See more details on using hashes here.

File details

Details for the file spellgen-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: spellgen-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spellgen-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cf7308278e4903ec865b04f50e30d38541748e49a1bd39496fc8fc86f3494c6d
MD5 e53851588bef12c42831c714617363b5
BLAKE2b-256 5cf0572888e04d9edcd5610ba5f62b16431f22bdff612881acce5fa03e292a4b

See more details on using hashes here.

File details

Details for the file spellgen-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for spellgen-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 160778642b4353e5faf103bc1169b31be1d5ba02e99e182fbeea80494784ad76
MD5 5201279adf0d52f438702a7450c61791
BLAKE2b-256 eef6c13908f57b0b1cea749276a0062a531f59f8ecca27707907971bc0cef520

See more details on using hashes here.

File details

Details for the file spellgen-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spellgen-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e08163b31825b835091411d8c38d52c0eda009176177b583beb0db4c12403495
MD5 5d6cfb7263deb42921b678cd62cf6a63
BLAKE2b-256 e306552deae156e500180a89a2fa4cf276817961012e4343ac6d5332e5ab0d92

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