Skip to content

Add role icon utilities and enhance PlacedUtility class#48

Merged
SunkenInTime merged 3 commits intomainfrom
adding-role-icons-as-draggable
Mar 16, 2026
Merged

Add role icon utilities and enhance PlacedUtility class#48
SunkenInTime merged 3 commits intomainfrom
adding-role-icons-as-draggable

Conversation

@SunkenInTime
Copy link
Owner

  • Introduced new UtilityType values for agent roles: controller, duelist, initiator, and sentinel.
  • Updated PlacedUtility class to include an isAlly property with default value.
  • Enhanced serialization and deserialization for PlacedUtility to handle the new isAlly property.
  • Added RoleIconUtility class for creating role icon widgets.
  • Updated various utility-related classes and methods to support ability size and isAlly parameters.

These changes improve the utility system by allowing for role-specific icons and better handling of ally status in the game mechanics.

- Introduced new UtilityType values for agent roles: controller, duelist, initiator, and sentinel.
- Updated PlacedUtility class to include an isAlly property with default value.
- Enhanced serialization and deserialization for PlacedUtility to handle the new isAlly property.
- Added RoleIconUtility class for creating role icon widgets.
- Updated various utility-related classes and methods to support ability size and isAlly parameters.

These changes improve the utility system by allowing for role-specific icons and better handling of ally status in the game mechanics.
Copilot AI review requested due to automatic review settings March 16, 2026 18:56
@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
icarus Error Error Mar 16, 2026 8:39pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR extends the utility system with four agent role icon types (controller, duelist, initiator, sentinel), adds an isAlly property to PlacedUtility for ally/enemy visual distinction, introduces an AgentRoleIconTools sidebar panel, and extracts a reusable FramedIconShell widget shared between AbilityWidget and the new RoleIconUtilityWidget.

Key changes:

  • New UtilityType enum values and RoleIconUtility/RoleIconToolData classes in utilities.dart cleanly follow the existing Utilities sealed-class contract
  • isAlly is correctly defaulted to true, included in copyWith, and serialized in both JSON (@JsonKey(defaultValue: true)) and Hive (field index 14) — but the source PlacedUtility.isAlly field is missing its @HiveField(14) annotation, meaning a build_runner regeneration would silently drop the field from the Hive adapter
  • FramedIconShell is a clean refactor that eliminates duplicated framing code between abilities and role icons
  • The abilitySize parameter is consistently threaded through getSize, getAnchorPoint, switchSides, and all call sites
  • The "File saved" toast in global_shortcuts.dart fires unconditionally even if the save throws an exception
  • Both .g.dart files (placed_classes.g.dart and hive_adapters.g.dart) are still being edited by hand — the core concern from the previous review thread remains unresolved

Confidence Score: 2/5

  • Not safe to merge — the missing @HiveField(14) annotation means running build_runner (which is required by project policy) would silently drop isAlly from the Hive adapter, and the generated-file editing policy from the previous thread is still unresolved.
  • The new feature logic is sound: the RoleIconUtility class, drag-and-drop placement, FramedIconShell refactor, and isAlly/abilitySize threading are all correct. However, the isAlly Hive persistence is fragile because the source field lacks @HiveField(14), and both .g.dart files were hand-edited again despite the project policy requiring build_runner regeneration. These issues mean any future build_runner run will silently regress the isAlly Hive serialization.
  • lib/const/placed_classes.dart (missing @HiveField(14) on isAlly), lib/const/placed_classes.g.dart, and lib/hive/hive_adapters.g.dart (both still manually edited).

Important Files Changed

Filename Overview
lib/const/placed_classes.dart Adds isAlly field to PlacedUtility (with @JsonKey(defaultValue: true) and default value in constructor), adds abilitySize to switchSides and _getEffectiveUtilitySize, and applies @UtilityTypeCompatConverter() to the type field. The copyWith method is correctly updated. Missing @HiveField(14) annotation on isAlly means Hive regeneration via build_runner would drop this field.
lib/const/placed_classes.g.dart Manually edited generated file: replaces _$UtilityTypeEnumMap/$enumDecode with UtilityTypeCompatConverter, and adds isAlly serialization. Logic is correct but this file must not be hand-edited — already flagged in a previous review thread.
lib/const/utilities.dart Adds four new UtilityType values (controller, duelist, initiator, sentinel), RoleIconUtility class, RoleIconToolData data class, UtilityData.isRoleIcon() helper, and threads abilitySize/isAlly parameters through the Utilities interface and all subclasses.
lib/hive/hive_adapters.g.dart Manually edited generated file: adds isAlly at Hive field index 14 (with null-safe default), extends UtilityTypeAdapter to handle new role-icon enum cases 6–9. Field count correctly updated from 12→13. Must not be hand-edited.
lib/hive/hive_adapters.g.yaml Spec file updated correctly: isAlly added at index 14 (skipping reserved index 13), nextIndex bumped to 15; UtilityType extended with four new values at indices 6–9, nextIndex bumped to 10.
lib/widgets/draggable_widgets/shared/framed_icon_shell.dart New reusable ConsumerWidget that extracts the framed icon container (background, border, ally/enemy color, hover highlight) from AbilityWidget and reuses it in RoleIconUtilityWidget. Clean and correct refactor.
lib/widgets/sidebar_widgets/agent_role_icon_tools.dart New sidebar panel exposing the four role-icon tiles with drag-and-drop and tap-to-center placement. Correctly reads teamProvider for isAlly at placement time and switches interaction state on drag start.

