Skip to content

Commit

Permalink
Made the cairo contracts to compile and test works
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandoDrRobot committed Sep 5, 2024
1 parent 234ccd5 commit 0bcdb62
Show file tree
Hide file tree
Showing 12 changed files with 1,442 additions and 63 deletions.
459 changes: 459 additions & 0 deletions manifests/dev/base/abis/models/bytebeasts-Game-e91217d7.json

Large diffs are not rendered by default.

407 changes: 407 additions & 0 deletions manifests/dev/base/abis/models/bytebeasts-GameId-344511d3.json

Large diffs are not rendered by default.

439 changes: 439 additions & 0 deletions manifests/dev/base/abis/models/bytebeasts-GamePlayer-596ef4a1.json

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions manifests/dev/base/models/bytebeasts-Game-e91217d7.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
kind = "DojoModel"
class_hash = "0x57c477846284e274054c78c5b265af51f8815abbf0147828080c274b0639764"
original_class_hash = "0x57c477846284e274054c78c5b265af51f8815abbf0147828080c274b0639764"
abi = "manifests/dev/base/abis/models/bytebeasts-Game-e91217d7.json"
tag = "bytebeasts-Game"
manifest_name = "bytebeasts-Game-e91217d7"

[[members]]
name = "game_id"
type = "u128"
key = true

[[members]]
name = "player_1"
type = "ContractAddress"
key = false

[[members]]
name = "player_2"
type = "ContractAddress"
key = false

[[members]]
name = "player_3"
type = "ContractAddress"
key = false

[[members]]
name = "player_4"
type = "ContractAddress"
key = false

[[members]]
name = "status"
type = "GameStatus"
key = false

[[members]]
name = "is_private"
type = "bool"
key = false
16 changes: 16 additions & 0 deletions manifests/dev/base/models/bytebeasts-GameId-344511d3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind = "DojoModel"
class_hash = "0x7dc1689aa3f1e6b123cadfed4066a70f09be69c9a166bfe824c61b916925efe"
original_class_hash = "0x7dc1689aa3f1e6b123cadfed4066a70f09be69c9a166bfe824c61b916925efe"
abi = "manifests/dev/base/abis/models/bytebeasts-GameId-344511d3.json"
tag = "bytebeasts-GameId"
manifest_name = "bytebeasts-GameId-344511d3"

[[members]]
name = "id"
type = "u32"
key = true

[[members]]
name = "game_id"
type = "u128"
key = false
56 changes: 56 additions & 0 deletions manifests/dev/base/models/bytebeasts-GamePlayer-596ef4a1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
kind = "DojoModel"
class_hash = "0x52df62dec799bbf7ba4725f74e32e579dec2d90a7a995638761646157bb7e18"
original_class_hash = "0x52df62dec799bbf7ba4725f74e32e579dec2d90a7a995638761646157bb7e18"
abi = "manifests/dev/base/abis/models/bytebeasts-GamePlayer-596ef4a1.json"
tag = "bytebeasts-GamePlayer"
manifest_name = "bytebeasts-GamePlayer-596ef4a1"

[[members]]
name = "address"
type = "ContractAddress"
key = true

[[members]]
name = "game_id"
type = "u128"
key = true

[[members]]
name = "beast_1"
type = "u8"
key = false

[[members]]
name = "beast_2"
type = "u8"
key = false

[[members]]
name = "beast_3"
type = "u8"
key = false

[[members]]
name = "beast_4"
type = "u8"
key = false

[[members]]
name = "bag_id"
type = "u8"
key = false

[[members]]
name = "active_mount"
type = "u8"
key = false

[[members]]
name = "mounts"
type = "Array<u8>"
key = false

[[members]]
name = "position"
type = "Array<u8>"
key = false
10 changes: 7 additions & 3 deletions src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
mod systems {
mod actions;
mod battle;
// mod realms;
}

mod models {
mod battle;
mod beast;
mod coordinates;
mod game_id;
mod game_player;
mod game;
mod mission_status;
mod mt;
mod npc;
mod player;
mod position;
mod potion;
mod world_elements;
mod mission_status;
mod npc;
mod role;
mod world_elements;
}
55 changes: 2 additions & 53 deletions src/models.cairo → src/models/game.cairo
Original file line number Diff line number Diff line change
@@ -1,56 +1,5 @@
use starknet::{ContractAddress, SyscallResultTrait};

// New Models

// Game Player
#[derive(Drop, Serde, Debug)]
#[dojo::model]
pub struct GamePlayer {
#[key]
pub address: ContractAddress,
#[key]
pub game_id: u128,
pub beast_1: u8,
pub beast_2: u8,
pub beast_3: u8,
pub beast_4: u8,
pub bag_id: u8,
pub active_mount: u8,
pub mounts: Array<u8>,
pub position: Array<u8>
}

pub trait GamePlayerTrait {
fn new(game_id: u128, address: ContractAddress) -> GamePlayer;
}

impl GamePlayerImpl of GamePlayerTrait {
// logic to create an instance of a game player
fn new(game_id: u128, address: ContractAddress) -> GamePlayer {
let game_player = GamePlayer {
address: address,
game_id: game_id,
beast_1: 0_u8,
beast_2: 0_u8,
beast_3: 0_u8,
beast_4: 0_u8,
bag_id: 0_u8,
active_mount: 0_u8,
mounts: ArrayTrait::new(),
position: ArrayTrait::new(),
};
game_player
}
}

// Realm (Game)
#[derive(Copy, Drop, Serde)]
#[dojo::model]
pub struct GameId {
#[key]
pub id: u32,
pub game_id: u128
}
use starknet::ContractAddress;
use super::game_player::GamePlayer;

#[derive(Serde, Copy, Drop, Introspect, PartialEq)]
pub enum GameStatus {
Expand Down
7 changes: 7 additions & 0 deletions src/models/game_id.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Copy, Drop, Serde)]
#[dojo::model]
pub struct GameId {
#[key]
pub id: u32,
pub game_id: u128
}
3 changes: 1 addition & 2 deletions src/models/GamePlayer.cairo → src/models/game_player.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use starknet::ContractAddress;
use dojo::model::Model;

#[derive(Drop, Serde, Debug)]
#[dojo::model]
Expand All @@ -11,7 +10,7 @@ pub struct GamePlayer {
pub beast_1: u8,
pub beast_2: u8,
pub beast_3: u8,
pub beast_3: u8,
pub beast_4: u8,
pub bag_id: u8,
pub active_mount: u8,
pub mounts: Array<u8>,
Expand Down
4 changes: 3 additions & 1 deletion src/models/npc.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use bytebeasts::{models::{role::Role, coordinates::Coordinates, mission_status::MissionStatus},};
use super::role::Role;
use super::coordinates::Coordinates;
use super::mission_status::MissionStatus;

#[derive(Drop, Serde)]
#[dojo::model]
Expand Down
8 changes: 4 additions & 4 deletions src/systems/realms.cairo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use starknet::ContractAddress;
use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait};

use bytebeasts::models::GameId
use bytebeasts::models::GameStatus
use bytebeasts::models::Game
use bytebeasts::models::GamePlayer
use bytebeasts::models::GameId;
use bytebeasts::models::GameStatus;
use bytebeasts::models::Game;
use bytebeasts::models::GamePlayer;

#[dojo::interface]
trait IActions {
Expand Down

0 comments on commit 0bcdb62

Please sign in to comment.