Skip to content

technology

tiargus.technology

Technology/research data model.

Provides:

  • ResearchCategory — the eight Terra Invicta research categories, with curated aliases for interactive use.

ResearchCategory

Bases: AliasedStrEnum

One of the eight research categories in Terra Invicta.

Research categories are a general taxonomy: every technology (global research) and engineering project belongs to one, and each category's research bonus is tracked independently. That per-category bonus is contributed by several sources — councilor traits, equipped orgs (see Org.research_bonuses), hab modules, certain ship utility modules, and alien-activity investigations — so this enum is not specific to any one of them.

Each member's value is the raw category string used across the game data (e.g. an org template's techBonuses list). Members subclass str, so a member compares and hashes equal to its raw key (e.g. ResearchCategory.ENERGY == "Energy"), keeping it interchangeable with those raw strings.

Each member also carries a curated tuple of synonyms — short, friendly names intended for interactive (REPL) use:

Member Raw key Synonyms
ENERGY Energy
INFORMATION_SCIENCE InformationScience Information, Info
LIFE_SCIENCE LifeScience Life, Bio
MATERIALS Materials Material, Mat
MILITARY_SCIENCE MilitaryScience Military, Mil
SOCIAL_SCIENCE SocialScience Social, Soc
SPACE_SCIENCE SpaceScience Space
XENOLOGY Xenology Xeno

Use from_alias to resolve any raw key, member name, or synonym (case- and separator-insensitively) to a member, and the aliases property to list every accepted spelling for a member.

Members are declared as NAME = (raw_key, *synonyms).

Source code in src/tiargus/technology.py
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
class ResearchCategory(AliasedStrEnum):
    """One of the eight research categories in Terra Invicta.

    Research categories are a general taxonomy: every technology (global
    research) and engineering project belongs to one, and each category's
    research bonus is tracked independently.  That per-category bonus is
    contributed by several sources — councilor traits, equipped
    [orgs][tiargus.orgs.Org] (see
    [Org.research_bonuses][tiargus.orgs.Org]), hab modules, certain ship
    utility modules, and alien-activity investigations — so this enum is not
    specific to any one of them.

    Each member's value is the raw category string used across the game data
    (e.g. an org template's ``techBonuses`` list).  Members subclass ``str``, so
    a member compares and hashes equal to its raw key
    (e.g. ``ResearchCategory.ENERGY == "Energy"``), keeping it interchangeable
    with those raw strings.

    Each member also carries a curated tuple of **synonyms** — short, friendly
    names intended for interactive (REPL) use:

    | Member | Raw key | Synonyms |
    | ------ | ------- | -------- |
    | ``ENERGY`` | ``Energy`` | |
    | ``INFORMATION_SCIENCE`` | ``InformationScience`` | ``Information``, ``Info`` |
    | ``LIFE_SCIENCE`` | ``LifeScience`` | ``Life``, ``Bio`` |
    | ``MATERIALS`` | ``Materials`` | ``Material``, ``Mat`` |
    | ``MILITARY_SCIENCE`` | ``MilitaryScience`` | ``Military``, ``Mil`` |
    | ``SOCIAL_SCIENCE`` | ``SocialScience`` | ``Social``, ``Soc`` |
    | ``SPACE_SCIENCE`` | ``SpaceScience`` | ``Space`` |
    | ``XENOLOGY`` | ``Xenology`` | ``Xeno`` |

    Use [from_alias][tiargus.technology.ResearchCategory.from_alias] to
    resolve any raw key, member name, or synonym (case- and
    separator-insensitively) to a member, and the
    [aliases][tiargus.technology.ResearchCategory.aliases] property to
    list every accepted spelling for a member.

    Members are declared as ``NAME = (raw_key, *synonyms)``.
    """

    ENERGY = ("Energy",)
    INFORMATION_SCIENCE = ("InformationScience", "Information", "Info")
    LIFE_SCIENCE = ("LifeScience", "Life", "Bio")
    MATERIALS = ("Materials", "Material", "Mat")
    MILITARY_SCIENCE = ("MilitaryScience", "Military", "Mil")
    SOCIAL_SCIENCE = ("SocialScience", "Social", "Soc")
    SPACE_SCIENCE = ("SpaceScience", "Space")
    XENOLOGY = ("Xenology", "Xeno")

aliases property

Every spelling that resolves to this member, in declaration order.

Comprises the raw value, the member name, and the curated synonyms, de-duplicated. Handy for listing accepted inputs in a REPL.

synonyms property

The curated friendly aliases for this member (excludes value & name).

from_alias(name) classmethod

Resolve a flexible alias to its canonical member.

Lookup is case- and separator-insensitive (spaces, underscores, and hyphens are ignored) and a trailing "bonus" is optional. A member's raw value, its name, and its curated synonyms are all valid aliases.

Parameters:

Name Type Description Default
name str

The alias to resolve.

required

Returns:

Type Description
_AS

The matching member.

Raises:

Type Description
ValueError

If no member matches the normalized alias.

Source code in src/tiargus/_aliased_enum.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
@classmethod
def from_alias(cls: type[_AS], name: str) -> _AS:
    """Resolve a flexible alias to its canonical member.

    Lookup is case- and separator-insensitive (spaces, underscores, and
    hyphens are ignored) and a trailing ``"bonus"`` is optional.  A
    member's raw value, its name, and its curated ``synonyms`` are all valid
    aliases.

    Args:
        name: The alias to resolve.

    Returns:
        The matching member.

    Raises:
        ValueError: If no member matches the normalized alias.
    """
    try:
        return cls._alias_index()[_normalize_alias(name)]
    except KeyError:
        raise ValueError(f"Unknown {cls.__name__} alias: {name!r}") from None