Skip to content

Commit

Permalink
serialized output
Browse files Browse the repository at this point in the history
  • Loading branch information
chudkowsky committed Aug 22, 2024
1 parent 3100017 commit 6cf9b49
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dojo_bin/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ enum TransactionType {
Move: (ContractAddress, models::Direction)
}

fn main() -> WorldState {
fn main(input:Array<felt252>) -> Array<felt252> {
//todo: implement deserialize input for player, world and array of transactions
let player = contract_address_const::<0>();
let mut world = WorldState { positions: Default::default(), moves: Default::default(), };

let txns = array![
TransactionType::Spawn(player),
TransactionType::Move((player, models::Direction::Up)),
Expand All @@ -31,5 +31,11 @@ fn main() -> WorldState {
)) => { ActionsImpl::move(ref world, player, direction) },
}
};
world
}
let mut output: Array<felt252> = ArrayTrait::new();
player.serialize(ref output);
let position = world.positions.get(player.into()).deref();
position.serialize(ref output);
let moves = world.moves.get(player.into()).deref();
moves.serialize(ref output);
output}
//[0, 0, 10, 10, 0, 98, 3, 1]

0 comments on commit 6cf9b49

Please sign in to comment.