Skip to content

Sims 4: Rules Refactor Part 1 - #14

Merged
benny-dreamly merged 71 commits into
sims4-devfrom
sims4-dev-events
Jan 8, 2026
Merged

Sims 4: Rules Refactor Part 1#14
benny-dreamly merged 71 commits into
sims4-devfrom
sims4-dev-events

Conversation

@benny-dreamly

@benny-dreamly benny-dreamly commented Jan 6, 2026

Copy link
Copy Markdown
Member

What is this fixing or adding?

This branch is a refactor of the rules file to be more maintainable. Currently there are a few things left to be done, notably:

  • Use events for the completion condition
  • Migrate the career rules to use the has_skill helper
  • Test to make sure there were no regressions

Migration of career rules to the has_skill helper will happen in part 2 of the refactor.

How was this tested?

I haven't tested this yet. I'm still mid refactor, however testing will come soon.

Summary by CodeRabbit

  • New Features

    • Added many aspiration-completion events and matching collectible items; events can be created as region-scoped locations and may appear locked.
    • New public capabilities to create and wire items, locations, events and map goals to events.
  • Chores

    • Expanded skills and location datasets, tightened type declarations, and bumped world/version.
  • Bug Fixes

    • Validation for skill entries and small location/name formatting fixes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • .github/workflows/test.yml is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Adds completed-aspiration event constants and a GOAL_TO_EVENT_MAPPING; updates Sims4World public API (new/changed create_* methods and event-location wiring during region setup); expands Items typing and skill entries; annotates location tables with explicit dict types and bumps version/metadata.

Changes