Sequence Diagram

sequenceDiagram
    participant User
    participant AgentRoleIconTools
    participant Draggable
    participant PlacedWidgetBuilder
    participant UtilityProvider
    participant UtilityData

    User->>AgentRoleIconTools: Drag _RoleIconTile
    AgentRoleIconTools->>Draggable: data = RoleIconToolData(type, centerPoint)
    Note over AgentRoleIconTools: dragAnchorStrategy scales centerPoint<br/>feedback renders RoleIconUtilityWidget

    User->>PlacedWidgetBuilder: Drop on map
    PlacedWidgetBuilder->>PlacedWidgetBuilder: details.data is RoleIconToolData
    PlacedWidgetBuilder->>UtilityProvider: addUtility(PlacedUtility(type, position, isAlly: teamProvider))

    alt Tap to place
        User->>AgentRoleIconTools: Tap _RoleIconTile
        AgentRoleIconTools->>AgentRoleIconTools: _placeAtCenter(ref, toolData)
        AgentRoleIconTools->>UtilityProvider: addUtility(PlacedUtility(type, centeredTopLeft, isAlly: teamProvider))
    end

    UtilityProvider->>UtilityData: utilityWidgets[type].createWidget(isAlly, abilitySize)
    UtilityData->>RoleIconUtilityWidget: build with FramedIconShell
    RoleIconUtilityWidget-->>User: renders ally/enemy colored icon on map
Loading

Last reviewed commit: c5acb98

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds role-based utility icons and threads ally/enemy state + ability sizing through the utility rendering/serialization pipeline, enabling “agent role” widgets to be placed like other utilities.

Changes:

  • Added new UtilityType values (controller/duelist/initiator/sentinel) and a RoleIconUtility + widgets/tools to place them.
  • Extended PlacedUtility with isAlly (defaulting to true) and updated Hive + JSON serialization/deserialization.
  • Updated various utility builders/previews to pass isAlly and abilitySize, and added a new sidebar tool mode/button for role icons.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/widgets/sidebar_widgets/tool_grid.dart Adds a new “Agent Roles” tool button and context bar mode for role icon tools.
lib/widgets/sidebar_widgets/agent_role_icon_tools.dart New sidebar tool UI for dragging/clicking role icons onto the canvas.
lib/widgets/page_transition_overlay.dart Passes isAlly and abilitySize into utility preview rendering.
lib/widgets/draggable_widgets/utilities/utility_widget_builder.dart Threads abilitySize and isAlly into utility widget construction.
lib/widgets/draggable_widgets/utilities/role_icon_utility_widget.dart New rendered widget for role icons, using a framed shell and delete-target wiring.
lib/widgets/draggable_widgets/shared/framed_icon_shell.dart New shared framed container used for abilities/role icons to unify styling/hover behavior.
lib/widgets/draggable_widgets/placed_widget_builder.dart Accepts dropped RoleIconToolData and passes abilitySize into utility bounds logic.
lib/widgets/draggable_widgets/ability/ability_widget.dart Refactors ability rendering to use FramedIconShell.
lib/providers/interaction_state_provider.dart Adds InteractionState.roleIcons.
lib/hive/hive_adapters.g.yaml Updates Hive schema indices for PlacedUtility.isAlly and new UtilityType values.
lib/hive/hive_adapters.g.dart Implements Hive read/write for isAlly and new UtilityType enum cases.
lib/const/utilities.dart Adds role icon utilities/tool data and expands utility APIs to accept isAlly/abilitySize.
lib/const/placed_classes.g.dart Updates JSON (de)serialization for PlacedUtility (isAlly, compat converter).
lib/const/placed_classes.dart Adds PlacedUtility.isAlly field and updates copy/constructor + compat converter annotation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

- Updated the PlacedUtility class to include an abilitySize parameter in the _getEffectiveUtilitySize method.
- Modified the switchSides method to accept the new abilitySize parameter.
- Adjusted the UtilityProvider to read abilitySize from the strategySettingsProvider and pass it to the switchSides method.

These changes improve the utility system by allowing for more precise handling of ability sizes in the game mechanics.
@SunkenInTime
Copy link
Owner Author

@greptile how does it look now

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@SunkenInTime SunkenInTime merged commit ffda748 into main Mar 16, 2026
1 of 3 checks passed
@SunkenInTime SunkenInTime deleted the adding-role-icons-as-draggable branch March 16, 2026 20:35
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