Skip to content

Terraria: Add crate logic #2841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 55 additions & 56 deletions worlds/terraria/Checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def validate_conditions(
if condition not in {
"npc",
"calamity",
"grindy",
"pickaxe",
"hammer",
"mech_boss",
Expand Down Expand Up @@ -221,62 +222,60 @@ def mark_progression(
mark_progression(conditions, progression, rules, rule_indices, loc_to_item)


def read_data() -> (
Tuple[
# Goal to rule index that ends that goal's range and the locations required
List[Tuple[int, Set[str]]],
# Rules
List[
Tuple[
# Rule
str,
# Flag to flag arg
Dict[str, Union[str, int, None]],
# True = or, False = and, None = N/A
Union[bool, None],
# Conditions
List[
Tuple[
# True = positive, False = negative
bool,
# Condition type
int,
# Condition name or list (True = or, False = and, None = N/A) (list shares type with outer)
Union[str, Tuple[Union[bool, None], List]],
# Condition arg
Union[str, int, None],
]
],
]
],
# Rule to rule index
Dict[str, int],
# Label to rewards
Dict[str, List[str]],
# Reward to flags
Dict[str, Set[str]],
# Item name to ID
Dict[str, int],
# Location name to ID
Dict[str, int],
# NPCs
List[str],
# Pickaxe to pick power
Dict[str, int],
# Hammer to hammer power
Dict[str, int],
# Mechanical bosses
List[str],
# Calamity final bosses
List[str],
# Progression rules
Set[str],
# Armor to minion count,
Dict[str, int],
# Accessory to minion count,
Dict[str, int],
]
):
def read_data() -> Tuple[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this monster have to be built out of recursive tuples?
I'm scared

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh god I missed that now I’m shaking in my boots

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a reason for it. it accurately represents the data structure of the output data or something idk that's chatgpts word

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the outer tuple is fine, it gets split up on line 719, but yeah the rules type is messy. It's not relevant to this pr, though. It just got caught by my formatter. I'll move it to a class if I end up doing parser reworks

# Goal to rule index that ends that goal's range and the locations required
List[Tuple[int, Set[str]]],
# Rules
List[
Tuple[
# Rule
str,
# Flag to flag arg
Dict[str, Union[str, int, None]],
# True = or, False = and, None = N/A
Union[bool, None],
# Conditions
List[
Tuple[
# True = positive, False = negative
bool,
# Condition type
int,
# Condition name or list (True = or, False = and, None = N/A) (list shares type with outer)
Union[str, Tuple[Union[bool, None], List]],
# Condition arg
Union[str, int, None],
]
],
]
],
# Rule to rule index
Dict[str, int],
# Label to rewards
Dict[str, List[str]],
# Reward to flags
Dict[str, Set[str]],
# Item name to ID
Dict[str, int],
# Location name to ID
Dict[str, int],
# NPCs
List[str],
# Pickaxe to pick power
Dict[str, int],
# Hammer to hammer power
Dict[str, int],
# Mechanical bosses
List[str],
# Calamity final bosses
List[str],
# Progression rules
Set[str],
# Armor to minion count,
Dict[str, int],
# Accessory to minion count,
Dict[str, int],
]:
next_id = 0x7E0000
item_name_to_id = {}

Expand Down
14 changes: 7 additions & 7 deletions worlds/terraria/Rules.dsv
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ Spider Armor; ArmorMinions(3);
Cross Necklace; ; Wall of Flesh;
Altar; ; Wall of Flesh & @hammer(80);
Begone, Evil!; Achievement; Altar;
Cobalt Ore; ; ((~@calamity & Altar) | (@calamity & Wall of Flesh)) & @pickaxe(100);
Cobalt Ore; ; (((~@calamity & Altar) | (@calamity & Wall of Flesh)) & @pickaxe(100)) | Wall of Flesh;
Extra Shiny!; Achievement; Cobalt Ore | Mythril Ore | Adamantite Ore | Chlorophyte Ore;
Cobalt Bar; ; Cobalt Ore;
Cobalt Bar; ; Cobalt Ore | Wall of Flesh;
Cobalt Pickaxe; Pickaxe(110); Cobalt Bar;
Soul of Night; ; Wall of Flesh | (@calamity & Altar);
Hallow; ; Wall of Flesh;
Expand All @@ -249,7 +249,7 @@ Blessed Apple; ;
Rod of Discord; ; Hallow;
Gelatin World Tour; Achievement | Grindy; Dungeon & Wall of Flesh & Hallow & #King Slime;
Soul of Flight; ; Wall of Flesh;
Head in the Clouds; Achievement; (Soul of Flight & ((Hardmode Anvil & (Soul of Light | Soul of Night | Pixie Dust | Wall of Flesh | Solar Eclipse | @mech_boss(1) | Plantera | Spectre Bar | #Golem)) | (Shroomite Bar & Autohammer) | #Mourning Wood | #Pumpking)) | Steampunker | (Wall of Flesh & Witch Doctor) | (Solar Eclipse & Plantera) | #Everscream | #Old One's Army Tier 3 | #Empress of Light | #Duke Fishron | (Fragment & Luminite Bar & Ancient Manipulator); // Leaf Wings are Post-Plantera in 1.4.4
Head in the Clouds; Achievement; @grindy | (Soul of Flight & ((Hardmode Anvil & (Soul of Light | Soul of Night | Pixie Dust | Wall of Flesh | Solar Eclipse | @mech_boss(1) | Plantera | Spectre Bar | #Golem)) | (Shroomite Bar & Autohammer) | #Mourning Wood | #Pumpking)) | Steampunker | (Wall of Flesh & Witch Doctor) | (Solar Eclipse & Plantera) | #Everscream | #Old One's Army Tier 3 | #Empress of Light | #Duke Fishron | (Fragment & Luminite Bar & Ancient Manipulator); // Leaf Wings are Post-Plantera in 1.4.4
Bunny; Npc; Zoologist & Wall of Flesh; // Extremely simplified
Forbidden Fragment; ; Sandstorm & Wall of Flesh;
Astral Infection; Calamity; Wall of Flesh;
Expand All @@ -274,13 +274,13 @@ Pirate; Npc;
Queen Slime; Location | Item; Hallow;

// Aquatic Scourge
Mythril Ore; ; ((~@calamity & Altar) | (@calamity & @mech_boss(1))) & @pickaxe(110);
Mythril Bar; ; Mythril Ore;
Mythril Ore; ; (((~@calamity & Altar) | (@calamity & @mech_boss(1))) & @pickaxe(110)) | (Wall of Flesh & (~@calamity | @mech_boss(1)));
Mythril Bar; ; Mythril Ore | (Wall of Flesh & (~@calamity | @mech_boss(1)));
Hardmode Anvil; ; Mythril Bar;
Mythril Pickaxe; Pickaxe(150); Hardmode Anvil & Mythril Bar;
Adamantite Ore; ; ((~@calamity & Altar) | (@calamity & @mech_boss(2))) & @pickaxe(150);
Adamantite Ore; ; (((~@calamity & Altar) | (@calamity & @mech_boss(2))) & @pickaxe(150)) | (Wall of Flesh & (~@calamity | @mech_boss(2)));
Hardmode Forge; ; Hardmode Anvil & Adamantite Ore & Hellforge;
Adamantite Bar; ; Hardmode Forge & Adamantite Ore;
Adamantite Bar; ; (Hardmode Forge & Adamantite Ore) | (Wall of Flesh & (~@calamity | @mech_boss(2)));
Adamantite Pickaxe; Pickaxe(180); Hardmode Anvil & Adamantite Bar;
Forbidden Armor; ArmorMinions(2); Hardmode Anvil & Adamantite Bar & Forbidden Fragment;
Aquatic Scourge; Calamity | Location | Item;
Expand Down
2 changes: 2 additions & 0 deletions worlds/terraria/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ def check_condition(
return not sign
elif condition == "calamity":
return sign == self.calamity
elif condition == "grindy":
return sign == (self.multiworld.achievements[self.player].value >= 2)
elif condition == "pickaxe":
if type(arg) is not int:
raise Exception("@pickaxe requires an integer argument")
Expand Down
Loading