Skip to content

Commit

Permalink
📝 Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Nov 13, 2024
1 parent 7bc838f commit 92ae132
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 58 deletions.
65 changes: 7 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,13 @@
<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>
# Overview

<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>
The Cartridge Arcade is a plateform for building and distributing games on Starknet.

[![discord](https://img.shields.io/badge/join-dojo-green?logo=discord&logoColor=white)](https://discord.gg/PwDa2mKhR4)
[![Telegram Chat][tg-badge]][tg-url]
## Key Features

[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
#### Achievements

# Dojo Starter: Official Guide
Players can earn achievements by progressing in games.

The official Dojo Starter guide, the quickest and most streamlined way to get your Dojo provable game up and running. This guide will assist you with the initial setup, from cloning the repository to deploying your world.
#### Profile (coming soon)

Read the full tutorial [here](https://book.dojoengine.org/tutorial/dojo-starter).

## Running Locally

#### Terminal one (Make sure this is running)

```bash
# Run Katana
katana --disable-fee --allowed-origins "*"
```

#### Terminal two

```bash
# Build the example
sozo build

# Migrate the example
sozo migrate apply

# Start Torii
torii --world 0x5d475a9221f6cbf1a016b12400a01b9a89935069aecd57e9876fcb2a7bb29da --allowed-origins "*"
```

---

## 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.

Happy coding!
Players can view their profile accross all registered games and track their progress.
Empty file added packages/registry/README.md
Empty file.
35 changes: 35 additions & 0 deletions packages/trophy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Achievements

The Cartridge Achievements is a system for games to reward players for completing achievements.

## Key Features

- **Packages**: Games can define achievements thanks to the provided packages.
- **Rewards**: Games can reward players with Cartridge points for completing achievements.
- **Profile**: Players can view their achievements and scores whitout leaving the game.

## Benefits for Game Developers

- **Simplicity**: Easy integration with existing Starknet smart contracts and Dojo.
- **Cost-effectiveness**: Achievements are events based, no additional storage is required.
- **Performance** (coming soon): Plugin attached to Torii to improve the performances of the achievements computation.

## How It Works?

### Creation

The game world describes the achievements and the corresponding tasks to unlock them.
Each achievement is defined by (not exhaustive) a unique `identifier`, a `title`, a `description` and a set of `tasks`.
Each task is defined by an `identifier`, a `total` and a `description`.
The completion of a task is done when enough progression has been made by a player regarding a specific task.
The achievement is completed when all included tasks are completed.

### Progression

The progression of each individual task is done by the game by emitting events associated to a `task` and a `player`.
Each progression provides a `counter` to add to the player progression.
A task completion is the sum of all the progression events emitted for a specific `task` (defined by the `identifier`).

### Integration

The status of the achievement is computed off-chain by the controller, it starts when the controller is initialized on the client.
32 changes: 32 additions & 0 deletions packages/trophy/src/components/achievable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ mod AchievableComponent {
impl InternalImpl<
TContractState, +HasComponent<TContractState>
> of InternalTrait<TContractState> {
/// Create an achievement
///
/// # Arguments
///
/// * `self`: The component state.
/// * `world`: The world storage.
/// * `id`: The achievement identifier, it should be unique.
/// * `hidden`: Speicify if you want the achievement to be hidden in the controller UI.
/// * `index`: The achievement index which is the page in which the achievement will be
/// displayed within the group.
/// * `points`: The achievement points to reward the player.
/// * `start`: The achievement start timestamp, it should be used for ephemeral
/// achievements, `0` for everlasting achievements.
/// * `end`: The achievement end timestamp, it should be used for ephemeral achievements,
/// `0` for everlasting achievements.
/// * `group`: The achievement group, it should be used to group achievements together (see
/// also `index` to define multiple pages).
/// * `icon`: The achievement icon, it should be a
/// [FontAwesome](https://fontawesome.com/icons) icon name (e.g. `fa-trophy`).
/// * `title`: The achievement title.
/// * `description`: The achievement global description.
/// * `tasks`: The achievement tasks (see also `Task` type).
/// * `data`: The achievement data, not used yet but could have a future use.
fn create(
self: @ComponentState<TContractState>,
world: WorldStorage,
Expand Down Expand Up @@ -73,6 +96,15 @@ mod AchievableComponent {
);
}

/// Progress on an achievement
///
/// # Arguments
///
/// * `self`: The component state.
/// * `world`: The world storage.
/// * `player_id`: The player identifier.
/// * `task_id`: The task identifier.
/// * `count`: The progression count to add.
fn progress(
self: @ComponentState<TContractState>,
world: WorldStorage,
Expand Down

0 comments on commit 92ae132

Please sign in to comment.