Card Generator Rewrite
·
13 commits
to main
since this release
Card Data Formatter Script
This C# script is designed to format data for a card game, creating Card Definition Files (CDFs) based on the images in a specified directory.
Usage
-
Edition ID Input:
- The script begins by prompting the user to enter the edition ID. This is used to locate the directory containing card images.
-
Directory Validation:
- It validates the path for the existence of the specified card directory. If the directory does not exist, it displays an error message and exits the program.
-
CDF Generation Loop:
- For each PNG file in the specified directory, the script generates a corresponding CDF file.
-
CDF Data Generation:
- For each card, it extracts information such as category, description, rarity, and drop weight from the filename and generates a CDF with this information.
-
File Overwriting:
- The script overwrites any existing CDF files with the updated content.
-
Success Message:
- After processing all files, it prints a success message.
-
Console Wait:
- The program waits for user input before closing the console window.
Methods Overview
-
GenerateCdfFile:
- Takes a card image path and the edition ID as input.
- Extracts information from the filename and generates CDF data.
- Writes the CDF data to a file.
-
GenerateCardId:
- Generates a card ID by converting the filename to lowercase, removing file extensions, parentheses, square brackets, and rarity suffixes, and replacing non-alphanumeric characters with underscores.
-
GenerateCardName:
- Generates a card name by removing the rarity suffix, a prefix of consecutive numbers followed by an underscore, replacing underscores with spaces, and capitalizing each word.
-
GetRarityFromFilename:
- Extracts the rarity level from the filename.
-
GetDropWeight:
- Assigns a drop weight based on the rarity level.
-
ExtractCategoryAndDescription:
- Extracts category and description from the filename, capitalizes each word, and assigns them to respective variables.
Image Formatting
- Images are expected to follow the format:
n_a_m_e(Category Insert)[Description Insert]_Rarity.png - The script extracts information from this format to generate CDFs.
Important Notes
- The script is designed to overwrite existing CDF files with updated content.
- It handles variations in the filenames and generates consistent CDFs.
How to Use
-
Run the Script:
- Execute the script in a C# environment.
-
Enter Edition ID:
- Provide the edition ID when prompted.
-
Review Output:
- Check the console output for success messages and any potential errors.
-
CDF Files:
- Find generated CDF files in the same directory as the script.
-
Adjustments:
- Modify methods as needed to accommodate specific filename variations or additional data requirements.
Dependencies
- The script utilizes standard C# libraries for file handling, regular expressions, and console input/output.
License
- The script is free to use for any of your projects, Just make sure to credit SaxbyMod or Creator.