Skip to content

Feature/shape terrain - #65

Merged
Sofistico merged 14 commits into
masterfrom
feature/shape-terrain
Jul 12, 2025
Merged

Feature/shape terrain#65
Sofistico merged 14 commits into
masterfrom
feature/shape-terrain

Conversation

@Sofistico

@Sofistico Sofistico commented Jun 23, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Introduced two new alteration spells: "Raise Wall" (creates a wall at a target location) and "Dig" (transmutes a wall into rubble).
    • Added new spell effects and in-game actions for raising walls and digging.
  • Improvements
    • Enhanced tile and terrain manipulation via new helper methods and dynamic tile type changes.
    • Expanded tile and entity inspection with detailed descriptions and debug information.
    • Updated spell effect handling to use string identifiers for greater flexibility.
    • Added new debug key actions for field of view recalculation and tile transparency toggling.
    • Refined spell targeting and casting logic for clearer control flow and state management.
  • Bug Fixes
    • Improved handling of empty collections in entity vision and anatomy checks to prevent errors.
  • Chores
    • Upgraded GoRogue library dependency to a newer version.
    • Cleaned up unused code, reorganized imports, and improved code clarity and maintainability.
    • Added build and run command scripts for streamlined project execution.

@Sofistico Sofistico added the ai Automatic AI Review label Jun 23, 2025
@coderabbitai

coderabbitai Bot commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Two new alteration spells, "Raise Wall" and "Dig," are introduced with their spell effects and JSON definitions. The spell system now uses string-based effect types instead of enums. New enum members for spell contexts and effects are added. Helpers for tile transformation and mining difficulty are created. Various nullability and code clarity improvements are applied across the codebase.

Changes

