Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: wonder model #2393

Merged
merged 1 commit into from
Dec 10, 2024
Merged

feat: wonder model #2393

merged 1 commit into from
Dec 10, 2024

Conversation

r0man1337
Copy link
Contributor

@r0man1337 r0man1337 commented Dec 10, 2024

Added wonder model for realm & worldmap views
image

Summary by CodeRabbit

  • New Features

    • Introduced a method to check if a realm has a wonder.
    • Added new model selection logic for structures with the hasWonder attribute.
    • Enhanced building type handling to accommodate a new category of buildings labeled as "Wonder".
  • Changes

    • Updated model paths to include the new "Wonder" realm type and its associated models.

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 7:37pm
eternum-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 7:37pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Dec 10, 2024 7:37pm

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes in this pull request introduce enhancements to the TileManager, StructureManager, and HexceptionScene classes. A new method getWonder is added to TileManager to check if a realm has a wonder. The StructureManager now includes logic to select a specific model for structures with the hasWonder property. Additionally, HexceptionScene is updated to recognize a new building type related to wonders, and constants for WONDER_REALM are introduced across multiple files for consistent handling of this new type.

Changes

File Path Change Summary
client/src/dojo/modelManager/TileManager.ts - Method added: getWonder() to check if the realm has a wonder.
- Modified setTile() to adjust col and row properties.
client/src/three/components/StructureManager.ts - Constant added: WONDER_MODEL_INDEX = 4 for model selection based on hasWonder.
client/src/three/scenes/Hexception.tsx - Constant added: WONDER_REALM.
- Updated buildingModels map to include WONDER_REALM.
- Adjusted logic in updateHexceptionGrid.
client/src/three/scenes/constants.ts - Constant added: export const WONDER_REALM = "Wonder";
- Updated buildingModelPaths and StructureModelPaths to include new paths for wonders.

Possibly related PRs

  • contracts: no lords burn during donkey production for wonders #2164: This PR adds a has_wonder property to the Realm component, which is directly related to the new getWonder method in the TileManager class that checks if a realm has a wonder.
  • [client] updated models, bugfix #2223: Although primarily focused on model updates, this PR's changes in the WorldmapScene may interact with the getWonder method's functionality, as it involves managing structures that could include wonders.
  • [client] hyperstructures hexception #2304: This PR introduces a structureType property in the existingBuildings method of the TileManager, which could relate to the new functionality provided by the getWonder method in determining the state of buildings in relation to wonders.

Suggested reviewers

  • edisontim

Poem

🐇 In the realm where wonders gleam,
A new method joins the team.
With models bright and paths anew,
Our structures dance in vibrant hue.
Hooray for tiles and realms so grand,
A wonder's touch across the land! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Experiment)
  • @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.

Copy link
Contributor

mentatbot bot commented Dec 10, 2024

You are out of MentatBot reviews. Your usage will refresh December 16 at 08:00 AM.

Copy link

Failed to generate code suggestions for PR

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
client/src/dojo/modelManager/TileManager.ts (1)

64-68: Consider extracting wonder-related constants to a dedicated configuration.

The wonder-related constants and configurations are currently spread across multiple files. Consider creating a dedicated configuration file (e.g., wonderConfig.ts) to centralize all wonder-related constants, paths, and configurations. This would improve maintainability and make it easier to extend wonder-related features in the future.

Also applies to: 17-17, 41-44

client/src/three/scenes/Hexception.tsx (1)

473-475: Add error handling for wonder model loading

