|
| 1 | +# Copyright 2025-2025 the openage authors. See copying.md for legal info. |
| 2 | + |
| 3 | +""" |
| 4 | +Create the attributes used in AoC. |
| 5 | +
|
| 6 | +TODO: Fill translations |
| 7 | +""" |
| 8 | +from __future__ import annotations |
| 9 | +import typing |
| 10 | + |
| 11 | +from .....entity_object.conversion.converter_object import RawAPIObject, ConverterObjectGroup |
| 12 | +from .....value_object.conversion.forward_ref import ForwardRef |
| 13 | + |
| 14 | +if typing.TYPE_CHECKING: |
| 15 | + from .....entity_object.conversion.aoc.genie_object_container import GenieObjectContainer |
| 16 | + |
| 17 | +ATTRIBUTE_PARENT = "engine.util.attribute.Attribute" |
| 18 | +ATTRIBUTES_LOCATION = "data/util/attribute/" |
| 19 | + |
| 20 | + |
| 21 | +def generate_attributes( |
| 22 | + full_data_set: GenieObjectContainer, |
| 23 | + pregen_converter_group: ConverterObjectGroup |
| 24 | +) -> None: |
| 25 | + """ |
| 26 | + Generate Attribute objects. |
| 27 | +
|
| 28 | + :param full_data_set: Storage for all converted objects and metadata. |
| 29 | + :param pregen_converter_group: Stores all pregenerated nyan objects. |
| 30 | + """ |
| 31 | + _generate_hp_attribute(full_data_set, pregen_converter_group) |
| 32 | + _generate_faith_attribute(full_data_set, pregen_converter_group) |
| 33 | + |
| 34 | + |
| 35 | +def _generate_hp_attribute( |
| 36 | + full_data_set: GenieObjectContainer, |
| 37 | + pregen_converter_group: ConverterObjectGroup |
| 38 | +) -> None: |
| 39 | + """ |
| 40 | + Generate the HP attribute. |
| 41 | +
|
| 42 | + :param full_data_set: Storage for all converted objects and metadata. |
| 43 | + :param pregen_converter_group: Stores all pregenerated nyan objects. |
| 44 | + """ |
| 45 | + pregen_nyan_objects = full_data_set.pregen_nyan_objects |
| 46 | + api_objects = full_data_set.nyan_api_objects |
| 47 | + |
| 48 | + health_ref_in_modpack = "util.attribute.types.Health" |
| 49 | + health_raw_api_object = RawAPIObject(health_ref_in_modpack, |
| 50 | + "Health", api_objects, |
| 51 | + ATTRIBUTES_LOCATION) |
| 52 | + health_raw_api_object.set_filename("types") |
| 53 | + health_raw_api_object.add_raw_parent(ATTRIBUTE_PARENT) |
| 54 | + |
| 55 | + name_forward_ref = ForwardRef(pregen_converter_group, |
| 56 | + "util.attribute.types.Health.HealthName") |
| 57 | + health_raw_api_object.add_raw_member("name", name_forward_ref, |
| 58 | + ATTRIBUTE_PARENT) |
| 59 | + abbrv_forward_ref = ForwardRef(pregen_converter_group, |
| 60 | + "util.attribute.types.Health.HealthAbbreviation") |
| 61 | + health_raw_api_object.add_raw_member("abbreviation", abbrv_forward_ref, |
| 62 | + ATTRIBUTE_PARENT) |
| 63 | + |
| 64 | + pregen_converter_group.add_raw_api_object(health_raw_api_object) |
| 65 | + pregen_nyan_objects.update({health_ref_in_modpack: health_raw_api_object}) |
| 66 | + |
| 67 | + name_value_parent = "engine.util.language.translated.type.TranslatedString" |
| 68 | + health_name_ref_in_modpack = "util.attribute.types.Health.HealthName" |
| 69 | + health_name_value = RawAPIObject(health_name_ref_in_modpack, "HealthName", |
| 70 | + api_objects, ATTRIBUTES_LOCATION) |
| 71 | + health_name_value.set_filename("types") |
| 72 | + health_name_value.add_raw_parent(name_value_parent) |
| 73 | + health_name_value.add_raw_member("translations", [], name_value_parent) |
| 74 | + |
| 75 | + pregen_converter_group.add_raw_api_object(health_name_value) |
| 76 | + pregen_nyan_objects.update({health_name_ref_in_modpack: health_name_value}) |
| 77 | + |
| 78 | + abbrv_value_parent = "engine.util.language.translated.type.TranslatedString" |
| 79 | + health_abbrv_ref_in_modpack = "util.attribute.types.Health.HealthAbbreviation" |
| 80 | + health_abbrv_value = RawAPIObject(health_abbrv_ref_in_modpack, "HealthAbbreviation", |
| 81 | + api_objects, ATTRIBUTES_LOCATION) |
| 82 | + health_abbrv_value.set_filename("types") |
| 83 | + health_abbrv_value.add_raw_parent(abbrv_value_parent) |
| 84 | + health_abbrv_value.add_raw_member("translations", [], abbrv_value_parent) |
| 85 | + |
| 86 | + pregen_converter_group.add_raw_api_object(health_abbrv_value) |
| 87 | + pregen_nyan_objects.update({health_abbrv_ref_in_modpack: health_abbrv_value}) |
| 88 | + |
| 89 | + |
| 90 | +def _generate_faith_attribute( |
| 91 | + full_data_set: GenieObjectContainer, |
| 92 | + pregen_converter_group: ConverterObjectGroup |
| 93 | +) -> None: |
| 94 | + """ |
| 95 | + Generate the Faith attribute. |
| 96 | +
|
| 97 | + :param full_data_set: Storage for all converted objects and metadata. |
| 98 | + :param pregen_converter_group: Stores all pregenerated nyan objects. |
| 99 | + """ |
| 100 | + pregen_nyan_objects = full_data_set.pregen_nyan_objects |
| 101 | + api_objects = full_data_set.nyan_api_objects |
| 102 | + |
| 103 | + faith_ref_in_modpack = "util.attribute.types.Faith" |
| 104 | + faith_raw_api_object = RawAPIObject(faith_ref_in_modpack, |
| 105 | + "Faith", api_objects, |
| 106 | + ATTRIBUTES_LOCATION) |
| 107 | + faith_raw_api_object.set_filename("types") |
| 108 | + faith_raw_api_object.add_raw_parent(ATTRIBUTE_PARENT) |
| 109 | + |
| 110 | + name_forward_ref = ForwardRef(pregen_converter_group, |
| 111 | + "util.attribute.types.Faith.FaithName") |
| 112 | + faith_raw_api_object.add_raw_member("name", name_forward_ref, |
| 113 | + ATTRIBUTE_PARENT) |
| 114 | + abbrv_forward_ref = ForwardRef(pregen_converter_group, |
| 115 | + "util.attribute.types.Faith.FaithAbbreviation") |
| 116 | + faith_raw_api_object.add_raw_member("abbreviation", abbrv_forward_ref, |
| 117 | + ATTRIBUTE_PARENT) |
| 118 | + |
| 119 | + pregen_converter_group.add_raw_api_object(faith_raw_api_object) |
| 120 | + pregen_nyan_objects.update({faith_ref_in_modpack: faith_raw_api_object}) |
| 121 | + |
| 122 | + name_value_parent = "engine.util.language.translated.type.TranslatedString" |
| 123 | + faith_name_ref_in_modpack = "util.attribute.types.Faith.FaithName" |
| 124 | + faith_name_value = RawAPIObject(faith_name_ref_in_modpack, "FaithName", |
| 125 | + api_objects, ATTRIBUTES_LOCATION) |
| 126 | + faith_name_value.set_filename("types") |
| 127 | + faith_name_value.add_raw_parent(name_value_parent) |
| 128 | + faith_name_value.add_raw_member("translations", [], name_value_parent) |
| 129 | + |
| 130 | + pregen_converter_group.add_raw_api_object(faith_name_value) |
| 131 | + pregen_nyan_objects.update({faith_name_ref_in_modpack: faith_name_value}) |
| 132 | + |
| 133 | + abbrv_value_parent = "engine.util.language.translated.type.TranslatedString" |
| 134 | + faith_abbrv_ref_in_modpack = "util.attribute.types.Faith.FaithAbbreviation" |
| 135 | + faith_abbrv_value = RawAPIObject(faith_abbrv_ref_in_modpack, "FaithAbbreviation", |
| 136 | + api_objects, ATTRIBUTES_LOCATION) |
| 137 | + faith_abbrv_value.set_filename("types") |
| 138 | + faith_abbrv_value.add_raw_parent(abbrv_value_parent) |
| 139 | + faith_abbrv_value.add_raw_member("translations", [], abbrv_value_parent) |
| 140 | + |
| 141 | + pregen_converter_group.add_raw_api_object(faith_abbrv_value) |
| 142 | + pregen_nyan_objects.update({faith_abbrv_ref_in_modpack: faith_abbrv_value}) |
0 commit comments