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 & client config: scale building cost #1722

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

Conversation

credence0x
Copy link
Collaborator

contracts and client config for #1720

  • increase fixed cost of building by a certain percentage based on the number of the building type already on the realm

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 8:49pm

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 scaled building costs looks good and covers both contract and client-side changes. The new BuildingGeneralConfig model and its usage are well-implemented. The changes to the create function in BuildingCustomImpl to return both the Building and BuildingQuantityv2 are appropriate. The client-side SDK updates in EternumProvider and config/index.ts are consistent with the contract changes. The removal of the BonusPercentageImpl in favor of using PercentageImpl and PercentageValueImpl from the math utils is a good refactoring. The changes seem to be backwards compatible and shouldn't break existing functionality. Overall, this is a solid implementation of the scaled building costs feature.

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

contracts/src/models/buildings.cairo Show resolved Hide resolved
@@ -102,7 +102,7 @@ export const ONE_MONTH = 2628000;

// Buildings
export const BASE_POPULATION_CAPACITY = 5;

export const BUILDING_FIXED_COST_SCALE_PERCENT = 1_000; // 1_000/10_000 = 10%
Copy link

Choose a reason for hiding this comment

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

Consider making this scaling factor more easily configurable, possibly as an environment variable or part of a configuration object.

@@ -598,17 +583,33 @@ impl BuildingCustomImpl of BuildingCustomTrait {
destroyed_building_category
}

fn make_payment(world: IWorldDispatcher, entity_id: ID, category: BuildingCategory, resource_type: u8) {
let building_config: BuildingConfig = BuildingConfigCustomImpl::get(world, category, resource_type);
fn pay_fixed_cost(self: Building, building_quantity: BuildingQuantityv2, world: IWorldDispatcher) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this keep the same name as before? I feel like the function actually pays a variable cost

Comment on lines 352 to 353
// cost scale percent
base_cost_percent_increase: u16,
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment and change the name to be more explicit, we don't want comments to be everywhere if it can be explained through the name imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i dont actually know what a better name would be. ive renamed it like 5 times

Copy link
Collaborator

Choose a reason for hiding this comment

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

increase_per_extra_building_percent ? Honestly I prefer explicit and long than short haha

Copy link
Collaborator

Choose a reason for hiding this comment

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

quadratic_increase_per_extra_building_percent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it doesnt fit into a felt. long names wont fit into a felt

Copy link
Collaborator

Choose a reason for hiding this comment

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

Forgot dojo had those limitations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

31 characters at most

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