refactor(engine): move casting_costs/casting_targets into casting/ submodule - #2815
refactor(engine): move casting_costs/casting_targets into casting/ submodule#2815dale053 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request reorganizes the casting module structure by moving casting_costs and casting_targets into casting::costs and casting::targets respectively, updating module paths, imports, and visibility modifiers across the engine. The review feedback highlights opportunities to improve code robustness and refactoring safety by replacing fragile, deeply nested relative imports (e.g., super::super::) with absolute paths starting with crate::game::, in accordance with the idiomatic Rust style guide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| use super::super::effects::counters::add_counter_with_replacement; | ||
| use super::super::engine::EngineError; | ||
| use super::super::mana_abilities; | ||
| use super::super::mana_payment; | ||
| use super::super::mana_sources::{self, ManaSourceOption}; | ||
| use super::super::restrictions; | ||
| use super::super::stack; | ||
| use super::emit_targeting_events; | ||
|
|
||
| use super::super::ability_utils::{ | ||
| assign_targets_in_chain, auto_select_targets_for_ability, begin_target_selection_for_ability, | ||
| build_target_slots, build_target_slots_labelled, flatten_targets_in_chain, | ||
| modal_choice_for_player, random_select_targets_for_ability, target_constraints_from_modal, | ||
| }; | ||
| use super::life_costs::PayLifeCostResult; | ||
| use super::super::life_costs::PayLifeCostResult; |
There was a problem hiding this comment.
[MEDIUM] Fragile relative imports. Evidence: crates/engine/src/game/casting/costs.rs:22-36. Why it matters: Using deeply nested relative paths like super::super:: makes the codebase fragile to refactoring and leads to significant code churn when files are moved. Using absolute paths starting with crate::game:: is more idiomatic and robust. Additionally, importing other modules (like quantity, filter, zones, etc.) at the top of the file using crate::game:: absolute paths would allow you to remove the verbose inline super::super:: prefixes throughout the file, preventing future refactoring pain.
| use super::super::effects::counters::add_counter_with_replacement; | |
| use super::super::engine::EngineError; | |
| use super::super::mana_abilities; | |
| use super::super::mana_payment; | |
| use super::super::mana_sources::{self, ManaSourceOption}; | |
| use super::super::restrictions; | |
| use super::super::stack; | |
| use super::emit_targeting_events; | |
| use super::super::ability_utils::{ | |
| assign_targets_in_chain, auto_select_targets_for_ability, begin_target_selection_for_ability, | |
| build_target_slots, build_target_slots_labelled, flatten_targets_in_chain, | |
| modal_choice_for_player, random_select_targets_for_ability, target_constraints_from_modal, | |
| }; | |
| use super::life_costs::PayLifeCostResult; | |
| use super::super::life_costs::PayLifeCostResult; | |
| use crate::game::effects::counters::add_counter_with_replacement; | |
| use crate::game::engine::EngineError; | |
| use crate::game::mana_abilities; | |
| use crate::game::mana_payment; | |
| use crate::game::mana_sources::{self, ManaSourceOption}; | |
| use crate::game::restrictions; | |
| use crate::game::stack; | |
| use super::emit_targeting_events; | |
| use crate::game::ability_utils::{ | |
| assign_targets_in_chain, auto_select_targets_for_ability, begin_target_selection_for_ability, | |
| build_target_slots, build_target_slots_labelled, flatten_targets_in_chain, | |
| modal_choice_for_player, random_select_targets_for_ability, target_constraints_from_modal, | |
| }; | |
| use crate::game::life_costs::PayLifeCostResult; |
References
- Idiomatic Rust — uses the type system, ownership model, and standard library idioms to their fullest. Enums over stringly-typed data. Absolute imports are preferred over fragile relative paths. (link)
| use super::super::ability_utils::{ | ||
| ability_target_legality_needs_chosen_x, assign_selected_slots_in_chain, | ||
| assign_targets_in_chain, auto_select_targets_for_ability, begin_target_selection_for_ability, | ||
| build_chained_resolved, build_target_slots_labelled, choose_target_for_ability, | ||
| flatten_targets_in_chain, random_select_targets_for_ability, validate_modal_indices, | ||
| validate_selected_targets_for_ability, TargetSelectionAdvance, | ||
| }; | ||
| use super::casting::{emit_targeting_events, pay_ability_cost_for_activation}; | ||
| use super::casting_costs::{ | ||
| use super::super::engine::EngineError; | ||
| use super::super::restrictions; | ||
| use super::super::stack; |
There was a problem hiding this comment.
[MEDIUM] Fragile relative imports. Evidence: crates/engine/src/game/casting/targets.rs:12-21. Why it matters: Using deeply nested relative paths like super::super:: makes the codebase fragile to refactoring. Using absolute paths starting with crate::game:: is more idiomatic and robust.
| use super::super::ability_utils::{ | |
| ability_target_legality_needs_chosen_x, assign_selected_slots_in_chain, | |
| assign_targets_in_chain, auto_select_targets_for_ability, begin_target_selection_for_ability, | |
| build_chained_resolved, build_target_slots_labelled, choose_target_for_ability, | |
| flatten_targets_in_chain, random_select_targets_for_ability, validate_modal_indices, | |
| validate_selected_targets_for_ability, TargetSelectionAdvance, | |
| }; | |
| use super::casting::{emit_targeting_events, pay_ability_cost_for_activation}; | |
| use super::casting_costs::{ | |
| use super::super::engine::EngineError; | |
| use super::super::restrictions; | |
| use super::super::stack; | |
| use crate::game::ability_utils::{ | |
| ability_target_legality_needs_chosen_x, assign_selected_slots_in_chain, | |
| assign_targets_in_chain, auto_select_targets_for_ability, begin_target_selection_for_ability, | |
| build_chained_resolved, build_target_slots_labelled, choose_target_for_ability, | |
| flatten_targets_in_chain, random_select_targets_for_ability, validate_modal_indices, | |
| validate_selected_targets_for_ability, TargetSelectionAdvance, | |
| }; | |
| use crate::game::engine::EngineError; | |
| use crate::game::restrictions; | |
| use crate::game::stack; |
References
- Idiomatic Rust — uses the type system, ownership model, and standard library idioms to their fullest. Enums over stringly-typed data. Absolute imports are preferred over fragile relative paths. (link)
| pending.ability.context.additional_cost_paid = true; | ||
| let base_cost = pending.base_cost.clone(); | ||
| super::super::casting_costs::pay_and_push( | ||
| super::super::casting::costs::pay_and_push( |
There was a problem hiding this comment.
[MEDIUM] Fragile relative path. Evidence: crates/engine/src/game/effects/collect_evidence.rs:178. Why it matters: Using deeply nested relative paths like super::super:: is fragile and breaks easily when files are moved. Using absolute paths starting with crate::game:: is more robust.
| super::super::casting::costs::pay_and_push( | |
| crate::game::casting::costs::pay_and_push( |
/review-impl — PR #2815Verdict: REQUEST CHANGES — one hard blocker ( BLOCKER 1 — accidental
|
/review-impl — PR #2815VERDICT: request-changes The actual change — relocating HIGH — Stray
|
8efe697 to
444fd58
Compare
444fd58 to
5b09d65
Compare
/review-impl — PR #2815 (re-review of
|
# Conflicts: # crates/engine/src/game/casting/mod.rs
|
Maintainer note: merged current |
matthewevans
left a comment
There was a problem hiding this comment.
Maintainer sign-off: mechanical casting/ submodule reorg at the right boundary (mod.rs/costs.rs/targets.rs), gitlink blocker removed (natefinch re-review approve at this head); brought current with main, conflicts resolved in favor of the effective_spell_keywords authority. Behavior-preserving by construction; conflict-area suites green.
|
Thanks for taking a swing at the casting module's organization — the mechanical execution is clean (imports updated throughout, compiles, casting tests pass). Closing this one, though, because as it stands it's a directory rename rather than the decomposition the branch name promises. It moves The cost side is real too: If you'd like to pursue this, a decomposition that actually splits |
Summary
Closes #2814
Reorganizes the casting module from flat files into a
casting/submodule, movingcasting.rs→casting/mod.rs,casting_costs.rs→casting/costs.rs, andcasting_targets.rs→casting/targets.rs. Updates all import paths across the engine crate. No logic changes.Files changed
crates/engine/src/game/casting/mod.rs(renamed fromcasting.rs)crates/engine/src/game/casting/costs.rs(renamed fromcasting_costs.rs)crates/engine/src/game/casting/targets.rs(renamed fromcasting_targets.rs)crates/engine/src/game/mod.rs— removed flat declarations, addedpub mod castingcrates/engine/src/game/cost_payability.rs— import path updatecrates/engine/src/game/effects/collect_evidence.rs— import path updatecrates/engine/src/game/effects/pay.rs— import path updatecrates/engine/src/game/engine.rs— import path updatecrates/engine/src/game/engine_casting.rs— import path updatecrates/engine/src/game/engine_modes.rs— import path updatecrates/engine/src/game/engine_replacement.rs— import path updatecrates/engine/src/game/engine_resolution_choices.rs— import path updatecrates/engine/src/game/engine_stack.rs— import path updatecrates/engine/src/game/filter.rs— import path updatecrates/engine/src/game/mana_abilities.rs— import path updatecrates/engine/src/game/restrictions.rs— import path updatecrates/engine/src/game/splice.rs— import path updatecrates/engine/src/game/triggers.rs— import path updateCR references
No new CR annotations — structural reorganization only, no logic changes.
Track
Developer
LLM
Model: claude-sonnet-4-6
Thinking: medium
Tier: Standard
Verification
cargo fmt --all— clean./scripts/check-parser-combinators.sh— clean (no parser logic touched)./scripts/tilt-wait.sh clippy test-engine— pending CIAnchored on
crates/engine/src/game/effects/mod.rs— existing submodule pattern:effects/directory withmod.rsre-exporting sibling files, consumed viause crate::game::effects::*crates/engine/src/game/mod.rs:12— existingpub mod castingdeclaration used as the template for the new submodule entry pointScope Expansion
None.
Validation Failures
None.
CI Failures
None.