Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/dojo_examples/combat_game/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dojo 1.2.1
scarb 2.9.2
dojo v1.6.0-alpha.1
scarb 2.10.1
14 changes: 7 additions & 7 deletions backend/dojo_examples/combat_game/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = 1
[[package]]
name = "achievement"
version = "0.0.0"
source = "git+https://github.com/cartridge-gg/arcade?tag=v1.2.1#8b8ccea5ec85ae7f903903ced9cd16e16b8e47cb"
source = "git+https://github.com/cartridge-gg/arcade?tag=v1.6.0-alpha.1#0378ed6d9d8188fa6532e66c8db8729a27eb8a5f"
dependencies = [
"dojo",
]
Expand All @@ -20,21 +20,21 @@ dependencies = [

[[package]]
name = "dojo"
version = "1.2.1"
source = "git+https://github.com/dojoengine/dojo?tag=v1.2.1#3d4b1a3e662f70679813f9fb65c0b5c7fa5d6f0a"
version = "1.6.0-alpha.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.6.0-alpha.1#054623bbf939a3bf90786355bd9b081a2b1b3c3a"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_cairo_test"
version = "1.0.12"
source = "git+https://github.com/dojoengine/dojo?tag=v1.2.1#3d4b1a3e662f70679813f9fb65c0b5c7fa5d6f0a"
version = "1.6.0-alpha.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.6.0-alpha.1#054623bbf939a3bf90786355bd9b081a2b1b3c3a"
dependencies = [
"dojo",
]

[[package]]
name = "dojo_plugin"
version = "2.9.2"
source = "git+https://github.com/dojoengine/dojo?tag=v1.2.1#3d4b1a3e662f70679813f9fb65c0b5c7fa5d6f0a"
version = "2.10.1"
source = "git+https://github.com/dojoengine/dojo?tag=v1.6.0-alpha.1#054623bbf939a3bf90786355bd9b081a2b1b3c3a"
10 changes: 5 additions & 5 deletions backend/dojo_examples/combat_game/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
cairo-version = "2.9.2"
cairo-version = "2.10.1"
name = "combat_game"
version = "0.1.0"
edition = "2023_11"
Expand All @@ -11,8 +11,8 @@ sierra-replace-ids = true
sepolia = "sozo --profile sepolia clean && sozo --profile sepolia build && sozo --profile sepolia migrate --account-address $DEPLOYER_ACCOUNT_ADDRESS --private-key $DEPLOYER_PRIVATE_KEY --fee strk"

[dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.2.1" }
achievement = { git = "https://github.com/cartridge-gg/arcade", tag = "v1.2.1" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.6.0-alpha.1" }
achievement = { git = "https://github.com/cartridge-gg/arcade", tag = "v1.6.0-alpha.1" }

[[target.starknet-contract]]
build-external-contracts = [
Expand All @@ -22,7 +22,7 @@ build-external-contracts = [
]

[dev-dependencies]
cairo_test = "2.9.2"
dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.2.1" }
cairo_test = "2.10.1"
dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.6.0-alpha.1" }

[profile.sepolia]
47 changes: 30 additions & 17 deletions backend/dojo_examples/combat_game/src/models/skill.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ pub impl SkillImpl of SkillTrait {
#[cfg(test)]
mod tests {
use super::{
SkillImpl, SkillType,
SLASH_SKILL_ID, BEAM_SKILL_ID, WAVE_SKILL_ID, PUNCH_SKILL_ID, KICK_SKILL_ID,
BLAST_SKILL_ID, CRUSH_SKILL_ID, PIERCE_SKILL_ID, SMASH_SKILL_ID, BURN_SKILL_ID,
FREEZE_SKILL_ID, SHOCK_SKILL_ID, DEFAULT_SKILL_ID,
SLASH_SKILL_DAMAGE, BEAM_SKILL_DAMAGE, WAVE_SKILL_DAMAGE, PUNCH_SKILL_DAMAGE,
KICK_SKILL_DAMAGE, BLAST_SKILL_DAMAGE, CRUSH_SKILL_DAMAGE, PIERCE_SKILL_DAMAGE,
SMASH_SKILL_DAMAGE, BURN_SKILL_DAMAGE, FREEZE_SKILL_DAMAGE, SHOCK_SKILL_DAMAGE,
DEFAULT_SKILL_DAMAGE,
SkillImpl, SkillType, SLASH_SKILL_ID, BEAM_SKILL_ID, WAVE_SKILL_ID, PUNCH_SKILL_ID,
KICK_SKILL_ID, BLAST_SKILL_ID, CRUSH_SKILL_ID, PIERCE_SKILL_ID, SMASH_SKILL_ID,
BURN_SKILL_ID, FREEZE_SKILL_ID, SHOCK_SKILL_ID, DEFAULT_SKILL_ID, SLASH_SKILL_DAMAGE,
BEAM_SKILL_DAMAGE, WAVE_SKILL_DAMAGE, PUNCH_SKILL_DAMAGE, KICK_SKILL_DAMAGE,
BLAST_SKILL_DAMAGE, CRUSH_SKILL_DAMAGE, PIERCE_SKILL_DAMAGE, SMASH_SKILL_DAMAGE,
BURN_SKILL_DAMAGE, FREEZE_SKILL_DAMAGE, SHOCK_SKILL_DAMAGE, DEFAULT_SKILL_DAMAGE,
};

#[test]
Expand Down Expand Up @@ -248,10 +246,19 @@ mod tests {
fn test_all_skill_constants() {
// Test that all skill ID constants are unique
let skill_ids = array![
SLASH_SKILL_ID, BEAM_SKILL_ID, WAVE_SKILL_ID, PUNCH_SKILL_ID,
KICK_SKILL_ID, BLAST_SKILL_ID, CRUSH_SKILL_ID, PIERCE_SKILL_ID,
SMASH_SKILL_ID, BURN_SKILL_ID, FREEZE_SKILL_ID, SHOCK_SKILL_ID,
DEFAULT_SKILL_ID
SLASH_SKILL_ID,
BEAM_SKILL_ID,
WAVE_SKILL_ID,
PUNCH_SKILL_ID,
KICK_SKILL_ID,
BLAST_SKILL_ID,
CRUSH_SKILL_ID,
PIERCE_SKILL_ID,
SMASH_SKILL_ID,
BURN_SKILL_ID,
FREEZE_SKILL_ID,
SHOCK_SKILL_ID,
DEFAULT_SKILL_ID,
];

// Test that each ID is within expected range
Expand All @@ -262,12 +269,18 @@ mod tests {
assert!(KICK_SKILL_ID >= 1 && KICK_SKILL_ID <= 13, "Kick skill ID should be in range");
assert!(BLAST_SKILL_ID >= 1 && BLAST_SKILL_ID <= 13, "Blast skill ID should be in range");
assert!(CRUSH_SKILL_ID >= 1 && CRUSH_SKILL_ID <= 13, "Crush skill ID should be in range");
assert!(PIERCE_SKILL_ID >= 1 && PIERCE_SKILL_ID <= 13, "Pierce skill ID should be in range");
assert!(
PIERCE_SKILL_ID >= 1 && PIERCE_SKILL_ID <= 13, "Pierce skill ID should be in range",
);
assert!(SMASH_SKILL_ID >= 1 && SMASH_SKILL_ID <= 13, "Smash skill ID should be in range");
assert!(BURN_SKILL_ID >= 1 && BURN_SKILL_ID <= 13, "Burn skill ID should be in range");
assert!(FREEZE_SKILL_ID >= 1 && FREEZE_SKILL_ID <= 13, "Freeze skill ID should be in range");
assert!(
FREEZE_SKILL_ID >= 1 && FREEZE_SKILL_ID <= 13, "Freeze skill ID should be in range",
);
assert!(SHOCK_SKILL_ID >= 1 && SHOCK_SKILL_ID <= 13, "Shock skill ID should be in range");
assert!(DEFAULT_SKILL_ID >= 1 && DEFAULT_SKILL_ID <= 13, "Default skill ID should be in range");
assert!(
DEFAULT_SKILL_ID >= 1 && DEFAULT_SKILL_ID <= 13, "Default skill ID should be in range",
);
}

#[test]
Expand All @@ -276,7 +289,7 @@ mod tests {
// Test that base damage matches what would be set when creating skills
let slash_skill = SkillImpl::new(SLASH_SKILL_ID, SLASH_SKILL_DAMAGE, SkillType::Slash, 1);
let calculated_damage = SkillImpl::base_damage(SkillType::Slash);

assert_eq!(slash_skill.power, calculated_damage, "Skill power should match base damage");
}
}
}
2 changes: 1 addition & 1 deletion backend/dojo_examples/combat_game/src/systems/beast.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub mod beast_system {
store.init_beast_skills(beast_id);

let beast_stats = BeastStatsActionTrait::new_beast_stats(
beast_id, beast_type, beast.level, get_block_timestamp()
beast_id, beast_type, beast.level, get_block_timestamp(),
);
store.write_beast_stats(beast_stats);
beast_id
Expand Down
2 changes: 1 addition & 1 deletion backend/dojo_examples/combat_game/src/systems/player.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod player_system {
player_counter: u256,
}

// Constructor
// Constructor
fn dojo_init(ref self: ContractState) {
self.player_counter.write(1);
}
Expand Down
4 changes: 2 additions & 2 deletions backend/dojo_examples/combat_game/src/types/beast_type.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub impl Intou8BeastType of Into<u8, BeastType> {
0 => BeastType::Light,
1 => BeastType::Magic,
2 => BeastType::Shadow,
_ => BeastType::Light, // Default fallback
_ => BeastType::Light // Default fallback
}
}
}
Expand Down Expand Up @@ -153,4 +153,4 @@ mod tests {
let display_string = format!("{}", beast_type);
assert_eq!(display_string, "Shadow");
}
}
}
Loading