While the wonder check is correctly placed, consider adding error handling in case the wonder model fails to load or isn't found in the buildingModels map.

 if (this.tileManager.getWonder()) {
   buildingType = WONDER_REALM;
+  if (!this.buildingModels.has(WONDER_REALM)) {
+    console.warn(`Wonder model not found, falling back to castle model: ${castleLevelToRealmCastle[this.structureStage]}`);
+    buildingType = castleLevelToRealmCastle[this.structureStage];
+  }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b010ea5 and ae73dfd.

📒 Files selected for processing (4)
  • client/src/dojo/modelManager/TileManager.ts (1 hunks)
  • client/src/three/components/StructureManager.ts (2 hunks)
  • client/src/three/scenes/Hexception.tsx (3 hunks)
  • client/src/three/scenes/constants.ts (3 hunks)
🔇 Additional comments (7)
client/src/three/scenes/constants.ts (2)

41-44: LGTM: Wonder type constant and type definition.

The constant and type definition are properly integrated into the existing type system.


75-75: Verify model file existence and consistency.

The wonder model paths are defined in two locations:

  • /models/buildings-opt/wonder.glb for building models
  • /models/buildings-opt/wonder2.glb for structure models

Also applies to: 108-108

✅ Verification successful

Both wonder model files exist and are correctly placed

The verification confirms that both wonder model files exist in the expected location:

  • /models/buildings-opt/wonder.glb
  • /models/buildings-opt/wonder2.glb

The files are present in the client/public/models/buildings-opt/ directory, which is the correct location as it will be served as static assets under /models/buildings-opt/ path in the client application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of wonder model files

# Check if the model files exist
fd -t f "wonder.*.glb$" "models/buildings-opt"

Length of output: 154


Script:

#!/bin/bash
# Let's first check if the models directory exists and its location
fd -t d "models"

# Also search for any .glb files to understand the model file structure
fd -t f ".glb$"

Length of output: 4736

client/src/three/components/StructureManager.ts (2)

168-170: LGTM: Wonder model selection logic.

The conditional logic for selecting the wonder model is properly implemented.


17-17: Verify array bounds for wonder model index.

The constant WONDER_MODEL_INDEX = 4 should match the index of the wonder model in StructureModelPaths[StructureType.Realm].

✅ Verification successful

Wonder model index constant matches array index

The constant WONDER_MODEL_INDEX = 4 correctly corresponds to the index of "models/buildings-opt/wonder2.glb" in the StructureType.Realm array, as it's the fifth element (index 4) in the array.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the wonder model index matches the array length

# Search for realm structure model paths array definition
rg -A 5 "\[StructureType\.Realm\]:\s*\[" "client/src/three/scenes/constants.ts"

Length of output: 306

client/src/dojo/modelManager/TileManager.ts (1)

64-68: LGTM: Wonder status retrieval implementation.

The getWonder method properly:

  • Retrieves the realm entity ID from the UI store
  • Uses optional chaining for safe property access
  • Provides a default value of false
client/src/three/scenes/Hexception.tsx (2)

101-103: LGTM: Type signature properly extended for wonder models

The type signature update correctly includes the new WONDER_REALM type alongside existing building and resource mining types.


473-475: Verify wonder model configuration

Let's ensure that the wonder model is properly configured in the constants file and the model file exists.

✅ Verification successful

Based on the search results, I can now generate the final response:

Wonder model configuration is properly integrated

The wonder model is correctly configured in the codebase:

  • WONDER_REALM constant is defined in client/src/three/scenes/constants.ts
  • The wonder model path is properly mapped to /models/buildings-opt/wonder.glb
  • The model file exists at client/public/models/buildings-opt/wonder.glb and wonder2.glb
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if WONDER_REALM is defined in constants and the model path exists
echo "Checking wonder model configuration..."

# Check WONDER_REALM constant definition
rg -A 1 "WONDER_REALM.*=.*" src/

# Check model path in buildingModelPaths
rg "wonder.*\.glb" src/

# List available model files
fd -e glb . models/buildings-opt/

Length of output: 382


Script:

#!/bin/bash
# Let's try searching from the repository root with proper paths
# First, let's find the correct source directory structure
fd -t d "src$"

# Then search for WONDER_REALM constant
rg "WONDER_REALM"

# Look for any .glb model files
fd -e glb

# Check for any wonder-related constants or configurations
rg -i "wonder" -g "*.{ts,tsx,js,jsx}"

Length of output: 69577

@ponderingdemocritus ponderingdemocritus merged commit b713ae2 into next Dec 10, 2024
6 of 9 checks passed
@ponderingdemocritus ponderingdemocritus deleted the feat/wonder branch December 10, 2024 22:08
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