-
Notifications
You must be signed in to change notification settings - Fork 51
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: allow realm capture #1216
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes seem to be focused on modifying the ownership model and allowing realms to be captured. While these changes might be intentional, they introduce significant alterations to the game mechanics, particularly around structure and army ownership. It's crucial to ensure that these changes are thoroughly tested and that all parts of the codebase that interact with ownership are updated accordingly. The removal of certain ownership-related operations could potentially lead to inconsistencies if not handled properly throughout the entire system.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
@@ -481,7 +481,7 @@ impl BuildingCustomImpl of BuildingCustomTrait { | |||
|
|||
|
|||
fn destroy(world: IWorldDispatcher, outer_entity_id: ID, inner_coord: Coord) -> BuildingCategory { | |||
get!(world, outer_entity_id, Owner).assert_caller_owner(); | |||
get!(world, outer_entity_id, EntityOwner).assert_caller_owner(world); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change. Using EntityOwner
instead of Owner
is more appropriate for this context, as it's specifically dealing with entity ownership.
@@ -792,9 +792,6 @@ mod combat_systems { | |||
let structure: Structure = get!(world, structure_id, Structure); | |||
structure.assert_is_structure(); | |||
|
|||
// ensure structure is not a realm | |||
assert!(structure.category != StructureCategory::Realm, "realms can not be claimed"); | |||
|
|||
// ensure claimer army is not in battle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this assertion allows realms to be claimed now. Make sure this is the intended behavior and that there are appropriate safeguards or restrictions in place for realm claiming.
|
||
let mut structure_army_owner: Owner = get!(world, structure_army_id, Owner); | ||
structure_army_owner.address = starknet::get_caller_address(); | ||
set!(world, (structure_army_owner)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of setting the structure_army_owner
might have implications. Ensure that this doesn't break any logic related to army ownership after a structure is claimed.
let claimer_army_owner_entity_id: ID = get!(world, army_id, EntityOwner).entity_owner_id; | ||
structure_owner_entity.entity_owner_id = claimer_army_owner_entity_id; | ||
set!(world, (structure_owner_entity)); | ||
|
||
let mut structure_owner: Owner = get!(world, structure_id, Owner); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EntityOwner
update for the structure has been removed. This might affect how ownership is tracked at the entity level. Make sure this doesn't break any existing functionality that relies on EntityOwner
.
@@ -1222,7 +1209,6 @@ mod combat_systems { | |||
entity_id: army_id, troops: Default::default(), battle_id: 0, battle_side: Default::default() | |||
}, | |||
EntityOwner { entity_id: army_id, entity_owner_id: army_owner_id }, | |||
Owner { entity_id: army_id, address: owner_address }, | |||
Position { entity_id: army_id, x: army_owner_position.x, y: army_owner_position.y } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Owner
component is no longer being set for the army. This could have implications for ownership checks elsewhere in the code. Ensure that all places that previously relied on the Owner
component for armies are updated accordingly.
PR Reviewer Guide 🔍
|
PR Code Suggestions ✨
|
… realm-capture
… realm-capture
… realm-capture
… realm-capture
3003532
to
8a72cb0
Compare
1e3e90a
to
725e95f
Compare
725e95f
to
cfe1080
Compare
0c26727
to
f54ea84
Compare
f54ea84
to
8fded13
Compare
97f28db
to
aa32d31
Compare
aa32d31
to
935cd52
Compare
PR Type
enhancement, bug fix
Description
destroy
function inbuildings.cairo
to useEntityOwner
instead ofOwner
for ownership checks.combat/contracts.cairo
.Changes walkthrough 📝
buildings.cairo
Update ownership handling in building destruction
contracts/src/models/buildings.cairo
OwnerCustomTrait
toEntityOwnerCustomTrait
.destroy
function to useEntityOwner
instead ofOwner
.contracts.cairo
Allow realm capture and simplify combat ownership logic
contracts/src/systems/combat/contracts.cairo
Owner
initialization for armies.