mirror of
https://github.com/Cockatrice/Magic-Spoiler.git
synced 2026-08-24 10:25:16 -05:00
Merge pull request #2 from Cockatrice/hou
Add new set "Hour of Devastation" (HOU)
This commit is contained in:
@@ -1,18 +1,2 @@
|
||||
{
|
||||
"Open into Wonder": {
|
||||
"manaCost": "{X}{U}{U}"
|
||||
},
|
||||
"By Force": {
|
||||
"manaCost": "{X}{R}"
|
||||
},
|
||||
"Nissa, Steward of Elements": {
|
||||
"manaCost": "{X}{U}{G}",
|
||||
"loyalty": "X"
|
||||
},
|
||||
"Pull From Tomorrow": {
|
||||
"name": "Pull from Tomorrow"
|
||||
},
|
||||
"Tresspasser's Curse": {
|
||||
"name": "Trespasser's Curse"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
["~Sandwurm Convengence","Holaphel, Maw of Sands","Evolving Wilds"]
|
||||
[]
|
||||
|
||||
@@ -45,10 +45,12 @@
|
||||
"blank card (do not use this key, just the object) - remove unneeded keys":
|
||||
{
|
||||
"name": "",
|
||||
"manaCost": "",
|
||||
"number": "",
|
||||
"rarity": "",
|
||||
"type": "",
|
||||
"url": "",
|
||||
"text": "",
|
||||
"loyalty": "",
|
||||
"cmc": 0,
|
||||
"layout": "",
|
||||
@@ -57,5 +59,37 @@
|
||||
}
|
||||
},
|
||||
"cards": [
|
||||
{
|
||||
"name": "Nicol Bolas, God-Pharaoh",
|
||||
"manaCost": "4UBR",
|
||||
"number": "140",
|
||||
"rarity": "Mythic Rare",
|
||||
"type": "Planeswalker - Bolas",
|
||||
"url": "https://i.imgur.com/DTNXG2z.png",
|
||||
"text": "+2: Target opponent exiles cards from the top of his or her library until he or she exiles a nonland card. Until end of turn, you may cast that card without paying its mana cost.\n+1: Each opponent exiles two cards from his or her hand.\n-4: Nicol Bolas, God-Pharaoh deals 7 damage to target opponent or creature an opponent controls.\n-12: Exile each nonland permanent your opponents control.",
|
||||
"loyalty": "7",
|
||||
"cmc": 7
|
||||
},
|
||||
{
|
||||
"name": "Bontu's Last Reckoning",
|
||||
"manaCost": "1BB",
|
||||
"number": "60",
|
||||
"rarity": "Rare",
|
||||
"type": "Sorcery",
|
||||
"url": "https://i.imgur.com/HOjh3pE.png",
|
||||
"text": "Destroy all creatures. Lands you control don't untap during your next untap step.",
|
||||
"cmc": 3
|
||||
},
|
||||
{
|
||||
"name": "Samut, the Tested",
|
||||
"manaCost": "2RG",
|
||||
"number": "144",
|
||||
"rarity": "Mythic Rare",
|
||||
"type": "Planeswalker - Samut",
|
||||
"url": "https://i.imgur.com/4tRYs5z.png",
|
||||
"text": "+1: Up to one target creature gains double strike until end of turn.\n-2: Samut, the Tested deals 2 damage divided as you choose among one or two target creatures and/or players.\n-7: Search your library for up to two creature and/or planeswalker cards, put them onto the battlefield, then shuffle your library.",
|
||||
"loyalty": "4",
|
||||
"cmc": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
12
main.py
12
main.py
@@ -7,7 +7,8 @@ import json
|
||||
|
||||
presets = {
|
||||
"isfullspoil": True, #when full spoil comes around, we only want to use WOTC images
|
||||
"includeMasterpieces": True #if the set has masterpieces, let's get those too
|
||||
"includeMasterpieces": True, #if the set has masterpieces, let's get those too
|
||||
"oldRSS": True #maybe MTGS hasn't updated their spoiler.rss but new cards have leaked
|
||||
}
|
||||
|
||||
with open('set_info.json') as data_file:
|
||||
@@ -64,8 +65,11 @@ def save_errorlog(errorlog):
|
||||
|
||||
if __name__ == '__main__':
|
||||
AllSets = spoilers.get_allsets() #get AllSets from mtgjson
|
||||
mtgs = spoilers.scrape_mtgs('http://www.mtgsalvation.com/spoilers.rss') #scrape mtgs rss feed
|
||||
mtgs = spoilers.parse_mtgs(mtgs) #parse spoilers into mtgjson format
|
||||
if presets['oldRSS']:
|
||||
mtgs = {"cards":[]}
|
||||
else:
|
||||
mtgs = spoilers.scrape_mtgs('http://www.mtgsalvation.com/spoilers.rss') #scrape mtgs rss feed
|
||||
mtgs = spoilers.parse_mtgs(mtgs) #parse spoilers into mtgjson format
|
||||
mtgs = spoilers.correct_cards(mtgs, manual_cards, card_corrections, delete_cards) #fix using the fixfiles
|
||||
#scryfall = spoilers.get_scryfall('https://api.scryfall.com/cards/search?q=++e:' + setinfos['setname'].lower())
|
||||
mtgs = spoilers.get_image_urls(mtgs, presets['isfullspoil'], setinfos['setname'], setinfos['setlongname'], setinfos['setsize']) #get images
|
||||
@@ -86,4 +90,4 @@ if __name__ == '__main__':
|
||||
save_masterpieces(masterpieces)
|
||||
save_errorlog(errorlog)
|
||||
save_allsets(AllSets)
|
||||
#save_setjson(mtgs)
|
||||
save_setjson(mtgs)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"setname": "AKH",
|
||||
"setlongname": "Amonkhet",
|
||||
"setname": "HOU",
|
||||
"setlongname": "Hour of Devastation",
|
||||
"blockname": "Amonkhet",
|
||||
"setsize": 269,
|
||||
"setreleasedate": "2017-04-28",
|
||||
"setsize": 199,
|
||||
"setreleasedate": "2017-07-14",
|
||||
"settype": "expansion",
|
||||
"masterpieces": {
|
||||
"setname": "MPS_AKH",
|
||||
|
||||
42
spoilers.py
42
spoilers.py
@@ -248,17 +248,17 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[]
|
||||
workingCMC += 1
|
||||
if 'types' not in card:
|
||||
card['types'] = []
|
||||
if '—' in card['type']:
|
||||
workingTypes = card['type'].split('—')[0].strip()
|
||||
else:
|
||||
workingTypes = card['type'].split('-')[0].strip()
|
||||
# if '—' in card['type']:
|
||||
# workingTypes = card['type'].split('—')[0].strip()
|
||||
# else:
|
||||
workingTypes = card['type'].split('-')[0].strip()
|
||||
workingTypes.replace('Legendary ','').replace('Snow ','')\
|
||||
.replace('Elite ','').replace('Basic ','').replace('World ','').replace('Ongoing ','')
|
||||
card['types'] += workingTypes.split(' ')
|
||||
if 'subtypes' not in card:
|
||||
if '—' in card['type']:
|
||||
workingSubtypes = card['type'].split('—')[1].strip()
|
||||
elif '-' in card['type']:
|
||||
# if '—' in card['type']:
|
||||
# workingSubtypes = card['type'].split('—')[1].strip()
|
||||
if '-' in card['type']:
|
||||
workingSubtypes = card['type'].split('-')[1].strip()
|
||||
if workingSubtypes:
|
||||
card['subtypes'] = workingSubtypes.split(' ')
|
||||
@@ -280,7 +280,7 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[]
|
||||
card['colorIdentity'] = [letter]
|
||||
if 'colors' in card:
|
||||
if not colorMap[letter] in card['colors']:
|
||||
card['colors'] += colorMap[letter]
|
||||
card['colors'].append(colorMap[letter])
|
||||
else:
|
||||
card['colors'] = [colorMap[letter]]
|
||||
if 'text' in card:
|
||||
@@ -297,10 +297,22 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[]
|
||||
for manualCard in manual_cards:
|
||||
if card['name'] == manualCard['name']:
|
||||
mtgjson2.append(manualCard)
|
||||
print 'overwriting card ' + card['name']
|
||||
isManual = True
|
||||
if not isManual and not card['name'] in delete_cards:
|
||||
mtgjson2.append(card)
|
||||
|
||||
for manualCard in manual_cards:
|
||||
addManual = True
|
||||
for card in mtgjson['cards']:
|
||||
if manualCard['name'] == card['name']:
|
||||
addManual = False
|
||||
if addManual:
|
||||
mtgjson2.append(manualCard)
|
||||
print 'inserting manual card ' + manualCard['name']
|
||||
|
||||
mtgjson = {"cards": mtgjson2}
|
||||
|
||||
for card in mtgjson['cards']:
|
||||
for cardCorrection in card_corrections:
|
||||
if card['name'] == cardCorrection:
|
||||
@@ -811,7 +823,7 @@ def write_xml(mtgjson, setname, setlongname, setreleasedate, split_cards=[]):
|
||||
cardsxml.write("<name>" + name.encode('utf-8') + "</name>\n")
|
||||
cardsxml.write('<set rarity="' + card['rarity'] + '" picURL="' + card["url"] + '">' + setname + '</set>\n')
|
||||
cardsxml.write("<manacost>" + manacost.encode('utf-8') + "</manacost>\n")
|
||||
cardsxml.write("<cmc>" + cardcmc + "</cmc>")
|
||||
cardsxml.write("<cmc>" + cardcmc + "</cmc>\n")
|
||||
if card.has_key('colors'):
|
||||
colorTranslate = {
|
||||
"White": "W",
|
||||
@@ -821,14 +833,14 @@ def write_xml(mtgjson, setname, setlongname, setreleasedate, split_cards=[]):
|
||||
"Green": "G"
|
||||
}
|
||||
for color in card['colors']:
|
||||
cardsxml.write('<color>' + colorTranslate[color] + '</color>')
|
||||
cardsxml.write('<color>' + colorTranslate[color] + '</color>\n')
|
||||
if name + ' enters the battlefield tapped' in text:
|
||||
cardsxml.write("<cipt>1</cipt>")
|
||||
cardsxml.write("<cipt>1</cipt>\n")
|
||||
cardsxml.write("<type>" + cardtype.encode('utf-8') + "</type>\n")
|
||||
if pt:
|
||||
cardsxml.write("<pt>" + pt + "</pt>\n")
|
||||
if card.has_key('loyalty'):
|
||||
cardsxml.write("<loyalty>" + str(card['loyalty']) + "</loyalty>")
|
||||
cardsxml.write("<loyalty>" + str(card['loyalty']) + "</loyalty>\n")
|
||||
cardsxml.write("<tablerow>" + tablerow + "</tablerow>\n")
|
||||
cardsxml.write("<text>" + text.encode('utf-8') + "</text>\n")
|
||||
if related:
|
||||
@@ -839,9 +851,9 @@ def write_xml(mtgjson, setname, setlongname, setreleasedate, split_cards=[]):
|
||||
cardsxml.write("</card>\n")
|
||||
|
||||
cardsxml.write("</cards>\n</cockatrice_carddatabase>")
|
||||
|
||||
if os.path.isfile('out/' + setname + '.xml'):
|
||||
shutil.copyfile('out/' + setname + '.xml','out/spoiler.xml')
|
||||
if not 'MPS' in setname:
|
||||
if os.path.isfile('out/' + setname + '.xml'):
|
||||
shutil.copyfile('out/' + setname + '.xml','out/spoiler.xml')
|
||||
|
||||
#failing pretty xml code
|
||||
#with open('out/' + setname + '.xml') as data_file:
|
||||
|
||||
Reference in New Issue
Block a user