Files/Group Change Summary
src/Arquimedes/Data/Spells/spells_alteration.json Added new JSON file defining "Raise Wall" and "Dig" alteration spells.
src/Arquimedes/Enumerators/SpellContext.cs, SpellEffectType.cs, TargetState.cs Added new enum members for spell contexts and effect types; renamed EffectType to SpellEffectType.
src/Arquimedes/Utils/FileUtils.cs Restricted file search to top directory; reformatted parallel file processing lambda.
src/Diviner/KeyboardHandle.cs Reorganized usings; added debug keys for F2 (FOV recalculation) and K (tile transparency toggle); removed map/game save keys.
src/Diviner/Windows/LookWindow.cs Unified console creation; enhanced tile description with material, traits, vegetation, water, debug info.
src/MagusEngine/Bus/MapBus/ChangeControlledEntitiy.cs Removed unused using directives.
src/MagusEngine/Core/Entities/Base/Anatomy.cs Added early returns for empty collections in CanSee and HasATorso properties.
src/MagusEngine/Core/Entities/Player.cs Increased magic shaping ability score; added "dig" and "raise_wall" spells to player's known spells.
src/MagusEngine/Core/Entities/Target.cs Improved nullability handling; updated layer mask; refined spell casting control flow; changed state transitions; removed obsolete commented code.
src/MagusEngine/Core/Magic/Effects/*Effect.cs Changed EffectType assignments from enum to string via .ToString(); removed unused usings; no logic changes.
src/MagusEngine/Core/Magic/Effects/DigEffect.cs, RaiseWallEffect.cs Added new spell effect classes implementing terrain modification logic for Dig and Raise Wall spells.
src/MagusEngine/Core/Magic/Interfaces/ISpellEffect.cs Changed EffectType property type from enum to string, removing JSON enum converter.
src/MagusEngine/Core/Magic/Magic.cs Changed KnowEffects property type from list of enums to list of strings.
src/MagusEngine/Core/Magic/SpellEffectBase.cs Changed EffectType property type from enum to non-nullable string with default null-forgiving initializer.
src/MagusEngine/Core/MapStuff/MagiMap.cs Changed base class to Map; applied null-forgiving operators; used modern C# collection patterns; cleaned commented code.
src/MagusEngine/Core/MapStuff/Tile.cs Made LastSeenAppereance setter private; added UpdateLastSeenAppearence() method to encapsulate cloning logic.
src/MagusEngine/Core/MapStuff/TileHelpers.cs Added static helper class with method to change tile type considering mining difficulty and chance.
src/MagusEngine/MagusEngine.csproj Updated GoRogue package dependency from beta09 to beta10.
src/MagusEngine/Serialization/EntitySerialization/SpellTemplate.cs Updated spell effect type parsing to use SpellEffectType enum.
src/MagusEngine/Services/Factory/SpellEffectFactory.cs Registered new spell effects "RAISEWALL" and "DIG"; updated method signatures to use SpellEffectType.
src/MagusEngine/Services/Factory/TileFactory.cs Added extension method to change tile type and update appearance accordingly.
src/MagusEngine/Systems/Physics/PhysicsSystem.cs Added method to calculate mining difficulty based on material properties.
build.cmd, run.cmd Added new build and run command scripts for the project.
src/MagusEngine/Bus/UiBus/AddMessageLog.cs Added constructor overload to create message logs based on entity visibility.
Various files Minor refactorings: nullability improvements, removal of unused usings, code clarity enhancements.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant SpellSystem
    participant TileHelpers
    participant TileFactory
    participant Map

    Player->>SpellSystem: Cast "Raise Wall" or "Dig" spell
    SpellSystem->>TileHelpers: ChangeTileEffect(target, caster, modifier, newType)
    TileHelpers->>Map: Get tile at target location
    TileHelpers->>PhysicsSystem: GetMiningDificulty(material)
    alt Tile change successful
        TileHelpers->>TileFactory: ChangeTileType(tile, newType)
        TileFactory->>tile: Update appearance and properties
    else Tile change failed
        TileHelpers->>SpellSystem: Log error message
    end
Loading

Poem

🧙‍♂️

Two spells now join the wizard's tome,
To raise a wall or dig through stone.
With string-bound types and mining lore,
The code is clearer than before.
Tiles shift and magic swirls anew—
The world bends to the mage's view!

✨🪄🧱


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1c818f and 2ed822a.

📒 Files selected for processing (6)
  • src/Arquimedes/Data/Spells/spells_dimensionalism.json (1 hunks)
  • src/Arquimedes/Enumerators/SpellAreaEffect.cs (1 hunks)
  • src/Diviner/KeyboardHandle.cs (4 hunks)
  • src/MagusEngine/Core/Entities/Target.cs (12 hunks)
  • src/MagusEngine/Core/Magic/Effects/TeleportEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Spell.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/MagusEngine/Core/Magic/Effects/TeleportEffect.cs
  • src/Diviner/KeyboardHandle.cs
  • src/MagusEngine/Core/Entities/Target.cs
⏰ 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). (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: SonarScan
🔇 Additional comments (3)
src/MagusEngine/Core/Magic/Spell.cs (1)

272-274: Magnificent arcane enhancement! The TargetSelf case weaves magic perfectly.

This implementation correctly channels the spell effect to the target location while keeping the caster as the source - precisely what's needed for teleportation and similar self-affecting spells that target distant locations. The spell logic flows as smoothly as a well-practiced incantation.

src/Arquimedes/Data/Spells/spells_dimensionalism.json (1)

7-7: Splendid transmutation of the Blink spell's targeting essence!

Changing the teleportation effect from "Target" to "TargetSelf" is precisely the mystical adjustment needed - now the spell properly whisks the caster to the target location rather than affecting whatever unfortunate soul might be standing there. A most logical enchantment indeed!

src/Arquimedes/Enumerators/SpellAreaEffect.cs (1)

25-27: A most scholarly addition to the tome of magical area effects!

The new TargetSelf enum member is perfectly documented with crystal-clear intent - "applies the effect to the caster at the specified target location" leaves no room for mystical confusion. Positioned wisely between Target and Ball, this enchantment shall serve teleportation magic and similar spells most admirably.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 16

🔭 Outside diff range comments (1)
src/Diviner/Windows/LookWindow.cs (1)

19-31: Inconsistent printing behavior detected in the entity constructor!

The entity constructor builds a detailed description in desc but only prints entity.Description to the console, ignoring all the additional information gathered (descriptor, status, ID, position). This seems like unfinished enchantment work.

Complete the spell by printing the full description:

-                lookConsole.Cursor.Print(entity.Description);
+                lookConsole.Cursor.Print(desc.ToString());

Or if you prefer to keep the original behavior, remove the unused desc building.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3db262 and ab56032.

📒 Files selected for processing (33)
  • src/Arquimedes/Data/Spells/spells_alteration.json (1 hunks)
  • src/Arquimedes/Enumerators/SpellContext.cs (1 hunks)
  • src/Arquimedes/Enumerators/SpellEffectType.cs (2 hunks)
  • src/Arquimedes/Enumerators/TargetState.cs (1 hunks)
  • src/Arquimedes/Utils/FileUtils.cs (2 hunks)
  • src/Diviner/KeyboardHandle.cs (3 hunks)
  • src/Diviner/Windows/LookWindow.cs (3 hunks)
  • src/MagusEngine/Bus/MapBus/ChangeControlledEntitiy.cs (0 hunks)
  • src/MagusEngine/Core/Entities/Base/Anatomy.cs (2 hunks)
  • src/MagusEngine/Core/Entities/Player.cs (3 hunks)
  • src/MagusEngine/Core/Entities/Target.cs (13 hunks)
  • src/MagusEngine/Core/Magic/Effects/DamageEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/DigEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/HasteEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/KnockbackEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/LightEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/MEssionEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/MageSightEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/PermEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/RaiseWallEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/SeverEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Effects/TeleportEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Interfaces/ISpellEffect.cs (1 hunks)
  • src/MagusEngine/Core/Magic/Magic.cs (1 hunks)
  • src/MagusEngine/Core/Magic/SpellEffectBase.cs (1 hunks)
  • src/MagusEngine/Core/MapStuff/MagiMap.cs (17 hunks)
  • src/MagusEngine/Core/MapStuff/Tile.cs (5 hunks)
  • src/MagusEngine/Core/MapStuff/TileHelpers.cs (1 hunks)
  • src/MagusEngine/MagusEngine.csproj (1 hunks)
  • src/MagusEngine/Serialization/EntitySerialization/SpellTemplate.cs (1 hunks)
  • src/MagusEngine/Services/Factory/SpellEffectFactory.cs (1 hunks)
  • src/MagusEngine/Services/Factory/TileFactory.cs (1 hunks)
  • src/MagusEngine/Systems/Physics/PhysicsSystem.cs (2 hunks)
💤 Files with no reviewable changes (1)
  • src/MagusEngine/Bus/MapBus/ChangeControlledEntitiy.cs
🧰 Additional context used
🪛 GitHub Actions: Build and Test
src/MagusEngine/MagusEngine.csproj

[warning] 1-1: Numerous CS8600, CS8602, CS8604, CS8618, CS8625, CS8629, CS8765, CS8777, CS0169, and SYSLIB0051 warnings related to nullability, unused fields, and obsolete API usage.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: SonarScan
🔇 Additional comments (47)
src/Arquimedes/Enumerators/TargetState.cs (1)

5-5: By the ancient scrolls, a new targeting state emerges!

The addition of IdleMode to the targeting incantations appears most wise, dear mage! This new state shall provide clarity when our mystical targeting systems return to their restful state.

However, placing this new enchantment as the first member of the enum may affect any arcane calculations that rely upon the numeric values of these states. Ensure thy spellwork elsewhere accounts for this reordering of the mystical constants!

Let me divine whether this enum ordering change affects other parts of the magical realm:

#!/bin/bash
# Description: Search for potential integer usage of TargetState enum values
# Expected: Find any code that might be affected by the enum reordering

echo "=== Searching for TargetState integer conversions ==="
rg -A 3 -B 3 "TargetState.*int|int.*TargetState|\(int\).*TargetState|TargetState.*\(int\)"

echo "=== Searching for switch statements on TargetState ==="
rg -A 10 "switch.*TargetState|switch.*targetState"

echo "=== Searching for TargetState array indexing ==="
rg -A 3 -B 3 "\[.*TargetState|\[.*targetState"
src/MagusEngine/MagusEngine.csproj (1)

10-10: The mystical tomes of GoRogue have been updated, but dark omens appear!

The upgrade from beta09 to beta10 of the GoRogue grimoire brings new powers, yet the crystal ball reveals troubling warnings in the build incantations! The pipeline speaks of numerous nullability curses (CS8600, CS8602, CS8604, CS8618, CS8625, CS8629, CS8765, CS8777) that may have awakened with this update.

Verily, ensure this version update aligns with the changes to MagiMap's inheritance mentioned in the ancient scrolls (the summary).

Allow me to consult the ethereal archives to verify this update brings no ill fortune:

What are the breaking changes and new features in GoRogue 3.0.0-beta10 compared to 3.0.0-beta09?
src/MagusEngine/Core/Magic/Effects/KnockbackEffect.cs (1)

18-18: The mystical force of knockback transforms its essence from rigid enum to flowing string!

This transmutation from the solid form of EffectType.KNOCKBACK to the more ethereal SpellEffectType.KNOCKBACK.ToString() aligns perfectly with the grand refactoring ritual described in the ancient texts! The spell effect now speaks in the common tongue of strings, allowing for easier divination through serialization and more flexible enchantment extensions.

The invocation appears correctly wrought, maintaining the same magical essence while adopting the new paradigm.

src/MagusEngine/Core/Magic/Effects/HasteEffect.cs (1)

25-25: The winds of haste now speak in the universal tongue of strings!

Behold! Another successful transmutation in our grand magical refactoring ritual! The HasteEffect now properly converts its mystical essence from the rigid EffectType.HASTE to the more flexible SpellEffectType.HASTE.ToString(), following the same arcane pattern as its sibling effects.

This change maintains perfect harmony with the system-wide transformation from strongly-typed enum mysticism to string-based enchantment identification. The spell of swiftness shall now flow more easily through serialization portals and extensibility gateways!

src/MagusEngine/Core/Magic/Effects/MageSightEffect.cs (1)

23-23: The Sight beyond sight is granted with proper form!

This enchantment follows the same mystical pattern as the other spell effects in this grand transformation. The string-based effect typing shall serve the realm well.

src/Arquimedes/Enumerators/SpellEffectType.cs (2)

3-3: A most wise renaming of the mystical enumerations!

Changing from EffectType to SpellEffectType brings clarity to the arcane arts, making it crystal clear these enumerated powers belong to the realm of spell casting.


16-17: Behold! New powers of terrain manipulation are inscribed in the tome!

The addition of RAISEWALL and DIG spell effects opens new chapters in the art of shaping the very earth itself. These mystical forces shall grant wizards dominion over stone and soil!

src/MagusEngine/Core/Entities/Player.cs (3)

25-25: The apprentice grows in power most magnificently!

Raising the magic shaping ability to 65 grants the test wizard greater mastery over the mystical arts, necessary for wielding the new terrain-altering enchantments.


51-52: New spells of earth and stone are granted to the worthy!

The addition of "dig" and "raise_wall" spells at level 2 brings forth the power to reshape the very foundations of the world. These incantations shall serve the test wizard well in mastering the terrain.


64-66: The grimoire expands with earthen magics!

Adding the new terrain spells to the known spell list ensures our test wizard can practice the ancient arts of stone shaping and earth moving.

src/MagusEngine/Core/Magic/Effects/DamageEffect.cs (1)

23-23: The forces of destruction follow the new mystical pattern!

The damage effect correctly adopts the string-based effect type system. However, I sense a potential disturbance in the magical flow - the JsonConstructor (lines 27-43) doesn't set the EffectType property while the parameterless constructor does.

Pray tell, is this intentional? Ensure that spell effects deserialized from JSON maintain their proper magical signatures.

#!/bin/bash
# Description: Search for other JsonConstructor patterns in spell effects to verify consistency
# Expected: Find if other spell effects set EffectType in JsonConstructor or rely on parameterless constructor

echo "Searching for JsonConstructor patterns in spell effects..."
rg -A 10 -B 2 "JsonConstructor" --type cs src/MagusEngine/Core/Magic/Effects/

echo -e "\nSearching for EffectType assignments in constructors..."
rg -A 3 -B 3 "EffectType.*=" --type cs src/MagusEngine/Core/Magic/Effects/
src/MagusEngine/Serialization/EntitySerialization/SpellTemplate.cs (1)

23-23: By the ancient tomes, this spell parsing enchantment looks most excellent!

The transformation from the old EffectType to SpellEffectType enum is woven correctly into the deserialization ritual. The spell effects shall be properly conjured from their JSON grimoire form.

src/MagusEngine/Core/Magic/SpellEffectBase.cs (1)

16-16: ```shell
#!/bin/bash
set -e

Locate SpellEffectBase.cs and display its contents for context

FILE=$(fd SpellEffectBase.cs | head -n1)
echo "File: $FILE"
sed -n '1,200p' "$FILE"


</details>
<details>
<summary>src/Arquimedes/Enumerators/SpellContext.cs (1)</summary>

`18-20`: **Magnificent additions to our arcane lexicon!**

These new spell contexts - `Terraforming`, `Dig`, and `BlocksSight` - shall serve well for the earth-shaping magics being woven into our realm. The naming is clear and follows the established mystical conventions.

</details>
<details>
<summary>src/MagusEngine/Core/Magic/Magic.cs (1)</summary>

`24-24`: By the flicker of enchanted quills, let us summon deeper insight into the AddToSpellList incantation:


```shell
#!/bin/bash
rg -n "AddToSpellList" -C3 src/MagusEngine/Core/Magic/Magic.cs
rg -n "KnowEffects\\.Contains" -C3 src/MagusEngine/Core/Magic/Magic.cs
src/MagusEngine/Core/Magic/Interfaces/ISpellEffect.cs (1)

20-20: By my beard and staff! This mystical transformation weakens our spell-binding magic!

Changing from the strongly-typed EffectType enum to a mere string removes the arcane protections of compile-time type checking. While I sense this is part of a grand transmutation across the realm, we must ensure our spell effects remain consistent and true!

Let me divine the impact of this change across our magical domains:

#!/bin/bash
# Description: Verify all spell effects use consistent string values
# Expected: All effect types should use .ToString() pattern from SpellEffectType enum

echo "=== Searching for EffectType assignments in spell effects ==="
rg -A 2 -B 2 "EffectType\s*=" --type cs

echo "=== Checking for SpellEffectType enum usage ==="
rg "SpellEffectType\." --type cs

echo "=== Looking for potential inconsistencies ==="
rg -i "effecttype.*=" --type cs | grep -v "ToString()"
src/MagusEngine/Core/Magic/Effects/SeverEffect.cs (1)

22-22: Excellent transmutation, young sorcerer!

Your spell effect correctly follows the new incantation pattern, converting the mystical SpellEffectType.SEVER to its string essence. The blade magic shall continue to serve us well in this new form!

src/MagusEngine/Core/Entities/Base/Anatomy.cs (2)

99-101: Wisely woven protection spells for our anatomical divinations!

These early return enchantments prevent us from casting Exists upon empty collections - a most prudent ward against potential mystical mishaps! The logic remains sound: no organs means no sight, as clear as crystal.


110-112: Another excellent ward against the void!

Your protective incantation ensures we don't seek a torso where no limbs exist. Most logical indeed - even the most powerful necromancer cannot conjure an upper body from naught!

src/MagusEngine/Services/Factory/TileFactory.cs (1)

131-141: Magnificent transmutation magic for reshaping the very foundations of our realm!

This extension method is a masterfully crafted spell for changing tile essences! It properly updates all mystical properties - appearance, walkability, transparency, and name - ensuring complete transformation. The call to UpdateLastSeenAppearence() shows wisdom in maintaining the visual consistency of our magical world.

Let me ensure the UpdateLastSeenAppearence() method exists in the Tile class:

#!/bin/bash
# Description: Verify UpdateLastSeenAppearence method exists on Tile class
# Expected: Method should be found in Tile class definition

echo "=== Searching for UpdateLastSeenAppearence method ==="
rg -A 5 "UpdateLastSeenAppearence" --type cs

echo "=== Checking Tile class for this method ==="
ast-grep --pattern 'class Tile {
  $$$
  UpdateLastSeenAppearence($$$) {
    $$$
  }
  $$$
}'
src/MagusEngine/Core/Magic/Effects/RaiseWallEffect.cs (1)

9-21: By the ancient scrolls, this spell implementation is most excellently crafted!

The RaiseWallEffect follows the mystical patterns established by the arcane architecture. The delegation to TileHelpers.ChangeTileEffect maintains proper separation of concerns, and the error messaging through the ethereal message bus ensures wizards are informed when their earth-shaping fails.

src/MagusEngine/Core/Magic/Effects/DigEffect.cs (1)

9-21: Ah, the mystical arts of excavation! This incantation mirrors its wall-raising sibling most admirably!

The DigEffect spell follows the same arcane patterns as its earthen counterpart, maintaining consistency in the magical framework. The transmutation from solid stone to open passage is handled with the same wisdom and error-catching enchantments.

src/Arquimedes/Utils/FileUtils.cs (2)

52-66: The formatting of this parallel enchantment has been made more readable to mortal eyes!

The restructuring of the parallel processing incantation with proper brace placement enhances the clarity of the magical operations, though the essence of the spell remains unchanged.


21-21: Ah, the previous incantation stumbled over its own toes—let us cast a simpler find-ritual to unearth all hidden JSON spell scrolls in the vault:

#!/bin/bash
echo "🔍 Summoning the find ritual for JSON spell scrolls in subdirectories:"
find src/Arquimedes/Data/Spells -type f -name "*.json"

This shall reveal any .json files nestling in deeper chambers.

src/Arquimedes/Data/Spells/spells_alteration.json (1)

1-42: Behold! These terrestrial transmutation spells are woven with great skill!

The spell definitions for both earth-shaping incantations are properly balanced and consistently structured. The magical parameters appear harmonious - both requiring level 2 mastery, 7 mana points, and 4 units of range. The contextual classifications are most wise: wall-raising blocks sight while digging creates passages.

One mystical query arises: the "IgnoresWall" property is set to true for both spells. Verify this is the intended behavior - should a wall-raising spell truly ignore existing walls, or should it perhaps fail when targeting an occupied space?

src/MagusEngine/Core/MapStuff/Tile.cs (2)

185-188: An elegant method to preserve the visual essence of mystical tiles!

The UpdateLastSeenAppearence() method centralizes the cloning ritual, removing duplication from the constructors. This encapsulation ensures consistent behavior when refreshing the tile's remembered visage.


46-47: The constructor formatting has been blessed with proper brace alignment!

The restructuring of constructor braces enhances readability while the calls to UpdateLastSeenAppearence() maintain consistent appearance tracking across all tile creation paths.

Also applies to: 61-61, 96-96

src/Diviner/KeyboardHandle.cs (2)

352-356: A mystical F2 key binding appears!

The forced FOV recalculation debug feature looks properly implemented. The incantation calls the map's ForceFovCalculation() method cleanly.


358-363: The K key now holds the power of transparency!

This debug feature allows toggling tile transparency, which is most useful for testing sight mechanics. The null-conditional operator on _targetCursor?.TileInTarget() is wisely used.

src/MagusEngine/Services/Factory/SpellEffectFactory.cs (2)

22-23: New terraforming spells have been inscribed in the factory!

The registration of "RAISEWALL" and "DIG" spell effects follows the established pattern perfectly. These new mystical powers will serve the wizards well.


26-26: The spell effect type transformation is complete!

The parameter type changes from EffectType to SpellEffectType are consistent and properly applied across both method signatures. This enchantment aligns with the enum refactoring throughout the realm.

Also applies to: 30-30

src/Diviner/Windows/LookWindow.cs (3)

78-87: A wise consolidation of console creation magic!

The new CreateLookConsole() method properly centralizes the console creation logic, ensuring consistent sizing and positioning. The cursor positioning at (0, 0) is appropriate for the start of content.


40-74: Magnificent enhancement to tile divination powers!

The tile constructor now provides incredibly detailed information about tiles, including material, transparency, walkability, traits, vegetation, and water depth. This wealth of information will greatly aid wizards in understanding their environment, especially with the new terraforming spells.


65-68: Potential null reference in vegetation component access!

The vegetation component access could fail if vegetation is null despite the successful GetComponent call. The null-forgiving operator on vegetation!.Plant.Name is risky.

Add proper null verification to your plant-sensing spell:

-            if (tile!.GetComponent<PlantComponent>(out var vegetation))
-            {
-                desc.Append("Tile has the following vegetation: ").Append(vegetation!.Plant.Name).AppendLine();
-            }
+            if (tile!.GetComponent<PlantComponent>(out var vegetation) && vegetation?.Plant != null)
+            {
+                desc.Append("Tile has the following vegetation: ").Append(vegetation.Plant.Name).AppendLine();
+            }

Likely an incorrect or invalid review comment.

src/MagusEngine/Core/Entities/Target.cs (6)

1-3: By my staff and scroll! These using statements appear well-ordered.

The addition of System, System.Collections.Generic, and System.Linq using directives aligns with the code's usage patterns and supports the modernization efforts in this mystical targeting system.


157-157: The null-forgiving operators here seem justified, master wizard.

Given the context where _selectedSpell and _caster are checked for range validity just above, these null-forgiving operators appear safe. The logic flow ensures these fields are non-null when this line executes.


166-166: Excellent nullability enhancement! The Item may indeed be null.

Changing the return type from (bool, Item) to (bool, Item?) properly reflects that the item might be null when the operation fails. This improves the API's expressiveness.


206-206: The state transition to IdleMode intrigues me greatly!

This change from LookMode to IdleMode suggests a refinement in the targeting state machine. This aligns with the terrain-altering spell features that may require different idle behaviors.

#!/bin/bash
# Description: Verify the TargetState enum and understand the IdleMode addition
# Expected: Find TargetState enum definition and usage patterns

# Search for TargetState enum definition
ast-grep --pattern 'enum TargetState {
  $$$
}'

# Search for IdleMode usage across the codebase
rg -A 2 -B 2 "IdleMode"

215-215: ```shell
#!/bin/bash

Verify if nullable reference types are enabled in MagusEngine project

grep -R "" -n src/MagusEngine/MagusEngine.csproj


---

`81-81`: Ah, let us peer into the arcane scrolls and reveal the true order of the MapLayer realms and the nature of the MaskAllBelow incantation:


```shell
#!/bin/bash
# Retrieve MapLayer enum definition and its values
rg -n 'enum MapLayer' -A 50 -B 0 --color=never

# Retrieve the MaskAllBelow implementation to see its behavior
rg -n 'MaskAllBelow' -A 5 -B 2 --color=never
src/MagusEngine/Core/MapStuff/MagiMap.cs (7)

1-4: The using statements have been reorganized with mystical precision!

These import adjustments support the codebase modernization and new features. The addition of MagusEngine.Services.Factory suggests integration with the new terrain-altering spell system.

Also applies to: 9-9, 13-13


102-102: The useCachedGridViews: true parameter brings performance enchantments!

This constructor parameter addition suggests optimization for grid view caching, which would benefit the new terrain-altering spells that likely perform frequent tile queries.


212-213: Behold! The collection expressions of modern C# magic!

These updates to use collection expressions ([.. collection]) instead of .ToArray() represent excellent modernization. The syntax is more concise and potentially more performant.

Also applies to: 216-217, 218-218


381-381: The EntityRender initialization embraces the new collection syntax beautifully!

The modernized collection initialization ([]) is cleaner and more idiomatic than the previous syntax.


442-442: The random number generator simplification is most elegant!

Simplifying from the previous verbose random number generator usage to GlobalRandom.DefaultRNG improves code readability while maintaining functionality.


514-514: The collection expressions bring order to this mystical realm!

These modernized collection initializations using [] and [.. collection] syntax represent excellent upgrades to more idiomatic C# code. The spread operator usage in [.. tiles] is particularly elegant.

Also applies to: 533-533, 578-578, 676-676, 823-823


32-32: Beware! This inheritance change from GoRogue's Map to a local Map class is significant sorcery.

This fundamental change in base class inheritance could have wide-reaching implications. Ensure the local Map class provides all necessary functionality that was previously inherited from GoRogue.GameFramework.Map.

#!/bin/bash
# Description: Find the local Map class definition and compare with GoRogue.GameFramework.Map
# Expected: Locate the local Map class and understand its relationship to GoRogue's Map

# Search for local Map class definition
ast-grep --pattern 'class Map $$$'

# Search for references to GoRogue.GameFramework.Map to understand the migration
rg -A 3 -B 3 "GoRogue\.GameFramework\.Map"


public int SolidManaCost { get; set; }
public EffectType EffectType { get; set; }
public SpellEffectType EffectType { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

The permanent enchantment embraces the renamed mystical essence!

Excellent transmutation, dear wizard! The EffectType property now properly channels the renamed SpellEffectType enum, aligning with the grand restructuring of our magical taxonomy.

However, I perceive that this mystical property remains unbound in the constructor's ritual! Unlike its brethren in other effect classes, this EffectType is not given form during the object's creation, which may lead to undefined magical behavior.

Consider initializing this property in the constructor or providing a default value:

[JsonConstructor]
public PermEffect(Actor caster, ISpellEffect enchantment, int nodeCost, string enchantName,
    string enchantDesc)
{
    Caster = caster;
    Enchantment = enchantment;
    SolidManaCost = nodeCost;
    EnchantName = enchantName;
    EnchantDesc = enchantDesc;
+   EffectType = enchantment?.EffectType switch
+   {
+       string effectTypeStr when Enum.TryParse<SpellEffectType>(effectTypeStr, out var result) => result,
+       _ => SpellEffectType.NONE // or appropriate default
+   };
}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/MagusEngine/Core/Magic/Effects/PermEffect.cs at line 15, the EffectType
property is declared but not initialized in the constructor, which can cause it
to have an undefined value. To fix this, modify the constructor of the
PermEffect class to assign a default or specific SpellEffectType value to the
EffectType property during object creation, ensuring it is properly initialized
like in other effect classes.

Comment thread src/MagusEngine/Core/Magic/Effects/TeleportEffect.cs Outdated
public MEssionEffect()
{
EffectType = EffectType.MEMISSION;
EffectType = Arquimedes.Enumerators.SpellEffectType.MEMISSION.ToString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

A properly cast incantation, though it could be more elegant!

The fully qualified namespace usage is wise, and the .ToString() transformation aligns with the new string-based spell effect system. However, this mystical working could be more efficient.

Consider using a constant string instead of repeated .ToString() calls across effect classes:

-EffectType = Arquimedes.Enumerators.SpellEffectType.MEMISSION.ToString();
+EffectType = nameof(SpellEffectType.MEMISSION);

Or create a static class with pre-computed string constants to avoid runtime string generation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
EffectType = Arquimedes.Enumerators.SpellEffectType.MEMISSION.ToString();
EffectType = nameof(SpellEffectType.MEMISSION);
🤖 Prompt for AI Agents
In src/MagusEngine/Core/Magic/Effects/MEssionEffect.cs at line 12, the
assignment uses a fully qualified enum with a .ToString() call which generates
the string at runtime. To improve efficiency, replace this with a constant
string representing the effect type or create a static class holding
pre-computed string constants for all spell effect types, then reference the
constant here instead of calling .ToString() repeatedly.

public LightEffect()
{
EffectType = EffectType.LIGHT;
EffectType = Arquimedes.Enumerators.SpellEffectType.LIGHT.ToString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Your illumination spell shines true, but with unnecessary complexity!

While your fully qualified incantation Arquimedes.Enumerators.SpellEffectType.LIGHT.ToString() works perfectly, I noticed other spell effects use the simpler SpellEffectType.LIGHT.ToString() pattern. For consistency across our magical grimoire, consider harmonizing the approach!

-            EffectType = Arquimedes.Enumerators.SpellEffectType.LIGHT.ToString();
+            EffectType = SpellEffectType.LIGHT.ToString();
🤖 Prompt for AI Agents
In src/MagusEngine/Core/Magic/Effects/LightEffect.cs at line 14, replace the
fully qualified enum reference
Arquimedes.Enumerators.SpellEffectType.LIGHT.ToString() with the simpler
SpellEffectType.LIGHT.ToString() to maintain consistency with other spell
effects. Ensure the appropriate using directive for the Arquimedes.Enumerators
namespace is present at the top of the file to support this simplification.


public ColoredGlyph Appearence { get; } = null!;
public ColoredGlyph? LastSeenAppereance { get; }
public ColoredGlyph? LastSeenAppereance { get; private set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

A wise encapsulation enchantment has been cast upon the appearance mystique!

The change from public to private setter provides proper protection for the LastSeenAppereance property, preventing unauthorized modifications from external realms.

Whispers from the ancient texts: The spelling "Appereance" lacks an 'a' - it should be "Appearance". Though this likely echoes throughout the magical codebase, future scribes might wish to correct this orthographic anomaly.

🤖 Prompt for AI Agents
In src/MagusEngine/Core/MapStuff/Tile.cs at line 18, the property
LastSeenAppereance has a spelling mistake in its name; it should be
LastSeenAppearance. Rename the property to correct the spelling, ensuring all
references in the codebase are updated accordingly to maintain consistency and
prevent errors.

Comment on lines +795 to 796
// const int defaultSearchRange = 25;
throw new NotImplementedException("Lazy");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

The FindTypeOfFood method remains unimplemented - a task for future wizards!

The method throws NotImplementedException("Lazy") with commented-out code. While not directly related to the terrain spells, consider whether this functionality might be needed for the complete spell system.

Would you like me to help implement this method or create an issue to track this missing functionality?

Also applies to: 809-810

🤖 Prompt for AI Agents
In src/MagusEngine/Core/MapStuff/MagiMap.cs around lines 795-796 and 809-810,
the FindTypeOfFood method is currently unimplemented and throws
NotImplementedException with a placeholder comment. Decide if this method is
necessary for the spell system; if so, implement the method logic based on the
intended functionality or create a tracking issue to address this missing
feature later. Remove the NotImplementedException and replace it with the proper
implementation or a clear TODO comment referencing the issue.

{
Tile? door = GetTileAt<DoorComponent>(room.DoorsPoint[t]);
room.Doors.Add(door);
room.Doors.Add(door!);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Another null-forgiving operator - the door shall not be null!

In the context of UpdateRooms(), this assumes that GetTileAt<DoorComponent> always returns a valid door tile. Consider whether this assumption holds true in all map generation scenarios.

🤖 Prompt for AI Agents
In src/MagusEngine/Core/MapStuff/MagiMap.cs at line 176, the code uses a
null-forgiving operator on 'door' when adding it to room.Doors, assuming 'door'
is never null. Review the logic in UpdateRooms() to verify if
GetTileAt<DoorComponent> can indeed return null in any scenario. If it can, add
a null check before adding to room.Doors to avoid potential runtime exceptions;
otherwise, document why null is impossible here and consider removing the
null-forgiving operator for clarity.

Point[] posRoom = r.RoomPoints;

for (int x = 0; x < r.Template.Obj.Rows.Length; x++)
for (int x = 0; x < r!.Template!.Obj!.Rows.Length; x++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

More null-forgiving operators - the pattern continues throughout this enchanted map!

These operators follow the same pattern seen throughout the file. While they suppress warnings, ensure that the underlying assumptions about non-null values remain valid as the codebase evolves, especially with the new terrain-altering spells that may modify map structure.

Also applies to: 592-592, 619-619, 623-623, 646-646

🤖 Prompt for AI Agents
In src/MagusEngine/Core/MapStuff/MagiMap.cs at lines 586, 592, 619, 623, and
646, the code uses multiple null-forgiving operators (!) to suppress null
warnings on objects like r, Template, and Obj. Review these usages to ensure the
objects are indeed non-null at runtime. Replace the null-forgiving operators
with proper null checks or conditional logic to safely handle potential null
values, preventing runtime exceptions as the map structure changes.

public void ForceFovCalculation()
{
Actor actor = (Actor)ControlledEntitiy;
Actor actor = (Actor)ControlledEntitiy!;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

The forced FOV calculation assumes the ControlledEntity is an Actor!

This null-forgiving operator with cast assumes ControlledEntity is always non-null and always an Actor. Consider adding a type check to prevent runtime exceptions.

-Actor actor = (Actor)ControlledEntitiy!;
+if (ControlledEntitiy is not Actor actor)
+    return;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Actor actor = (Actor)ControlledEntitiy!;
if (ControlledEntitiy is not Actor actor)
return;
🤖 Prompt for AI Agents
In src/MagusEngine/Core/MapStuff/MagiMap.cs at line 431, the code forcibly casts
ControlledEntity to Actor using the null-forgiving operator, assuming it is
always non-null and of type Actor. To fix this, add a type check using the 'is'
or 'as' operator to verify ControlledEntity is not null and is an Actor before
casting. Handle the case where it is not an Actor or is null to avoid runtime
exceptions.

return (T)filter.Item;
}
return default;
return default!;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

This default return with null-forgiving operator seems perilous!

Returning default! for a generic type T where T : IGameObject could return null when the caller expects a valid object. This could lead to null reference exceptions downstream.

-return default!;
+throw new InvalidOperationException($"Entity with ID {id} not found in the map.");

Consider throwing an exception instead of returning a potentially null value, as this better communicates the failure condition.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return default!;
throw new InvalidOperationException($"Entity with ID {id} not found in the map.");
🤖 Prompt for AI Agents
In src/MagusEngine/Core/MapStuff/MagiMap.cs at line 372, replace the return of
default! with throwing an exception to clearly indicate failure instead of
returning a potentially null generic IGameObject. This prevents null reference
exceptions downstream by explicitly signaling that a valid object could not be
returned.

@github-advanced-security

Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@sonarqubecloud

Copy link
Copy Markdown

@Sofistico
Sofistico merged commit 9649e3e into master Jul 12, 2025
8 checks passed
@Sofistico
Sofistico deleted the feature/shape-terrain branch July 12, 2025 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Automatic AI Review

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants