Skip to main content

Procedurally generated trading card game

Project description


Proćemon is a procedurally-generated trading card game from the exceedingly popular Proćemon media franchise. I found the original source code under a truck and I’ve decided to leak it online.


Installation

pip3 install procemon

Usage

  1. Either clone this repo or download this file.
  2. cd path/to/the/file (Replace path/to with the actual path to the repo or the directory where the downloaded file is located.)
  3. Windows: py -3 create_dex.py OS X and Linux: python3 create_dex.py

What it does

  1. Create a "Dex" of a given number of "types" of Proćemon. Choose those "types" randomly.
  2. Generate Proćemon and assign them moves.
  3. Save a JSON object describing the Dex to disk.
  4. Get a sprite image for each Proćemon.
  5. Generate a card image for each Proćemon and save it to disk.
  6. Generate a temporary image of the back of a card.
  7. Create a PDF zine of some of the images.

How it works

Read the API documentation here.

  • A Dex is a compendium of MonsterTypes. Per MonsterType, the Dex generates a given number of Monsters.
  • Each MonsterType is stored as a JSON object here. MonsterTypes are a few important keywords (such as the name of the type) and a list of nouns (which will be used to generate monster names). MonsterTypes and their nouns were scraped from the Internet in several ways:
  • Each Monster has 2 MonsterTypes. Each Monster's name is generated by combining part of a noun from the first MonsterType with part of a noun from the second MonsterType.
  • Each Monster has a description i.e. the flavor text at the bottom of the card. To generate the flavor text, it scrapes Wikipedia pages (with Beautiful Soup) using its MonsterType keywords (see MonsterType.wikipedia) and its constituent nouns. It then creates a Markov chain model (using Markovify) from this text and to generate a short sentence.
  • Each Monster has a rarity. This determines how "good" its stats are. In the Dex, each MonsterType has a certain percentage of card rarities (e.g. 20% of each monster type is Rare, and so on).
  • Each monster has a strong_against which is just the type one to the right of its "primary type" in the Dex array of MonsterTypes. For example if the array is ["duck", "furniture", "fern"] then all Monsters with the primary type "duck" are strong against "furniture". (The order of this array is randomly shuffled whenever a new Dex is created.)
  • Each Monster has 2 Moves. Moves are generated using the Monster's first type (the "primary type").
    • When the Dex is first created, it loads a Word Vector file. It then loads a list of verbs and a list of adjectives. These lists were scraped from pycorpora and Bulbapedia. Then, the Dex assigns verbs and adjectives to each Move based on their distance to the type. For example, if the type is flower and the adjective is floral, the distance will be really short, so now the adjectives dictionary will look something like: {"flower": ["floral"]}
    • If you don't already have the expected word vector file, it is downloaded from here and extracted to ~/procemon_wv/ where~ is your home directory.
    • There is also a list of "generic" verbs that any type can use. These verbs are a very short distance away from the word "attack".
    • To get the name of a Move, a verb is first picked at random either from the "generic" verb list of the type-specific verb list. Then, sometimes a type-specific adjective is prepended to the name.
    • A Move has a certain cost. It might deal damage and it might have a special effect. The odds for how this is generated depends on the Monster's rarity.
  • Once all of the monster have been generated, the Dex can be saved as a JSON dictionary.
  • Generate cards of each Monster by calling Dex.create_cards()
    • A color palette is loaded. This array was derived from this image of the NES palette. Each MonsterType is associated with a "color index" representing a column in the palette array.
    • For every MonsterType, the Dex looks for image URLs. It uses this file to look up "synset IDs" in ImageNet using the MonsterType.imagenet and MonsterType.nouns. It tests each URL.
      • If it's a "good" URL (if an image is successfully downloaded), the Dex processes the image using PIL to make it look like a sprite and then adds it as an option for the next Monster of this MonsterTtype. The sprite is colorized using the color index in the palette.
      • If it's a "bad" URL (and they often are) it is added to a list of known bad URLs so it doesn't waste time trying again.
    • Once the images have been selected, a card per Monster is created and saved to disk using PIL.
  • Optionally, a zine can be created of some of the cards in the Dex. This script will:
    • Generate an image of the back of the card to use as the front and back cover of the zine.
    • Start creating a PDF using fpdf.
    • Randomly select some cards and add them as pages.
    • Write the PDF to disk.

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

procemon-1.0.0.tar.gz (18.4 kB view hashes)

Uploaded Source

Supported by

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