51 lines
1.1 KiB
Python
Executable file
51 lines
1.1 KiB
Python
Executable file
#!/usr/bin/python3
|
|
import json
|
|
|
|
def get(j, name):
|
|
print(name, '(', *[ str(i)+':'+j[i] for i in range(len(j)) ], '): ', sep = ' ', end=' ')
|
|
|
|
index = int(input())
|
|
if(index < 0 or index >= len(j)):
|
|
return ''
|
|
|
|
return j[index]
|
|
|
|
with open("cards/config.json") as f:
|
|
j = json.loads(f.read())
|
|
traits = j["traits"]
|
|
lines = j["lines"]
|
|
factions = j["factions"]
|
|
template = j["template"]
|
|
|
|
def card():
|
|
data = template.copy()
|
|
|
|
print("Name:", end=' ')
|
|
data["name"] = input()
|
|
print(data["name"])
|
|
if data["name"] == '':
|
|
return {}
|
|
|
|
print("Power:", end=' ')
|
|
data["power"] = int(input())
|
|
|
|
data["faction"] = get(factions, "Faction")
|
|
|
|
data["line"] = get(lines, "Line")
|
|
|
|
trait = get(traits, "Traits (-1 to stop)")
|
|
while trait != '':
|
|
if trait not in data["traits"]:
|
|
data["traits"].append(trait)
|
|
trait = get(traits, "Traits (-1 to stop)")
|
|
|
|
return data
|
|
|
|
cards = []
|
|
new_card = card()
|
|
while new_card != {}:
|
|
cards.append(new_card)
|
|
new_card = card()
|
|
|
|
with open("cards/cards.json") as f:
|
|
f.write(json.dumps(cards))
|