-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2ddeca
commit 159d76d
Showing
9 changed files
with
64 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"cairo1.languageServerPath": "$HOME/.dojo/bin/dojo-language-server", | ||
// "cairo1.languageServerPath": "~/.dojo/bin/dojo-language-server", | ||
"cairo1.enableLanguageServer": true, | ||
"cairo1.enableScarb": false | ||
"cairo1.enableScarb": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,20 @@ | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset=".github/mark-dark.svg"> | ||
<img alt="Dojo logo" align="right" width="120" src=".github/mark-light.svg"> | ||
</picture> | ||
## Realms World Adventurers | ||
|
||
<a href="https://twitter.com/dojostarknet"> | ||
<img src="https://img.shields.io/twitter/follow/dojostarknet?style=social"/> | ||
</a> | ||
<a href="https://github.com/dojoengine/dojo"> | ||
<img src="https://img.shields.io/github/stars/dojoengine/dojo?style=social"/> | ||
</a> | ||
> WIP: This is heavy work in progress | ||
[![discord](https://img.shields.io/badge/join-dojo-green?logo=discord&logoColor=white)](https://discord.gg/PwDa2mKhR4) | ||
[![Telegram Chat][tg-badge]][tg-url] | ||
Milestone: Deploy into Realms Testnet. | ||
|
||
[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fdojoengine | ||
[tg-url]: https://t.me/dojoengine | ||
## Table of Contents | ||
|
||
# Dojo Starter: Official Guide | ||
### Adventurers | ||
|
||
The official Dojo Starter guide, the quickest and most streamlined way to get your Dojo Autonomous World up and running. This guide will assist you with the initial setup, from cloning the repository to deploying your world. | ||
Adventurers are the base layer Character in the world. They are the simplest possible Character with the idea they will be extended by other modules via new components. | ||
|
||
Read the full tutorial [here](https://book.dojoengine.org/cairo/hello-dojo.html) | ||
### Adventurers DNA | ||
|
||
--- | ||
Adventurers have a minimum of these: | ||
|
||
## Contribution | ||
|
||
This starter project is a constant work in progress and contributions are greatly appreciated! | ||
|
||
1. **Report a Bug** | ||
|
||
- If you think you have encountered a bug, and we should know about it, feel free to report it [here](https://github.com/dojoengine/dojo-starter/issues) and we will take care of it. | ||
|
||
2. **Request a Feature** | ||
|
||
- You can also request for a feature [here](https://github.com/dojoengine/dojo-starter/issues), and if it's viable, it will be picked for development. | ||
|
||
3. **Create a Pull Request** | ||
- It can't get better then this, your pull request will be appreciated by the community. | ||
|
||
For any other questions, feel free to reach out to us [here](https://dojoengine.org/contact). | ||
|
||
Happy coding! | ||
- Health: The is the base health of the Adventurer. This is the amount of damage they can take before they die. | ||
- Energy: This is the base energy of the Adventurer. This is the amount of energy they have to perform actions. | ||
- AdventurerId: This is a unique human readable identifier for the Adventurer. | ||
- Position: This is the position of the Adventurer in the world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
cairo-version = "2.2.0" | ||
name = "dojo_examples" | ||
name = "realms_adventurers" | ||
version = "0.3.5" | ||
|
||
[cairo] | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
mod actions; | ||
mod models; | ||
mod utils; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1 @@ | ||
use starknet::ContractAddress; | ||
|
||
#[derive(Serde, Copy, Drop, Introspect)] | ||
enum Direction { | ||
None: (), | ||
Left: (), | ||
Right: (), | ||
Up: (), | ||
Down: (), | ||
} | ||
|
||
impl DirectionIntoFelt252 of Into<Direction, felt252> { | ||
fn into(self: Direction) -> felt252 { | ||
match self { | ||
Direction::None(()) => 0, | ||
Direction::Left(()) => 1, | ||
Direction::Right(()) => 2, | ||
Direction::Up(()) => 3, | ||
Direction::Down(()) => 4, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Model, Drop, Serde)] | ||
struct Moves { | ||
#[key] | ||
player: ContractAddress, | ||
remaining: u8, | ||
last_direction: Direction | ||
} | ||
|
||
#[derive(Copy, Drop, Serde, Introspect)] | ||
struct Vec2 { | ||
x: u32, | ||
y: u32 | ||
} | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Position { | ||
#[key] | ||
player: ContractAddress, | ||
vec: Vec2, | ||
} | ||
|
||
trait Vec2Trait { | ||
fn is_zero(self: Vec2) -> bool; | ||
fn is_equal(self: Vec2, b: Vec2) -> bool; | ||
} | ||
|
||
impl Vec2Impl of Vec2Trait { | ||
fn is_zero(self: Vec2) -> bool { | ||
if self.x - self.y == 0 { | ||
return true; | ||
} | ||
false | ||
} | ||
|
||
fn is_equal(self: Vec2, b: Vec2) -> bool { | ||
self.x == b.x && self.y == b.y | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::{Position, Vec2, Vec2Trait}; | ||
|
||
#[test] | ||
#[available_gas(100000)] | ||
fn test_vec_is_zero() { | ||
assert(Vec2Trait::is_zero(Vec2 { x: 0, y: 0 }), 'not zero'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(100000)] | ||
fn test_vec_is_equal() { | ||
let position = Vec2 { x: 420, y: 0 }; | ||
assert(position.is_equal(Vec2 { x: 420, y: 0 }), 'not equal'); | ||
} | ||
} | ||
mod dna; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// the minimum DNA of an Adventurer | ||
|
||
#[derive(Copy, Drop, Serde, Introspect)] | ||
struct Vec2 { | ||
x: u32, | ||
y: u32 | ||
} | ||
|
||
// Health is a component that can be attached to an entity | ||
#[derive(Model, Copy, Drop, Serde, SerdeLen)] | ||
struct Health { | ||
#[key] | ||
entity_id: u64, | ||
health: u32, | ||
} | ||
|
||
// This can be inherited from the World, but leaving here for testing | ||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Position { | ||
#[key] | ||
entity_id: u64, | ||
vec: Vec2, | ||
} | ||
|
||
// ID is a unique identifier for an entity | ||
#[derive(Model, Copy, Drop, Serde)] | ||
struct AdventurerId { | ||
#[key] | ||
entity_id: u64, | ||
id: u64, | ||
} | ||
|
||
// ID is a unique identifier for an entity | ||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Energy { | ||
#[key] | ||
entity_id: u64, | ||
value: u64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[starknet::interface] | ||
trait IDNA<TContractState> { | ||
fn spawn(self: @TContractState, location: u64); | ||
fn move(self: @TContractState, adventurer_id: u64); | ||
fn get_adventurer(self: @TContractState, adventurer_id: u64) -> u64; | ||
} | ||
|
||
#[dojo::contract] | ||
mod spawn {} |
This file was deleted.
Oops, something went wrong.