Random Commander From File Rules

randomCommanderFromFile.txt

The randomcommander from file feature allows players to load a commander deck from a predefined list stored in an external file. Here’s how it works:

File Loading: The game attempts to open a file named commander.txt located in the User/commander/ directory. This file contains a list of possible commander IDs or names.

Default Handling: If the file doesn't exist or is empty, the game creates the file and writes a default commander ID (670972) to it. The file is then re-opened for further processing.

Commander ID Extraction: The game reads each line in the file, ignoring comments (lines starting with #). It validates whether the line is a numeric commander ID. If not, the game tries to convert it from a card name to an ID using function getMTGId().

Filtering and Validation: The game then filters out invalid IDs (e.g., IDs that do not correspond to an existing card in the game's database). If no valid IDs remain, it defaults to using the same commander ID (670972).

Random Selection: Once a list of valid commander IDs is compiled, the game randomly selects one ID from this list to be used as the commander for the player.

Deck Construction: A temporary deck is constructed using the selected commander, along with a predefined number of lands and spells that match the commander's colors.

Summary
The random commander from file feature provides a way to customize and randomize the commander used in a game based on an external file. This adds variety and replayability, as each game can have a different commander selected from the list, allowing for different strategies and experiences.
This commit is contained in:
Eduardo MG
2024-08-22 10:32:53 -06:00
committed by GitHub
parent ddd589d3f6
commit 3d9b40f903

View File

@@ -0,0 +1,5 @@
include randomCommander.txt
name=Random Commander From File
unlock=prx_rnddeck
[INIT]
mode=random_commander_from_file