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

contracts: feature: introduce realm levels #1721

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

credence0x
Copy link
Collaborator

contracts for #1719

  • introduce realm levels
  • create a function for upgrading realm levels as well as functions for configuration
  • restrict building on certain hexes depending on realm level
  • tests

Copy link

vercel bot commented Sep 27, 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 Sep 27, 2024 2:19am

Copy link

Failed to generate code suggestions for PR

Copy link

@mentatbot mentatbot bot left a comment

Choose a reason for hiding this comment

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

The implementation of realm levels looks solid and well-integrated with existing systems. The new functionality includes a level field in the Realm struct, a RealmLevelConfig for storing level-up requirements, and an upgrade_level function in the realm systems contract. The building creation process now checks the realm's level before allowing placement, which is a good way to enforce level restrictions.

The tests are comprehensive and cover various scenarios, including successful upgrades, insufficient resources, and attempts to upgrade beyond the max level. The max level is currently hardcoded to 3, which might be worth reconsidering for future flexibility.

Overall, the changes seem well-thought-out and follow established patterns in the codebase. Consider adding more documentation for the realm level mechanics and possibly emitting events for level upgrades to improve observability.

Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!

impl RealmCustomImpl of RealmCustomTrait {
fn max_level(self: Realm) -> u8 {
Copy link

Choose a reason for hiding this comment

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

Consider making the max_level configurable rather than hardcoded. This would allow for easier adjustments in the future if needed.

@@ -178,5 +180,42 @@ mod realm_systems {

Copy link

Choose a reason for hiding this comment

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

Consider emitting an event when a realm is upgraded. This would be useful for tracking realm progress and could be used by the frontend or other systems.

Suggested change

let directions_count = directions.len();
assert!(directions_count > 0, "building cant be made at the center");
assert!(directions_count <= realm.max_level().into() + 1, "building outside of max bound");
assert!(directions_count <= realm.level.into() + 1, "building outside of what realm level allows");
Copy link

Choose a reason for hiding this comment

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

The error message 'building outside of what realm level allows' could be more informative. Consider including the current realm level and the required level in the message.

Suggested change
assert!(directions_count <= realm.level.into() + 1, "building outside of what realm level allows");
assert!(directions_count <= realm.level.into() + 1,
&format!("building outside of what realm level allows: current level is {}, required level is {}", realm.level, directions_count - 1));

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.

1 participant