-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.py
668 lines (583 loc) · 29.3 KB
/
build.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
import os, shutil, json
from datetime import datetime, timezone
from cardata import *
from db import *
from math import floor
DATA_VERSION = 152
BUILD_TIMESTAMP = datetime.now().strftime("%Y%m%d%H%M%S")
jsondata = {
"updatetimestamp": datetime.now().strftime(f"%Y-%m-%d")
}
html = ""
with open("index.html", "r", encoding='utf-8') as f:
html = f.read()
html = html.replace("%BUILD_TIMESTAMP", BUILD_TIMESTAMP)
used_template = ""
with open("used.html", "r", encoding='utf-8') as f:
used_template = f.read()
legend_template = ""
with open("legend.html", "r", encoding='utf-8') as f:
legend_template = f.read()
dailyrace_template = ""
with open("dailyrace.html", "r", encoding='utf-8') as f:
dailyrace_template = f.read()
useddir = os.listdir("_data/used")
useddir.sort()
useddir.remove("starter.csv")
useddir.remove("menubook.csv")
legenddir = os.listdir("_data/legend")
legenddir.sort()
dailyracedir = os.listdir("_data/dailyrace")
dailyracedir.sort()
##################################################
# handle brand central prices
##################################################
lines = []
with open(f"_data/brandcentral/{os.listdir('_data/brandcentral')[-1]}") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
for car in lines:
cardata_add("brandcentral","*",car.strip().split(","))
##################################################
# handle rewards, engine swaps, lottery cars, trophy cars
##################################################
lines = []
with open(f"_data/rewards/{os.listdir('_data/rewards')[-1]}") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
rewards = {}
for reward in lines:
rewardsplit = reward.strip().split(",")
rewards[rewardsplit[0]] = rewardsplit[1:]
lines = []
with open(f"_data/db/engineswaps.csv") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
engineswaps = {}
for engineswap in lines:
engineswapsplit = engineswap.strip().split(",")
engineswaps[engineswapsplit[0]] = engineswapsplit[1:]
lines = []
with open(f"_data/db/lotterycars.csv") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
lotterycars = {}
for lotterycar in lines:
lotterycarsplit = lotterycar.strip().split(",")
if lotterycarsplit[0] != "B":
lotterycars[lotterycarsplit[1]] = lotterycarsplit[0]
lines = []
with open(f"_data/db/trophy.csv") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
trophycars = {}
for trophycar in lines:
trophycarsplit = trophycar.strip().split(",")
trophycars[trophycarsplit[1]] = trophycarsplit[0]
##################################################
# handle used car dealership
##################################################
lines = [] # type: list[str]
with open(f"_data/used/{useddir[-1]}") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
jsondata["used"] = {
"date": useddir[-1][:-4],
"cars": [],
}
for i in range(len(useddir)):
morelines = []
with open(f"_data/used/{useddir[-1-i]}") as f:
morelines = f.readlines()
morelines = morelines[1:] # remove headers
for car in morelines:
carsplit = car.strip().split(",")
cardata_add("used", useddir[-1-i].replace('.csv',''), carsplit)
usedcars_section = ""
for line in lines:
if line == "\n":
continue
carid, cr, state, daysremaining = line.strip().split(",")
daysremaining = int(daysremaining)
name = cardb_id_to_name(carid)
manufacturer = cardb_id_to_makername(carid)
region = cardb_id_to_countrycode(carid)
#HACK for cars that go through bad state changes
fucked = False
if int(carid) == 999999:
fucked = True
#HACK end
if state == "new":
car = '<p class="car carnew">\n'+used_template
elif state == "limited":
car = '<p class="car carlimited">\n'+used_template
elif state == "soldout":
car = '<p class="car carsold">\n'+used_template
else:
car = '<p class="car">\n'+used_template
flag = f"img/pdi-flag.png" if region == "pdi" else f"https://flagcdn.com/h24/{region}.png"
car = car.replace("%FLAG", flag)
car = car.replace("%MANUFACTURER", manufacturer.upper())
if cardata_exists(int(carid)):
car = car.replace("%NAME", f'<a href="cars/prices_{carid}.png" target="_blank">{name}</a>')
else:
car = car.replace("%NAME", name)
car = car.replace("%CREDITS", f"{int(cr):,}")
if state == "new":
car += '\n <span id="new">NEW</span>'
elif state == "limited":
car += '\n <span id="limited">Limited Stock</span>'
elif state == "soldout":
car += '\n <span id="soldout">SOLD OUT</span>'
if not fucked:
if daysremaining > 3:
car += f'\n <span id="days-estimate">Available For {daysremaining-2} More Days</span>'
elif daysremaining == 3:
car += f'\n <span id="days-remaining">Available For 1 More Day</span>'
elif daysremaining == 2:
car += f'\n <span id="days-remaining">Last Day Available</span>'
elif daysremaining == -1:
car += f'\n <span id="days-estimate">No Estimate Available</span>'
else:
car += f'\n <span id="days-estimate">No Estimate Available</span>'
rewardinfo = None
if carid in rewards.keys():
rewardinfo = rewards[carid]
car += '\n <span id="reward-text">REWARD<br>CAR</span>'
rewardtype = ""
match rewardinfo[0]:
case "menubook":
rewardtype = "Menu Book"
case "license":
rewardtype = "License:"
case "mission":
rewardtype = "Mission Set:"
car += f'\n <img id="reward-icon" src="img/open-book.svg" width="24" title="Reward from {rewardtype} {rewardinfo[1]}'
if rewardinfo[2] != "-":
car += f' All {rewardinfo[2].capitalize()}'
car += '"/>'
engineswapinfo = None
if carid in engineswaps.keys():
engineswapinfo = engineswaps[carid]
car += '\n <span id="engineswap-text">ENGINE<br>SWAP</span>'+\
f'\n <img id="engineswap-icon" src="img/engine.svg" width="24" title="Supports engine swap: {engineswapinfo[1]} from {cardb_id_to_name(engineswapinfo[0])}"/>'
lotterycarinfo = None
if carid in lotterycars.keys():
lotterycarinfo = lotterycars[carid]
lotterystars = ""
match lotterycarinfo:
case "L":
lotterystars = "4/5/6"
case "M":
lotterystars = "3/4/5"
case "S":
lotterystars = "1/2/3/4"
car += '\n <span id="lottery-text">TICKET<br>REWARD</span>'+\
f'\n <img id="lottery-icon" src="img/gift.svg" width="24" title="Can be won from {lotterystars} star tickets. Special parts for this car can be recieved from 4/5 star tickets."/>'
trophyname = None
if carid in trophycars.keys():
trophyname = trophycars[carid]
car += '\n <span id="trophy-text">TROPHY<br>REQ.</span>'+\
f'\n <img id="trophy-icon" src="img/trophy.svg" width="24" title="Must be owned to earn the {trophyname} trophy."/>'
usedcars_section += f'{car}\n </p>'
jsondata["used"]["cars"].append({
"carid": carid, "manufacturer": manufacturer, "region": region, "name": name, "credits": int(cr),
"state": "normal" if state == "new" else state, "estimatedays": daysremaining-1, "maxestimatedays": daysremaining-1, "new": state == "new",
"rewardcar": {"type": rewardinfo[0], "name": rewardinfo[1], "requirement": rewardinfo[2] if rewardinfo[2] != "-" else None} if rewardinfo is not None else None,
"engineswap": {"carid": engineswapinfo[0], "manufacturer": cardb_id_to_makername(engineswapinfo[0]),
"region": cardb_id_to_countrycode(engineswapinfo[0]), "name": cardb_id_to_name(engineswapinfo[0]),
"enginename": engineswapinfo[1]} if engineswapinfo is not None else None,
"lotterycar": lotterycarinfo, "trophycar": trophyname
})
##################################################
# handle legend car dealership
##################################################
lines = [] # type: list[str]
with open(f"_data/legend/{legenddir[-1]}") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
jsondata["legend"] = {
"date": legenddir[-1][:-4],
"cars": [],
}
for i in range(len(legenddir)):
morelines = []
with open(f"_data/legend/{legenddir[-1-i]}") as f:
morelines = f.readlines()
morelines = morelines[1:] # remove headers
for car in morelines:
carsplit = car.strip().split(",")
cardata_add("legend", legenddir[-1-i].replace('.csv',''), carsplit)
legendcars_section = ""
for line in lines:
if line == "\n":
continue
carid, cr, state, daysremaining = line.strip().split(",")
daysremaining = int(daysremaining)
name = cardb_id_to_name(carid)
manufacturer = cardb_id_to_makername(carid)
region = cardb_id_to_countrycode(carid)
if state == "new":
car = '<p class="lcar carnew">\n'+legend_template
elif state == "limited":
car = '<p class="lcar carlimited">\n'+legend_template
elif state == "soldout":
car = '<p class="lcar carsold">\n'+legend_template
else:
car = '<p class="lcar">\n'+legend_template
car = car.replace("%MANUFACTURER", manufacturer)
if cardata_exists(int(carid)):
car = car.replace("%NAME", f'<a href="cars/prices_{carid}.png" target="_blank">{name}</a>')
else:
car = car.replace("%NAME", name)
car = car.replace("%CREDITS", f"{int(cr):,}")
grind = int(cr)/2750000
play = int(cr)/400000
onetime = int(cr)/4000000
customrace = int(cr)/122053
nordslaps = int(cr)/6203.8
#if state != "soldout":
#if onetime > 1:
# car += f'\n <span id="onetime">Time to earn with one-time rewards: {int(onetime)+1} hours</span>'
#if grind > 1:
# car += f'\n <span id="grind">Optimal grinding time to earn: {int(grind)+1} hours</span>'
#if play > 50:
# car += f'\n <span id="play">Normal gameplay time to earn: {int(play)+1} hours 🤡</span>'
#elif play > 10:
# car += f'\n <span id="play">Normal gameplay time to earn: {int(play)+1} hours 💀</span>'
#elif play > 3:
# car += f'\n <span id="play">Normal gameplay time to earn: {int(play)+1} hours</span>'
#if customrace > 3:
# car += f'\n <span id="customrace">Number of <b>24 hour</b> custom races to earn: {int(customrace)+1}</span>'
#if nordslaps > 25:
# car += f'\n <span id="nordslaps">Gr.3 custom race Nordschleife laps to earn: {int(nordslaps)+1}</span>'
if state == "new":
car += '\n <span id="new">NEW</span>'
elif state == "limited":
car += '\n <span id="limited">Limited Stock</span>'
elif state == "soldout":
car += '\n <span id="soldout">SOLD OUT</span>'
if not fucked:
if daysremaining > 3:
car += f'\n <span id="days-estimate">Available For {daysremaining-2} More Days</span>'
elif daysremaining == 3:
car += f'\n <span id="days-remaining">Available For 1 More Day</span>'
elif daysremaining == 2:
car += f'\n <span id="days-remaining">Last Day Available</span>'
elif daysremaining == -1:
car += f'\n <span id="days-estimate">No Estimate Available</span>'
else:
car += f'\n <span id="days-estimate">No Estimate Available</span>'
rewardinfo = None
if carid in rewards.keys():
rewardinfo = rewards[carid]
car += '\n <span id="reward-text">REWARD<br>CAR</span>'
rewardtype = ""
match rewardinfo[0]:
case "menubook":
rewardtype = "Menu Book"
case "license":
rewardtype = "License:"
case "mission":
rewardtype = "Mission Set:"
car += f'\n <img id="reward-icon" src="img/open-book.svg" width="24" title="Reward from {rewardtype} {rewardinfo[1]}'
if rewardinfo[2] != "-":
car += f' All {rewardinfo[2].capitalize()}'
car += '"/>'
engineswapinfo = None
if carid in engineswaps.keys():
engineswapinfo = engineswaps[carid]
car += '\n <span id="engineswap-text">ENGINE<br>SWAP</span>'+\
f'\n <img id="engineswap-icon" src="img/engine-lcd.svg" width="24" title="Supports engine swap: {engineswapinfo[1]} from {cardb_id_to_name(engineswapinfo[0])}"/>'
trophyname = None
if carid in trophycars.keys():
trophyname = trophycars[carid]
car += '\n <span id="trophy-text">TROPHY<br>REQ.</span>'+\
f'\n <img id="trophy-icon" src="img/trophy.svg" width="24" title="Must be owned to earn the {trophyname} trophy."/>'
legendcars_section += car + '\n </p>'
jsondata["legend"]["cars"].append({
"carid": carid, "manufacturer": manufacturer, "region": region, "name": name, "credits": int(cr),
"state": "normal" if state == "new" else state, "estimatedays": daysremaining-1, "maxestimatedays": daysremaining-1, "new": state == "new",
"rewardcar": {"type": rewardinfo[0], "name": rewardinfo[1], "requirement": rewardinfo[2] if rewardinfo[2] != "-" else None} if rewardinfo is not None else None,
"engineswap": {"carid": engineswapinfo[0], "manufacturer": cardb_id_to_makername(engineswapinfo[0]),
"region": cardb_id_to_countrycode(engineswapinfo[0]), "name": cardb_id_to_name(engineswapinfo[0]),
"enginename": engineswapinfo[1]} if engineswapinfo is not None else None,
"trophycar": trophyname
})
##################################################
# handle html injects
##################################################
engineswaps_section = ""
with open(f"engine-swaps.html", encoding='utf-8') as f:
engineswaps_section = f.read()
ticketrewards_section = ""
with open(f"ticket-rewards.html", encoding='utf-8') as f:
ticketrewards_section = f.read()
menubookusedcars_section = ""
with open(f"menu-book-used.html", encoding="utf-8") as f:
menubookusedcars_section = f.read()
##################################################
# handle daily races
##################################################
"""
dailyraces_section = ""
lines = [] # type: list[str]
with open(f"_data/dailyrace/{dailyracedir[-1]}") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
jsondata["dailyrace"] = {
"date": dailyracedir[-1][:-4],
"races": [],
}
letters = ["A", "B", "C"] # lmao
i = -1
for line in lines:
i += 1
if line == "\n":
continue
courseid,laps,cars,starttype,fuelcons,tyrewear,cartype,category,specificcars,widebodyban,nitrousban,tyres,requiredtyres,bop,spec,carused,damage,shortcutpen,carcollisionpen,pitlanepen,time,offset = line.strip().split(",")
track = coursedb_id_to_name(courseid)
crsbase = coursedb_id_to_basename(courseid)
logo = coursedb_id_to_logoname(courseid)
region = coursedb_id_to_countrycode(courseid)
widebodyban = widebodyban == "y"
nitrousban = nitrousban == "y"
bop = bop == "y"
spec = spec == "y"
carused = carused if carused != "n" else False
damage = damage if damage != "n" else False
shortcutpen = shortcutpen == "y"
carcollisionpen = carcollisionpen == "y"
pitlanepen = pitlanepen == "y"
dailyrace = '<div class="dailyrace">'+dailyrace_template
flag = f"img/pdi-flag.png" if region == "pdi" else f"https://flagcdn.com/h24/{region}.png"
dailyrace = dailyrace.replace("%LETTER", letters[i])
dailyrace = dailyrace.replace("%TRACKLOGO", logo)
dailyrace = dailyrace.replace("%FLAG", flag)
dailyrace = dailyrace.replace("%TRACKNAME", track)
dailyrace = dailyrace.replace("%LAPS", laps)
dailyrace = dailyrace.replace("%CARS", cars)
dailyrace = dailyrace.replace("%STARTTYPE", "Grid Start" if starttype == "grid" else ("Grid with False Start Check" if starttype == "grid_with_false_start" else "Rolling Start"))
dailyrace = dailyrace.replace("%FUELCONS", fuelcons)
dailyrace = dailyrace.replace("%TYREWEAR", tyrewear)
dailyrace = dailyrace.replace("%TIME", time)
dailyrace = dailyrace.replace("%BOP", "On" if bop else "Off")
dailyrace = dailyrace.replace("%SPEC", "Specified" if spec else "Allowed")
if carused == "garage":
dailyrace = dailyrace.replace("%GARAGECAR", "Garage Car")
elif carused == "rent":
dailyrace = dailyrace.replace("%GARAGECAR", "Event-Specified Car")
elif carused == "any":
dailyrace = dailyrace.replace("%GARAGECAR", "Garage Car, Event-Specified Car")
else:
dailyrace = dailyrace.replace("%GARAGECAR", "ERROR: wtf???")
dailyrace = dailyrace.replace("%DAMAGE", damage.capitalize() if damage else "Disabled")
dailyrace = dailyrace.replace("%SHORTCUTPEN", "Light" if shortcutpen else "Disabled")
dailyrace = dailyrace.replace("%COLLISIONPEN", "Enabled" if carcollisionpen else "Disabled")
dailyrace = dailyrace.replace("%PITLANEPEN", "Enabled" if pitlanepen else "Disabled")
mincheck = int(offset)
schedule = ""
scheduledata = []
while mincheck < 60:
schedule += f"XX:{mincheck:02}, "
scheduledata.append(mincheck)
mincheck += int(time)+5
schedule = schedule[:-2]
dailyrace = dailyrace.replace("%SCHEDULE", schedule)
regulations = ''
#HACK: todo, actual "no dr/sr updates" support
if i == 0:
regulations += '\n <span class="racedetailrow"><span class="specifiedcar" style="color: #fe2;">No DR / SR Updates</span></span>'
#regulations += '\n <span class="racedetailrow"><span class="specifiedcar" style="color: #271;">DR / SR Updates enabled</span></span>'
if cartype == "specific" or cartype == "both" or cartype == "specific_tuninglimits":
regulations += '\n <span class="racedetailsection" id="specificcars">'+\
'\n <div class="racedetailheader" id="specificcars">Regulations (Specified Car)</div>'
x = 0
for carid in specificcars.split("|"):
car = cardb_id_to_name(carid)
#HACK: rental hack
if carid in []:
regulations += f'\n <div class="racedetailrow"><span class="specifiedcar">{car}</span> [CANNOT BE RENTED]</div>'
else:
regulations += f'\n <div class="racedetailrow"><span class="specifiedcar">{car}</span></div>'
#if x == 0:
# regulations += '\n <div class="racedetailrow">'
#regulations += f'\n <span class="specifiedcar">{car}</span>'
#x += 1
#if x == 2:
# x = 0
# regulations += '\n </div>'
#if x != 0:
# regulations += '\n </div>'
regulations += '\n </span>'
regulations += '\n <span class="racedetailsection" id="regulations">'+\
'\n <div class="racedetailheader" id="regulations">Regulations</div>'
if cartype == "category" or cartype == "both":
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Category</span>'+\
f'\n <span class="racedetailcontent" id="category">{category}</span>'+\
'\n </div>'
elif cartype == "pp":
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Car Type</span>'+\
f'\n <span class="racedetailcontent" id="category">{category}</span>'+\
'\n </div>'
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">PP</span>'+\
f'\n <span class="racedetailcontent" id="category">{specificcars} or less</span>'+\
'\n </div>'
elif cartype == "dt_tuninglimits":
splitcategory = category.split("|")
if len(splitcategory) == 5:
cartag, PSpower, HPpower, KGweight, LBweight = splitcategory
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Car Type</span>'+\
f'\n <span class="racedetailcontent" id="category">{cartag}</span>'+\
'\n </div>'
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Drivetrain</span>'+\
f'\n <span class="racedetailcontent" id="category">{specificcars}</span>'+\
'\n </div>'
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Power</span>'+\
f'\n <span class="racedetailcontent" id="category">{PSpower} PS or less / {HPpower} HP or less</span>'+\
'\n </div>'
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Weight</span>'+\
f'\n <span class="racedetailcontent" id="category">At least {KGweight} kg / At least {LBweight} lbs.</span>'+\
'\n </div>'
elif cartype == "specific_tuninglimits":
splitcategory = category.split("|")
if len(splitcategory) == 4:
PSpower, HPpower, KGweight, LBweight = splitcategory
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Power</span>'+\
f'\n <span class="racedetailcontent" id="category">{PSpower} PS or less / {HPpower} HP or less</span>'+\
'\n </div>'
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="categorylabel">Weight</span>'+\
f'\n <span class="racedetailcontent" id="category">At least {KGweight} kg / At least {LBweight} lbs.</span>'+\
'\n </div>'
if widebodyban:
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="widebodylabel">Wide Body</span>'+\
'\n <span class="racedetailcontent" id="widebody">Prohibited</span>'+\
'\n </div>'
if nitrousban:
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="nitrouslabel">Nitrous</span>'+\
'\n <span class="racedetailcontent" id="nitrous">Cannot be Fitted</span>'+\
'\n </div>'
if tyres != "-":
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="">Tyre Choice</span>'+\
f'\n <span class="racedetailcontent" id="">'
for tyre in tyres.split("|"):
regulations += f'<div class="tyre" id="{tyre}">{tyre}</div> '
regulations = regulations[:-1] + '</span>\n </div>'
if requiredtyres != "-":
regulations += '\n <div class="racedetailrow">'+\
'\n <span class="racedetaillabel" id="">Required Tyre Type</span>'+\
f'\n <span class="racedetailcontent" id="">'
for tyre in requiredtyres.split("|"):
regulations += f'<div class="tyre" id="{tyre}">{tyre}</div> '
regulations = regulations[:-1] + '</span>\n </div>'
regulations += '\n </span>'
dailyrace = dailyrace.replace("%REGULATIONS", regulations)
if bop:
dailyrace += '<div class="boprace">BoP Race</div>'
dailyrace += '\n</div>'
dailyraces_section += dailyrace
jsondata["dailyrace"]["races"].append({
"courseid": courseid, "crsbase": crsbase, "track": track, "logo": f'img/track/{logo}.png', "region": region,
"laps": int(laps), "cars": int(cars), "starttype": starttype, "fuelcons": int(fuelcons), "tyrewear": int(tyrewear),
"cartype": cartype, "widebodyban": widebodyban, "nitrousban": nitrousban, "tyres": tyres.split("|"), "requiredtyres": requiredtyres.split("|"),
"bop": bop, "carsettings_specified": spec, "garagecar": True if (carused == "garage" or carused == "both") else False, "carused": carused,
"damage": damage, "shortcutpen": shortcutpen, "carcollisionpen": carcollisionpen, "pitlanepen": pitlanepen,
"time": int(time), "offset": int(offset), "schedule": scheduledata
})
if cartype == "category" or cartype == "both":
jsondata["dailyrace"]["races"][-1]["category"] = category
if cartype == "specific" or cartype == "both" or cartype == "specific_tuninglimits":
jsondata["dailyrace"]["races"][-1]["specificcars_ids"] = specificcars.split("|")
jsondata["dailyrace"]["races"][-1]["specificcars"] = list(map(cardb_id_to_name, jsondata["dailyrace"]["races"][-1]["specificcars_ids"]))
if cartype == "pp":
jsondata["dailyrace"]["races"][-1]["cartags"] = category
jsondata["dailyrace"]["races"][-1]["pplimit"] = specificcars
if cartype == "dt_tuninglimits":
jsondata["dailyrace"]["races"][-1]["cartags"] = cartag
jsondata["dailyrace"]["races"][-1]["drivetrainlimit"] = specificcars
if cartype == "specific_tuninglimits" or cartype == "dt_tuninglimits":
jsondata["dailyrace"]["races"][-1]["pslimit"] = PSpower
jsondata["dailyrace"]["races"][-1]["kglimit"] = KGweight
"""
jsondata["dailyrace"] = {
"date": "70-01-01",
"races": [],
}
for i in range(3):
jsondata["dailyrace"]["races"].append({
"courseid": 0, "crsbase": "No Longer Updated", "track": "No Longer Updated", "logo": f'img/track/nothing.png', "region": "pd",
"laps": 0, "cars": 0, "starttype": "You can check Twitter instead: @Mistah_MCA at the start of a week", "fuelcons": 0, "tyrewear": 0,
"cartype": "category", "widebodyban": False, "nitrousban": False, "tyres": [], "requiredtyres": [],
"bop": False, "carsettings_specified": False, "garagecar": False, "carused": False,
"damage": False, "shortcutpen": False, "carcollisionpen": False, "pitlanepen": False,
"time": 0, "offset": 0, "schedule": "Tell your bot author to stop trying to get daily races :)"
})
##################################################
# do replacements
##################################################
html = html.replace("%USEDCARS_UPDATESTRING", useddir[-1].replace(".csv", ""))
html = html.replace("%USEDCARS_SECTION", usedcars_section)
html = html.replace("%LEGENDCARS_UPDATESTRING", legenddir[-1].replace(".csv", ""))
html = html.replace("%LEGENDCARS_SECTION", legendcars_section)
html = html.replace("%ENGINESWAPS_SECTION", engineswaps_section)
html = html.replace("%TICKETREWARDS_SECTION", ticketrewards_section)
html = html.replace("%MENUBOOKUSEDCARS_SECTION", menubookusedcars_section)
html = html.replace("%DAILYRACES_UPDATESTRING", dailyracedir[-1].replace(".csv", ""))
#html = html.replace("%DAILYRACES_SECTION", dailyraces_section)
#html = html.replace("%BOP_SECTION", "Coming soon! (Well, probably after economy changes make obtaining Gr.3 cars more reasonable.)<br>In the meantime, you can reference Gran Turismo Sport's BoP here:")
##################################################
# output built html & json data
##################################################
from time import sleep
if os.path.exists("build"):
shutil.rmtree("build")
sleep(1) # build folder is so large we need to delay now (windows moment)
os.mkdir("build")
os.mkdir("build/cars")
with open("build/index.html", "w", encoding='utf-8') as f:
f.write(html)
with open(f"build/data.json", "w") as f:
json.dump(jsondata, f)
FILES_TO_COPY = [
"course-bop.html",
"campaign-rewards.html",
"engine-swaps.html",
"extended-level-calculator.html",
"extended-level-calculator.js",
"gr1-hybrid-info.html",
"json-dev-notes.html",
"menu-book-used.html",
"ticket-rewards.html",
"legacy-changes.html",
"style.css",
"style-simple.css"
]
FOLDERS_TO_COPY = [
"fonts",
"img"
]
for file in FILES_TO_COPY:
shutil.copyfile(f"{file}", f"build/{file}")
for folder in FOLDERS_TO_COPY:
shutil.copytree(f"{folder}", f"build/{folder}")
shutil.copytree(f"_data", f"build/data")
##################################################
# per car data
##################################################
for line in db_cars:
id, _, _ = line.strip().split(",")
id = int(id)
if cardata_exists(id):
cardata_plot(id)