Skip to main content

Notes

This is the library for creating spell card images for the game Wizard101.

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)
  • legacy_madlib_sizes (bool): Use legacy inline icon sizing in descriptions (default: False)
  • legacy_rule_layout (bool): Use the legacy rule strip (PvP/PvE-only icons and framed level badge). When False, the modern combined rule bar and title-font level number are used (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: "")
  • legacy_pvp_only_icon (str): Legacy layout icon when the spell is PvP-only (default: "")
  • legacy_pve_only_icon (str): Legacy layout icon when the spell is PvE-only (default: "")
  • pvp_icon (str): Modern rule bar PvP icon (default: "")
  • pve_icon (str): Modern rule bar PvE 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)
  • legacy_rule_layout (bool): Stored on factory settings (default: False). Rendering uses SpellCard.legacy_rule_layout.

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")

Metadata

Release files for spellgen 0.6.0

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

Source distribution (sdist)

Source distribution for spellgen 0.6.0
File Size Uploaded Provenance Actions
spellgen-0.6.0.tar.gz 70.8 kB Without provenance Details for spellgen-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for spellgen 0.6.0
File Interpreter ABI Platform Actions
spellgen-0.6.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for spellgen-0.6.0-cp311-abi3-win_amd64.whl
spellgen-0.6.0-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details for spellgen-0.6.0-cp311-abi3-manylinux_2_34_x86_64.whl

Total release size: 5.6 MB

Release files / spellgen-0.6.0.tar.gz

Download URL spellgen-0.6.0.tar.gz
Size 70.8 kB
Tags Source
SHA-256 checksum
How to use checksums
516cb6e434d1b14822c59e41b510779d9567d4a92a98cb978da661c5fd93df48
BLAKE2b-256 checksum
How to use checksums
b8031e4a0027be1ff72a80bd6d84ee820631978bff2041b99c478ca960e22c4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / spellgen-0.6.0-cp311-abi3-win_amd64.whl

Download URL spellgen-0.6.0-cp311-abi3-win_amd64.whl
Size 2.7 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ad561fb0ef25c8c91e42a9a99fd445b074ba0ffc4896b9f580065e12ec9a4bba
BLAKE2b-256 checksum
How to use checksums
bc99fd94e2054aefa8224300cc5616c36a331fddf2d45fe1c6bbebfe62af7a34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / spellgen-0.6.0-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL spellgen-0.6.0-cp311-abi3-manylinux_2_34_x86_64.whl
Size 2.9 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
be099f67f1b2e731b2c8a9be5fc9e0c3c9fd9b98edd5b754f76e83c7a2d9aab1
BLAKE2b-256 checksum
How to use checksums
76e1336c9e67d30efe49d97b5c623885b444f603ab2de2ad8faf0a0007a686e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for spellgen 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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