📌 Feature Request: Full Implementation of PropertyTrait for Game Property Logic
🧩 Description
Implement the full logic for all methods defined in the PropertyTrait within the PropertyImpl. This trait governs all interactions and transformations related to in-game properties such as ownership transfer, rent calculations, mortgage status, and development (upgrade/downgrade).
The current implementation provides a basic structure but lacks concrete logic in critical functions like upgrades, downgrades, and ownership changes. These need to be handled with proper validation and state updates.
🧠 Model Overview
#[dojo::model]
pub struct Property {
#[key]
pub id: u8,
#[key]
pub game_id: u256,
pub name: felt252,
pub owner: ContractAddress,
pub cost_of_property: u256,
pub property_level: u8,
pub rent_site_only: u256,
pub rent_one_house: u256,
pub rent_two_houses: u256,
pub rent_three_houses: u256,
pub rent_four_houses: u256,
pub cost_of_house: u256,
pub rent_hotel: u256,
pub is_mortgaged: bool,
pub group_id: u8,
pub for_sale: bool,
pub development: u8,
}
✅ Acceptance Criteria
🛠️ Implementation Notes
fn upgrade_property(ref self: Property, player: ContractAddress, upgrade_level: u8) -> bool {
if self.owner != player || self.is_mortgaged {
return false;
}
if self.property_level + upgrade_level > 5 {
return false;
}
self.property_level += upgrade_level;
self.development += upgrade_level;
true
}
fn downgrade_property(ref self: Property, player: ContractAddress, downgrade_level: u8) -> bool {
if self.owner != player || self.property_level < downgrade_level {
return false;
}
self.property_level -= downgrade_level;
self.development -= downgrade_level;
true
}
fn change_game_property_ownership(ref self: Property, new_owner: ContractAddress, owner: ContractAddress) -> bool {
if self.owner != owner || self.is_mortgaged == true || self.for_sale == false {
return false;
}
self.owner = new_owner;
self.for_sale = false;
true
}
🧪 Testing Notes
- ✅ Rent Test: Ensure correct rent is returned for each development level.
- ✅ Mortgage Test: Mortgage and lift mortgage reflect correctly in state.
- ✅ Upgrade Test: Upgrade only works for owner and within bounds.
- ✅ Downgrade Test: Prevents reducing below zero or by non-owner.
- ✅ Ownership Transfer Test: Only original owner can transfer, and only if conditions are met.
📘 Status
Stat: 🔄 Pending Implementation
Build: 🔲 To Be Confirmed
Validation: 🔲 Functional Logic Pending
📎 Additional Notes
- Consider emitting events for upgrades, downgrades, and ownership transfers for transparency.
- Guard against overflows on
development and property_level.
- Potential for adding auction mechanism for unowned properties in future.
📌 Feature Request: Full Implementation of
PropertyTraitfor Game Property Logic🧩 Description
Implement the full logic for all methods defined in the
PropertyTraitwithin thePropertyImpl. This trait governs all interactions and transformations related to in-game properties such as ownership transfer, rent calculations, mortgage status, and development (upgrade/downgrade).The current implementation provides a basic structure but lacks concrete logic in critical functions like upgrades, downgrades, and ownership changes. These need to be handled with proper validation and state updates.
🧠 Model Overview
✅ Acceptance Criteria
get_rent_amount()correctly computes rent based on development level (houses/hotel), returning0if the property is mortgaged.mortgage()andlift_mortgage()toggle theis_mortgagedflag correctly.upgrade_property():property_leveland updatesdevelopment.downgrade_property():property_levelis already zero.property_leveland adjustsdevelopment.change_game_property_ownership():new_owner.for_sale.🛠️ Implementation Notes
🧪 Testing Notes
📘 Status
Stat: 🔄 Pending Implementation
Build: 🔲 To Be Confirmed
Validation: 🔲 Functional Logic Pending
📎 Additional Notes
developmentandproperty_level.