-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_1.py
59 lines (51 loc) · 1.88 KB
/
script_1.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
import os
import random
import ast
import file_operations
from faker import Faker
def replace_letters_in_skillnames_to_runic():
with open("letters_mapping.txt") as file:
data = file.read()
letters_mapping = ast.literal_eval(data)
with open("skills.txt", 'r') as file:
list_of_skills = file.readlines()
for index in range(len(list_of_skills)):
for key in letters_mapping.keys():
list_of_skills[index] = list_of_skills[index].replace(key, letters_mapping[key])
return list_of_skills
def randomize_npc():
fake = Faker("ru_RU")
first_name = fake.first_name()
last_name = fake.last_name()
job = fake.job()
town = fake.city()
strength = random.randint(3, 18)
agility = random.randint(3, 18)
endurance = random.randint(3, 18)
intelligence = random.randint(3, 18)
luck = random.randint(3, 18)
skills = random.sample(replace_letters_in_skillnames_to_runic(), 3)
return first_name, last_name, job, town, strength, agility, endurance, intelligence, luck, skills
def main():
if not os.path.isdir("NPC_Cards"):
os.mkdir("NPC_Cards")
for i in range(10):
i = i + 1
context = {
"first_name": randomize_npc()[0],
"last_name": randomize_npc()[1],
"job": randomize_npc()[2],
"town": randomize_npc()[3],
"strength": randomize_npc()[4],
"agility": randomize_npc()[5],
"endurance": randomize_npc()[6],
"intelligence": randomize_npc()[7],
"luck": randomize_npc()[8],
"skill_1": randomize_npc()[9][0],
"skill_2": randomize_npc()[9][1],
"skill_3": randomize_npc()[9][2]
}
card_name = f"NPC_card_{i}.svg"
file_operations.render_template("charsheet.svg", f"NPC_Cards/{card_name}", context)
if __name__ == "__main__":
main()