forked from OutlawByteStudios/Persistent-Kingdoms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule_generated_strings.py
More file actions
57 lines (47 loc) · 2.09 KB
/
module_generated_strings.py
File metadata and controls
57 lines (47 loc) · 2.09 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
####################################################################################################################
# Generates strings at module system build time.
#
# To use, make a function called "generate_" then the string name which will be combined with the generated text.
####################################################################################################################
from module_items import *
from module_scene_props import *
def process_item(processor, item_str, entry=None):
try:
return items[processor.process_id(item_str)]
except Exception as e:
if not e.entry:
if entry:
e.entry = "crafting data for %s" % (entry)
else:
e.entry = "crafting data"
raise
def crafting_book_generator(string, processor, item_type_checker):
crafting_list = [string]
for entry in crafting_data:
item = process_item(processor, entry[0])
if not item_type_checker(item[3] & 0xff, entry[1][0][0]):
continue
crafting_list.extend([item[1], ": "])
for i, resource in enumerate(entry[2]):
if i > 0:
crafting_list.append(", ")
if isinstance(resource, tuple):
crafting_list.extend([str(resource[1]), " "])
resource = resource[0]
crafting_list.append(process_item(processor, resource, entry[0])[1])
crafting_list.append("^^")
return "".join(crafting_list)
def type_is_armor(item_type):
return itp_type_head_armor <= item_type <= itp_type_hand_armor
def is_weapon(item_type, skill):
return not type_is_armor(item_type)
def generate_book_of_weapons(string, processor):
return crafting_book_generator(string, processor, is_weapon)
def is_clothing(item_type, skill):
return type_is_armor(item_type) and skill == "skl_tailoring"
def generate_book_of_clothing(string, processor):
return crafting_book_generator(string, processor, is_clothing)
def is_armor(item_type, skill):
return type_is_armor(item_type) and skill == "skl_engineer"
def generate_book_of_armor(string, processor):
return crafting_book_generator(string, processor, is_armor)