Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
credence0x committed Oct 18, 2024
1 parent 6f008ce commit 3e85f97
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.7.0
dojo 1.0.0-alpha.12
dojo 1.0.0-alpha.16
2 changes: 1 addition & 1 deletion contracts/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.7.0
dojo 1.0.0-alpha.12
dojo 1.0.0-alpha.16
40 changes: 20 additions & 20 deletions contracts/src/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -118,53 +118,53 @@ mod ResourceTypes {

fn resource_type_name(resource_type: u8) -> ByteArray {
if resource_type == 1 {
"WOOD"
} else if resource_type == 2 {
"STONE"
} else if resource_type == 3 {
} else if resource_type == 2 {
"COAL"
} else if resource_type == 3 {
"WOOD"
} else if resource_type == 4 {
"COPPER"
} else if resource_type == 5 {
"OBSIDIAN"
"IRONWOOD"
} else if resource_type == 6 {
"SILVER"
"OBSIDIAN"
} else if resource_type == 7 {
"IRONWOOD"
"GOLD"
} else if resource_type == 8 {
"COLD IRON"
"SILVER"
} else if resource_type == 9 {
"GOLD"
"MITHRAL"
} else if resource_type == 10 {
"HARTWOOD"
"ALCHEMICAL_SILVER"
} else if resource_type == 11 {
"DIAMONDS"
"COLD_IRON"
} else if resource_type == 12 {
"SAPPHIRE"
"DEEP_CRYSTAL"
} else if resource_type == 13 {
"RUBY"
} else if resource_type == 14 {
"DEEP CRYSTAL"
"DIAMONDS"
} else if resource_type == 15 {
"IGNIUM"
"HARTWOOD"
} else if resource_type == 16 {
"ETHEREAL SILICA"
"IGNIUM"
} else if resource_type == 17 {
"TRUE ICE"
"TWILIGHT_QUARTZ"
} else if resource_type == 18 {
"TWILIGHT QUARTZ"
"TRUE_ICE"
} else if resource_type == 19 {
"ALCHEMICAL SILVER"
} else if resource_type == 20 {
"ADAMANTINE"
} else if resource_type == 20 {
"SAPPHIRE"
} else if resource_type == 21 {
"MITHRAL"
"ETHEREAL_SILICA"
} else if resource_type == 22 {
"DRAGONHIDE"
} else if resource_type == 28 {
"DEMONHIDE"
} else if resource_type == 29 {
"EARTHEN SHARD"
"EARTHEN_SHARD"
} else if resource_type == 249 {
"DONKEY"
} else if resource_type == 250 {
Expand Down
21 changes: 21 additions & 0 deletions contracts/src/models/hyperstructure.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,24 @@ pub impl EpochCustomImpl of EpochCustomTrait {
epoch
}
}

#[generate_trait]
pub impl HyperstructureCustomImpl of HyperstructureCustomTrait {
fn assert_access(self: Hyperstructure, world: IWorldDispatcher) {
let contributor_address = starknet::get_caller_address();
let hyperstructure_owner = get!(world, self.entity_id, Owner);

match self.access {
Access::Public => {},
Access::Private => {
assert!(contributor_address == hyperstructure_owner.address, "Hyperstructure is private");
},
Access::GuildOnly => {
let guild_member = get!(world, contributor_address, GuildMember);

let owner_guild_member = get!(world, hyperstructure_owner.address, GuildMember);
assert!(guild_member.guild_entity_id == owner_guild_member.guild_entity_id, "not in the same guild");
}
}
}
}

0 comments on commit 3e85f97

Please sign in to comment.