mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Improve the card price generation script (#2368)
* - Update the MTGDecksNet conversion and AI playability test toolchain to the latest version (Python 3 compatible). * - Make the input/output folders generic * - Make the input/output folders generic, part 2. * - Add the Scryfall all-prices.txt generator script. * - Minor code cleanup. * - Improve ConniveAi for Change of Plans. * - Check if the AI can draw cards for ConniveAI * - Improve the price generation script to account for the Scryfall set code to Forge set code mapping. - Tweak paths in some of the scripts.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
CARDSFOLDER = "../../res/cardsfolder"
|
CARDSFOLDER = "../res/cardsfolder"
|
||||||
DECKFOLDER = "."
|
DECKFOLDER = "."
|
||||||
|
|
||||||
import argparse, os, re
|
import argparse, os, re
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
CARDSFOLDER = "../../res/cardsfolder"
|
CARDSFOLDER = "../res/cardsfolder"
|
||||||
DECKFOLDER = "."
|
DECKFOLDER = "."
|
||||||
|
|
||||||
import argparse, os, re
|
import argparse, os, re
|
||||||
|
|||||||
@@ -3,13 +3,39 @@
|
|||||||
|
|
||||||
import json, os
|
import json, os
|
||||||
|
|
||||||
|
# Set this to the current Forge editions folder (under res)
|
||||||
|
EDITIONS_FOLDER = "../res/editions"
|
||||||
|
|
||||||
|
# Load the editions and map Scryfall codes to the set codes used in Forge
|
||||||
|
set_map = {}
|
||||||
|
for filename in os.listdir(EDITIONS_FOLDER):
|
||||||
|
if filename.endswith(".txt"):
|
||||||
|
ed_file = open(os.path.join(EDITIONS_FOLDER, filename), "r")
|
||||||
|
ed_data = ed_file.readlines()
|
||||||
|
ed_file.close()
|
||||||
|
forge_code = "????"
|
||||||
|
scryfall_code = "????"
|
||||||
|
for line in ed_data:
|
||||||
|
if line.startswith("[cards]"):
|
||||||
|
break
|
||||||
|
elif line.lower().startswith("code="):
|
||||||
|
forge_code = line.split("=")[1].strip()
|
||||||
|
elif line.lower().startswith("scryfallcode="):
|
||||||
|
scryfall_code = line.split("=")[1].strip()
|
||||||
|
set_map[scryfall_code] = forge_code
|
||||||
|
|
||||||
# Note: currently only loads the first json file found in the folder!
|
# Note: currently only loads the first json file found in the folder!
|
||||||
|
metadata_file = None
|
||||||
files = os.listdir(".")
|
files = os.listdir(".")
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename.endswith(".json"):
|
if filename.endswith(".json"):
|
||||||
metadata_filename = filename
|
metadata_filename = filename
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if metadata_file is None:
|
||||||
|
print("Please download the Default Cards bulk data json file from https://scryfall.com/docs/api/bulk-data and place it in the script folder.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
print(f"Loading {metadata_filename}...")
|
print(f"Loading {metadata_filename}...")
|
||||||
metadata_file = open(metadata_filename, "r")
|
metadata_file = open(metadata_filename, "r")
|
||||||
metadata = json.load(metadata_file)
|
metadata = json.load(metadata_file)
|
||||||
@@ -50,6 +76,9 @@ for object in metadata:
|
|||||||
card_price = card_price[2:]
|
card_price = card_price[2:]
|
||||||
elif card_price.startswith("0"):
|
elif card_price.startswith("0"):
|
||||||
card_price = card_price[1:]
|
card_price = card_price[1:]
|
||||||
|
# tweak the card set to the Forge notation
|
||||||
|
if card_set in set_map:
|
||||||
|
card_set = set_map[card_set]
|
||||||
# add a key to the prices dictionary, per set
|
# add a key to the prices dictionary, per set
|
||||||
if not card_set in prices:
|
if not card_set in prices:
|
||||||
prices[card_set] = {}
|
prices[card_set] = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user