Skip to content

Commit

Permalink
add interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinones committed Nov 2, 2024
1 parent 07321cd commit 22004c5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/erc721.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ use starknet::ContractAddress;

#[dojo::interface]
trait IERC721System {
fn owner_of(ref world: IWorldDispatcher, token_id: u256) -> ContractAddress;
fn owner_of(world: @IWorldDispatcher, token_id: u256) -> ContractAddress;
}
39 changes: 38 additions & 1 deletion src/interfaces/loot_survivor.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait};
#[derive(Drop, Copy, PartialEq, Serde)]
struct Item { // 21 storage bits
id: u8, // 7 bits
xp: u16, // 9 bits
}

#[derive(Drop, Copy, Serde, PartialEq)]
struct Equipment { // 128 bits
weapon: Item,
chest: Item,
head: Item,
waist: Item, // 16 bits per item
foot: Item,
hand: Item,
neck: Item,
ring: Item,
}

#[derive(Drop, Copy, Serde, PartialEq)]
struct Stats { // 30 bits total
strength: u8,
dexterity: u8,
vitality: u8, // 5 bits per stat
intelligence: u8,
wisdom: u8,
charisma: u8,
luck: u8 // dynamically generated, not stored.
}

#[derive(Drop, Copy, Serde)]
struct Adventurer {
xp: u16
health: u16, // 10 bits
xp: u16, // 15 bits
gold: u16, // 9 bits
beast_health: u16, // 10 bits
stat_upgrades_available: u8, // 4 bits
stats: Stats, // 30 bits
equipment: Equipment, // 128 bits
battle_action_count: u8, // 8 bits
mutated: bool, // not packed
awaiting_item_specials: bool, // not packed
}

#[dojo::interface]
Expand Down
4 changes: 3 additions & 1 deletion src/models/status/round/adventurer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use core::num::traits::{Sqrt};
use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait};

use jokers_of_neon::interfaces::erc721::{IERC721SystemDispatcher, IERC721SystemDispatcherTrait};
use jokers_of_neon::interfaces::loot_survivor::{ILootSurvivorSystemDispatcher, ILootSurvivorSystemDispatcherTrait};
use jokers_of_neon::interfaces::loot_survivor::{
ILootSurvivorSystemDispatcher, ILootSurvivorSystemDispatcherTrait, Adventurer
};
use jokers_of_neon::models::data::adventurer::{AdventurerConsumed, AdventurerConsumedStore};
use jokers_of_neon::utils::adventurer::get_adventurer_address;
use starknet::{ContractAddress, get_caller_address, get_tx_info};
Expand Down

0 comments on commit 22004c5

Please sign in to comment.