Skip to content

Commit

Permalink
update example to 100 moves and 0,0 starting
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Nov 8, 2023
1 parent 9e24752 commit 4dfa7bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: CI

on:
push:
pull_request:
push:
pull_request:

jobs:
sozo-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: curl -L https://install.dojoengine.org | bash
- run: /home/runner/.config/.dojo/bin/dojoup -v v0.3.2
- run: |
/home/runner/.config/.dojo/bin/sozo build
/home/runner/.config/.dojo/bin/sozo test
sozo-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: curl -L https://install.dojoengine.org | bash
- run: /home/runner/.config/.dojo/bin/dojoup -v v0.3.2
- run: |
/home/runner/.config/.dojo/bin/sozo build
/home/runner/.config/.dojo/bin/sozo test
18 changes: 7 additions & 11 deletions src/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ mod actions {
let moves = get!(world, player, (Moves));

// Update the world state with the new data.
// 1. Increase the player's remaining moves by 10.
// 2. Move the player's position 10 units in both the x and y direction.
// 1. Set players moves to 10
// 2. Move the player's position 100 units in both the x and y direction.
set!(
world,
(
Moves {
player, remaining: moves.remaining + 10, last_direction: Direction::None(())
},
Position {
player, vec: Vec2 { x: position.vec.x + 10, y: position.vec.y + 10 }
},
Moves { player, remaining: 100, last_direction: Direction::None(()) },
Position { player, vec: Vec2 { x: 0, y: 0 } },
)
);
}
Expand Down Expand Up @@ -138,7 +134,7 @@ mod tests {
let right_dir_felt: felt252 = Direction::Right(()).into();

// check moves
assert(moves.remaining == 9, 'moves is wrong');
assert(moves.remaining == 99, 'moves is wrong');

// check last direction
assert(moves.last_direction.into() == right_dir_felt, 'last direction is wrong');
Expand All @@ -147,9 +143,9 @@ mod tests {
let new_position = get!(world, caller, Position);

// check new position x
assert(new_position.vec.x == 11, 'position x is wrong');
assert(new_position.vec.x == 1, 'position x is wrong');

// check new position y
assert(new_position.vec.y == 10, 'position y is wrong');
assert(new_position.vec.y == 0, 'position y is wrong');
}
}

0 comments on commit 4dfa7bd

Please sign in to comment.