Cohort / File(s) Summary
Event name constants
worlds/sims4/Names/EventNames.py
New module exporting paired completed-aspiration string constants (e.g., bodybuilder, bodybuilder_item) for aspiration-to-event mapping.
World logic & public API
worlds/sims4/__init__.py
Adds GOAL_TO_EVENT_MAPPING ClassVar; adds create_event_location; updates signatures/return types for create_item, create_location, create_event, create_region, create_regions; imports EventNames, AspirationGoal, Sims4Options; replaces TS4-specific set_rules usage.
Region wiring & setup flow
worlds/sims4/__init__.py (create_regions)
Region/menu creation now uses create_location, consults GOAL_TO_EVENT_MAPPING to place event locations and lock corresponding event items, and builds items with explicit DLC unions.
Rules invocation
worlds/sims4/Rules.py, worlds/sims4/__init__.py
set_rules imported from Rules and invoked as set_rules(self.multiworld, self.player, self.options) during setup.
Items typing & skills population
worlds/sims4/Items.py
Adds SkillConfigError (ValueError); expands ItemDict TypedDict with name, tech_type, expansion; types useful_table/junk_table as dict[int, ItemDict]; add_skill validates max_level and stores plain name; skill entries extended.
Locations typing & small fixes
worlds/sims4/Locations.py
Top-level location tables (careers_locations_table, ptj_locations_table, aspiration_locations_table, location_table) annotated as dict[int, Sims4LocationDict]; removed Sims4Location.__init__ event-setting behavior; minor spacing/argument fixes.
Version & metadata
worlds/sims4/Version.py, worlds/sims4/archipelago.json
Bumped VERSION RC suffix to rc3; updated world_version_full to 2.0.0-beta3; does_major_version_mismatch changed from staticmethod to instance method.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Player
    participant Multiworld
    participant Rules
    participant Sims4World
    participant RegionStore

    Player->>Multiworld: start world setup
    Multiworld->>Rules: set_rules(multiworld, player, options)
    Rules->>Sims4World: create_regions()
    Sims4World->>Sims4World: read AspirationGoal option
    alt aspiration mapped via GOAL_TO_EVENT_MAPPING
        Sims4World->>RegionStore: select target region
        Sims4World->>Sims4World: create_event_location(event, region)
        Sims4World->>Sims4World: create_event(event) -> event_item
        Sims4World->>RegionStore: append event location and lock event_item
    else no mapping
        Sims4World->>RegionStore: build regions normally
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through names and tucked a key,
Mapped goals to events for all to see,
Regions stitched and items pinned,
Skills planted wide, each sprout grinned,
A rabbit winks and bounds away.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title "Sims 4: Rules Refactor Part 1" clearly identifies the main change as a refactoring of the rules logic, matching the primary objectives described in the PR.
Description check ✅ Passed The description identifies what is being fixed (rules refactoring), what is done (events for completion), what is deferred (career rules migration), and mentions testing status.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sims4-dev-events

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @worlds/sims4/__init__.py:
- Line 15: The import line imports an unused symbol; remove
set_completion_condition from the import and only import set_rules as
ts4_set_rules (i.e., change "from .Rules import set_completion_condition,
set_rules as ts4_set_rules" to "from .Rules import set_rules as ts4_set_rules"),
ensuring no other references to set_completion_condition exist in this module.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d36885 and cb6c2c0.

📒 Files selected for processing (2)
  • worlds/sims4/Rules.py
  • worlds/sims4/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
worlds/sims4/__init__.py (1)
worlds/sims4/Rules.py (2)
  • set_completion_condition (83-140)
  • set_rules (21-26)
🪛 GitHub Actions: Analyze modified files
worlds/sims4/__init__.py

[error] 11-11: F401 '.Items.skills_table' imported but unused


[error] 13-13: F401 '.Regions.sims4_skill_dependencies' imported but unused


[error] 13-13: F401 '.Regions.sims4_regions' imported but unused


[error] 15-15: F401 '.Rules.set_completion_condition' imported but unused


[error] 22-22: E302 expected 2 blank lines, found 1


[error] 31-31: E302 expected 2 blank lines, found 1


[warning] 66-66: E303 too many blank lines (2)


[error] 77-77: E501 line too long (123 > 120 characters)


[error] 119-119: E501 line too long (123 > 120 characters)


[error] 132-132: E501 line too long (134 > 120 characters)


[warning] 132-132: W505 doc line too long (134 > 120 characters)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.13 macos-latest
🔇 Additional comments (1)
worlds/sims4/__init__.py (1)

128-129: LGTM! Good refactoring to explicit parameters.

The change from passing self to passing explicit parameters (self.multiworld, self.player, self.options) is a solid improvement. This makes the dependencies of ts4_set_rules clearer and improves testability by decoupling from the world instance.

Comment thread worlds/sims4/__init__.py Outdated
@benny-dreamly benny-dreamly changed the title Rules refactor Sims 4: Rules Refactor Jan 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
worlds/sims4/Locations.py (1)

12-12: Add missing type annotation for parent parameter.

The pipeline reports that the parent parameter in the __init__ method is missing a type annotation. Based on the BaseClasses.Location parent class pattern and usage context, this should be typed as Region.

🔧 Proposed fix
-    def __init__(self, player: int, name: str, address: Optional[int], parent):
+    def __init__(self, player: int, name: str, address: Optional[int], parent: Region):

You'll also need to import Region at the top of the file:

-from BaseClasses import Location
+from BaseClasses import Location, Region
worlds/sims4/__init__.py (1)

128-131: Fix variable shadowing in create_region method.

The loop variable location (a string from the locations list) is being reassigned to a Sims4Location object on line 130. This variable shadowing causes the type checker errors reported in the pipeline. Use a different variable name for the Sims4Location instance.

🔧 Proposed fix
         if locations:
             for location in locations:
                 loc_id = self.location_name_to_id.get(location, None)
-                location = Sims4Location(self.player, location, loc_id, ret)
-                ret.locations.append(location)
+                loc = Sims4Location(self.player, location, loc_id, ret)
+                ret.locations.append(loc)
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 534f139 and a423640.

📒 Files selected for processing (2)
  • worlds/sims4/Locations.py
  • worlds/sims4/__init__.py
🧰 Additional context used
🪛 GitHub Actions: Analyze modified files
worlds/sims4/__init__.py

[error] 130-130: mypy: Incompatible types in assignment (expression has type "Sims4Location", variable has type "str").


[error] 131-131: mypy: Argument 1 to "append" of "list" has incompatible type "str"; expected "Location" [arg-type].

worlds/sims4/Locations.py

[error] 12-12: mypy: Function is missing a type annotation for one or more arguments [no-untyped-def].

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: fuzz
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
  • GitHub Check: pyright
  • GitHub Check: tests
  • GitHub Check: mypy
  • GitHub Check: flake8
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
🔇 Additional comments (2)
worlds/sims4/Locations.py (1)

28-28: Excellent type annotation additions!

The explicit type annotations for skill_locations_table, careers_locations_table, ptj_locations_table, aspiration_locations_table, and location_table are exactly what was needed. These resolve the type inference issues mentioned in previous reviews and provide proper type safety throughout the codebase.

Also applies to: 108-108, 573-573, 611-611, 887-887

worlds/sims4/__init__.py (1)

89-100: Well-structured helper methods.

The new create_item, create_event, and create_event_location helper methods are well-typed and logically sound. They properly separate concerns and make the code more maintainable. The create_event_location correctly creates locations without addresses (event locations) and ties them to regions.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @worlds/sims4/__init__.py:
- Around line 60-83: The line for AspirationGoal.option_neighborly_advisor in
GOAL_TO_EVENT_MAPPING is over 120 chars; break the tuple across multiple lines
to satisfy the line-length limit. Locate GOAL_TO_EVENT_MAPPING and replace the
single long entry for AspirationGoal.option_neighborly_advisor with a multi-line
form, e.g. put the key on its own line and split (EventNames.neighborly_advisor,
EventNames.neighborly_advisor_item) across two shorter indented lines so each
line stays under 120 chars while preserving the same mapping.
- Line 2: Update the import so Mapping is taken from collections.abc instead of
typing: replace the use of Mapping from the typing module with Mapping from
collections.abc (keep Any, ClassVar, Optional as needed from typing) to follow
PEP 585 / modern Python 3.9+ conventions; locate the import line that currently
references Mapping and change only that part.
- Around line 99-104: The create_event_location function inconsistently calls
Sims4Location with three args when region is None; update it so both branches
call Sims4Location(self.player, event, None, region) or explicitly pass None as
the fourth argument in the else branch (e.g., Sims4Location(self.player, event,
None, None)) so the parent/region parameter is always supplied; modify the else
branch in create_event_location to pass the missing fourth argument to
Sims4Location.
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a423640 and 1a95683.

📒 Files selected for processing (2)
  • worlds/sims4/Locations.py
  • worlds/sims4/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
worlds/sims4/__init__.py (4)
worlds/sims4/Locations.py (1)
  • Sims4Location (9-10)
worlds/sims4/Items.py (1)
  • Sims4Item (22-23)
worlds/sims4/Options.py (2)
  • AspirationGoal (8-29)
  • Sims4Options (201-209)
worlds/sims4/Rules.py (1)
  • set_rules (21-26)
🪛 GitHub Actions: Analyze modified files
worlds/sims4/__init__.py

[error] 79-79: E501 line too long (121 > 120 characters)


[error] 36-36: E302 expected 2 blank lines, found 1


[error] 2-2: E305 expected 2 blank lines after class or function definition, found 1


[error] 6-6: E501 line too long (160 > 120 characters)


[error] 1-1: E741 ambiguous variable name 'l'

🪛 Ruff (0.14.10)
worlds/sims4/__init__.py

2-2: Import from collections.abc instead: Mapping

Import from collections.abc

(UP035)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
🔇 Additional comments (9)
worlds/sims4/Locations.py (3)

84-84: LGTM: Corrected expansion reference for knitting skill.

The expansion reference is now correctly set to StuffNames.nifty_knitting, aligning with the proper naming convention used throughout the file.


98-99: LGTM: Formatting correction.

The spacing for these skill location entries has been corrected for consistency.


104-104: Excellent: Type annotations added to all location tables.

The explicit type annotations (dict[int, Sims4LocationDict]) on all four location tables provide proper type safety and resolve the type inference issues mentioned in past reviews. This ensures that accessing data["name"] and other dictionary keys will be correctly type-checked throughout the codebase.

Also applies to: 569-569, 607-607, 883-883

worlds/sims4/__init__.py (6)

11-15: LGTM: Import cleanup.

The unused imports (skills_table, sims4_skill_dependencies, sims4_regions) have been removed, and new necessary imports (EventNames, AspirationGoal, Sims4Options) have been added. The set_rules import no longer uses an alias, simplifying the code.


89-97: LGTM: Added return type annotations.

The return type annotations (-> Sims4Item) for create_item and create_event improve type safety without changing functionality.


106-110: LGTM: Multi-line DLC set union.

The DLC set computation has been reformatted across multiple lines for readability and to satisfy line length constraints. The logic remains unchanged.

Also applies to: 154-158


128-128: LGTM: Added type hints to create_region parameters.

The locations and exits parameters now have proper type annotations (list[str] | None = None), improving type safety.


140-171: Excellent refactor: Event creation using GOAL_TO_EVENT_MAPPING.

The refactored create_regions method now uses the GOAL_TO_EVENT_MAPPING dictionary to create event locations, replacing the previous if/elif chain. The logic correctly:

  • Uses goal_value (integer) for dictionary lookup
  • Creates the event location via create_event_location
  • Appends it to the menu region
  • Locks the corresponding item using place_locked_item

This approach is cleaner, more maintainable, and eliminates the type mismatch issues from earlier iterations.

Based on learnings, the PR author has tested this with Archipelago unit tests and fuzzer tools, but comprehensive world logic tests are tracked in issue #15.


175-175: LGTM: Simplified set_rules call.

The call now uses set_rules directly instead of the ts4_set_rules alias, simplifying the code.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @worlds/sims4/__init__.py:
- Line 2: The import line currently pulls Mapping from typing; update it to
import Mapping from collections.abc (per PEP 585) while leaving Any, ClassVar,
and Optional from typing unchanged so references to Mapping in this module
continue to work; replace the `Mapping` import in the top-level import statement
accordingly.
- Around line 99-104: The else branch of create_event_location is missing the
required parent/region argument for Sims4Location; always call Sims4Location
with four args per its __init__ signature (player, event, parent, region) —
e.g., keep the parent argument (None) and explicitly pass region as None when
region is None so both branches call Sims4Location(self.player, event, None,
region_or_None).
- Around line 60-83: One mapping entry in GOAL_TO_EVENT_MAPPING is over the
120-character limit; split the long line for
AspirationGoal.option_neighborly_advisor into multiple lines (e.g., put the
tuple elements on separate lines or wrap after the key) so the line length is
under 120 while preserving the tuple (EventNames.neighborly_advisor,
EventNames.neighborly_advisor_item) and existing indentation.
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a95683 and fabfd74.

📒 Files selected for processing (1)
  • worlds/sims4/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
worlds/sims4/__init__.py (3)
worlds/sims4/Locations.py (1)
  • Sims4Location (9-10)
worlds/sims4/Items.py (1)
  • Sims4Item (22-23)
worlds/sims4/Options.py (2)
  • AspirationGoal (8-29)
  • Sims4Options (201-209)
🪛 Ruff (0.14.10)
worlds/sims4/__init__.py

2-2: Import from collections.abc instead: Mapping

Import from collections.abc

(UP035)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: fuzz
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.13 macos-latest
🔇 Additional comments (5)
worlds/sims4/__init__.py (5)

89-97: LGTM: Clear type annotations added.

The return type annotations for create_item and create_event improve type safety and IDE support. The logic remains correct.


105-126: LGTM: Improved formatting for DLC set creation.

The explicit set union for DLC values is now properly split across multiple lines, improving readability while maintaining the same logic.


128-138: LGTM: Type hints enhance clarity.

The added type annotations for locations, exits, and the return type make the method signature explicit and improve IDE support. The logic is unchanged and correct.


140-172: LGTM: Core refactor successfully implemented.

The refactored create_regions correctly uses the new GOAL_TO_EVENT_MAPPING dictionary lookup. Key improvements:

  • goal_value (integer) is correctly used for the mapping lookup (line 165)
  • aspiration_key (string) is correctly used for aspiration milestones (line 150)
  • Event location creation and item locking logic is clean and maintainable (lines 168-170)
  • DLC filtering is properly formatted (lines 154-158)

This replaces the previous if/elif chain and eliminates the string-vs-integer comparison bug noted in earlier reviews.


174-175: LGTM: Simplified rules invocation.

The direct call to set_rules is cleaner and consistent with the refactored imports.

Comment thread worlds/sims4/__init__.py Outdated
Comment thread worlds/sims4/__init__.py
Comment thread worlds/sims4/__init__.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @worlds/sims4/__init__.py:
- Line 156: The for-loop line "for aspiration in
sims4_aspiration_milestones[aspiration_key]: # (change this later, we'll need it
to do the multi aspiration thing that's in another branch)" violates E261 and
E501; fix by moving the trailing inline comment to its own line above the loop
or shortening it and ensuring there are two spaces before any remaining inline
'#' (e.g., add a standalone comment line like "# TODO: change this later for
multi-aspiration support" above the for loop), which both provides the required
two-space separation and prevents the line from exceeding the max length; update
the line using the symbols sims4_aspiration_milestones, aspiration_key, and
aspiration to locate the code.
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fabfd74 and 9f3f7a5.

📒 Files selected for processing (1)
  • worlds/sims4/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
worlds/sims4/__init__.py (5)
worlds/sims4/Locations.py (1)
  • Sims4Location (9-10)
worlds/sims4/Items.py (1)
  • Sims4Item (22-23)
worlds/sims4/Options.py (2)
  • AspirationGoal (8-29)
  • Sims4Options (201-209)
worlds/sims4/Rules.py (1)
  • set_rules (21-26)
worlds/sims4/UT.py (2)
  • UTMixin (8-30)
  • get_options_from_slot_data (19-30)
🪛 GitHub Actions: Analyze modified files
worlds/sims4/__init__.py

[error] 156-156: flake8: E261 at least two spaces before inline comment; E501 line too long. Also reported line continuation and other style issues in init.py.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.13 ubuntu-latest
  • GitHub Check: Test Python 3.11.2 ubuntu-latest
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.11 windows-latest
  • GitHub Check: Test hosting with 3.13 on ubuntu-latest
🔇 Additional comments (10)
worlds/sims4/__init__.py (10)

2-3: LGTM: Modern import style.

The import of Mapping from collections.abc follows PEP 585 conventions for Python 3.9+.


11-16: LGTM: Clean import consolidation.

Unused imports removed and new dependencies (EventNames, AspirationGoal) properly added to support the GOAL_TO_EVENT_MAPPING refactor.


61-86: LGTM: Comprehensive goal-to-event mapping.

All 18 AspirationGoal options are mapped. The ClassVar annotation ensures the mapping is shared across instances, and long entries are properly wrapped to stay within line limits.


92-97: LGTM: Return type annotation added.

The explicit -> Sims4Item return type improves type safety and IDE support.


104-105: LGTM: Event item factory.

Correctly creates a progression-classified event item with None as the ID.


113-118: LGTM: Clean multiline formatting.

The DLC set union is properly formatted across multiple lines for readability.


136-145: Good refactor to use helper method.

The updated type hints (list[str] | None) and use of self.create_location improve clarity and consistency. Note: this inherits the potential parent argument issue flagged in create_location.


167-172: Good mapping lookup pattern, but calls buggy path.

The dictionary lookup with get() and None check is clean. However, line 170 calls create_event_location(event_name) without passing a region, which triggers the buggy else branch that's missing the parent argument. Once the create_event_location fix is applied, this code will work correctly.


176-177: LGTM: Clean delegation to Rules module.

The method correctly delegates rule-setting to the shared set_rules function.


99-102: The review comment is incorrect. The Location.__init__ signature from BaseClasses.py shows that the parent parameter is optional with a default value of None:

def __init__(self, player: int, name: str = '', address: Optional[int] = None, parent: Optional[Region] = None):

The call Sims4Location(self.player, name, location_id) is valid and will correctly default parent to None. There is no TypeError.

Comment thread worlds/sims4/__init__.py Outdated
@benny-dreamly

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@benny-dreamly

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
worlds/sims4/Version.py (1)

29-29: Break long method signature to satisfy linter.

The method signature exceeds 120 characters. Wrap the parameters across multiple lines.

🔧 Proposed fix
-    def does_major_version_mismatch(client_version: tuple[int, int, int] | tuple[int, int, int, str], server_version: tuple[int, int, int] | tuple[int, int, int, str]) -> bool:
+    def does_major_version_mismatch(
+        client_version: tuple[int, int, int] | tuple[int, int, int, str],
+        server_version: tuple[int, int, int] | tuple[int, int, int, str]
+    ) -> bool:
🤖 Fix all issues with AI agents
In @worlds/sims4/__init__.py:
- Line 2: Remove the unused Optional import from the typing import line; update
the import statement that currently reads "from typing import Any, ClassVar,
Optional" to only include the actually used symbols (e.g., "Any, ClassVar") so
Optional is no longer imported and the linter warning is resolved.
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f3f7a5 and 9668878.

📒 Files selected for processing (3)
  • worlds/sims4/Version.py
  • worlds/sims4/__init__.py
  • worlds/sims4/archipelago.json
🧰 Additional context used
🧬 Code graph analysis (1)
worlds/sims4/__init__.py (5)
worlds/sims4/Locations.py (1)
  • Sims4Location (9-10)
worlds/sims4/Items.py (1)
  • Sims4Item (22-23)
worlds/sims4/Options.py (2)
  • AspirationGoal (8-29)
  • Sims4Options (201-209)
worlds/sims4/Rules.py (1)
  • set_rules (21-26)
worlds/sims4/UT.py (2)
  • UTMixin (8-30)
  • get_options_from_slot_data (19-30)
🪛 GitHub Actions: Analyze modified files
worlds/sims4/__init__.py

[error] 2-2: F401 'typing.Optional' imported but unused

worlds/sims4/Version.py

[error] 29-29: E501 line too long (176 > 120 characters)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Test Python 3.12 ubuntu-latest
  • GitHub Check: Test Python 3.13 windows-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 macos-latest
  • GitHub Check: Test Python 3.13 windows-latest
🔇 Additional comments (7)
worlds/sims4/archipelago.json (1)

4-4: LGTM: Version bump is consistent with the refactor.

The version increment from 2.0.0-beta2 to 2.0.0-beta3 appropriately reflects the rules refactor changes in this PR.

worlds/sims4/Version.py (1)

1-1: LGTM: Version constant updated consistently.

The update from rc2 to rc3 aligns with the 2.0.0-beta3 version in archipelago.json.

worlds/sims4/__init__.py (5)

61-86: Excellent refactor: Dictionary mapping significantly improves maintainability.

The GOAL_TO_EVENT_MAPPING successfully replaces the previous if/elif chain with a clean, declarative mapping. This approach:

  • Eliminates type comparison bugs (string vs. integer)
  • Makes the goal-to-event relationship explicit and easy to verify
  • Reduces code duplication
  • Simplifies future additions

The mapping is comprehensive, correctly typed, and all 17 goal options are properly mapped to their corresponding event and item names.


92-108: LGTM: Helper methods follow clean, consistent patterns.

The new helper methods provide excellent abstractions:

  • create_item: Properly looks up item metadata and classification
  • create_location: Correctly associates location with parent region
  • create_event: Creates progression item with None ID (appropriate for events)
  • create_event_location: Creates event location with None address and correct parent

All methods have clear signatures and handle the Sims4-specific object construction correctly.


110-131: LGTM: Improved readability with multiline DLC union and helper usage.

The refactored create_items method improves readability by:

  • Breaking the DLC union across multiple lines (satisfies E501)
  • Consistently using the create_item helper
  • Maintaining the same logical flow

144-171: Excellent integration of the event mapping refactor.

The refactored create_regions method successfully integrates the GOAL_TO_EVENT_MAPPING:

Key improvements:

  • Lines 164-169: Clean dictionary lookup replaces the error-prone if/elif chain
  • Correctly uses goal_value (integer) for the lookup, avoiding the previous string-vs-integer comparison bug
  • Properly creates the event location and locks the corresponding item
  • Multiline DLC unions improve readability and satisfy linting

Logic flow:

  1. Retrieves the mapping for the selected goal (line 164)
  2. If a mapping exists, unpacks event and item names (line 166)
  3. Creates the event location (line 167)
  4. Locks the progression item to the location (line 169)

This is a significant maintainability improvement. The mapping approach makes the relationship between goals and events explicit and eliminates the previous bugs that were caught in earlier reviews.


173-174: LGTM: Clean delegation to rules module.

The simplified call to set_rules properly delegates to the Rules module with the required parameters.

Acknowledgment of previous review work: The review history shows excellent collaboration between the author and reviewers. All previously identified issues have been addressed:

  • ✅ Critical bugs fixed (wrong event names, type comparison errors, missing arguments)
  • ✅ Code quality improvements (unused imports removed, line lengths fixed, type annotations added)
  • ✅ Refactoring completed successfully (if/elif chain replaced with dictionary mapping)

This PR demonstrates strong attention to detail and responsiveness to feedback.

Comment thread worlds/sims4/__init__.py Outdated
@benny-dreamly

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@benny-dreamly

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread .github/workflows/test.yml Outdated
Co-authored-by: Katelyn Gigante <clockwork.singularity@gmail.com>
@benny-dreamly
benny-dreamly merged commit db9d507 into sims4-dev Jan 8, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants