-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (46 loc) · 1.94 KB
/
main.py
File metadata and controls
66 lines (46 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import json
from CardGenerator import *
from APIJSONParser import *
import requests
from contants import *
from UnitData import *
pdf = FPDF(orientation='L', unit='mm', format='A4')
pdf.add_page(orientation = "L", format = "a4")
cardGenerator = CardGenerator(pdf)
y = requests.get('https://army-forge.onepagerules.com/api/army-books/FF4UemWHh60T1VRq?gameSystem=5')
x = requests.get('https://army-forge.onepagerules.com/api/army-books/vJuokTQpJWj3_MrJ?gameSystem=5')
saurians = requests.get('https://army-forge.onepagerules.com/api/army-books/BubhE1kUpgYbqZvW?gameSystem=5')
ratmens = requests.get('https://army-forge.onepagerules.com/api/army-books/tOWt5fgqK2nfpoBN?gameSystem=5')
#obj = json.loads(y.content)
#obj = json.loads(x.content)
obj = json.loads(saurians.content)
#obj = json.loads(ratmens.content)
units = obj["units"]
upgradePackage = obj["upgradePackages"] ### CONST
counterRow = 0
for unit in obj["units"]:
position = Vector2(40, 4 + DEFAULT_CARD_HEIGHT * cardGenerator.yRowScalerPerPage)
### Write first page
firstPageData = getFirstPageData(unit) # DONE
#cardGenerator.writeFirstHeroCardData(firstPageData) # DONE
unitData = UnitData()
cardGenerator.fillUnitFirstPageWithData(unitData, firstPageData)
cardGenerator.writeFirstPageByCardData(unitData) # DONE
### Write upgrades pages
unitUpgrades = getUnitUpgrades(unit, upgradePackage)
for unitUpgrade in unitUpgrades:
#print("UNIT_UPGRADE =>", unitUpgrade["options"], "\n\n")
cardGenerator.writeUpgradeHeroData(unitUpgrade, position)
for cell in range(int(position.x / DEFAULT_CARD_WIDTH)):
pdf.rect(DEFAULT_CARD_WIDTH * cell, DEFAULT_CARD_HEIGHT * cardGenerator.yRowScalerPerPage, DEFAULT_CARD_WIDTH, DEFAULT_CARD_HEIGHT)
cardGenerator.increaseRowScaler()
counterRow += 1
if counterRow >= 3:
counterRow = 0
pdf.add_page(orientation = "L", format = "a4")
cardGenerator.resetRowScaler()
pdf.output("simple_demo.pdf")
''' OTHER DATA
#for key,val in obj.items():
# print(key)
'''