Skip to content

Commit

Permalink
cairo format
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Sep 18, 2023
1 parent 770bbbb commit f6034ff
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/components/market.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl MarketImpl of MarketTrait {
}
} else {
panic(array!['invalid drug_id']);
PricingInfos { min_price: 0, max_price: 0, min_qty: 0, max_qty: 0, }
PricingInfos { min_price: 0, max_price: 0, min_qty: 0, max_qty: 0, }
}
}
}
Expand All @@ -102,7 +102,7 @@ fn normalize(amount: usize, market: Market) -> (u128, u128, u128) {


#[test]
#[should_panic(expected: ('not enough liquidity',))]
#[should_panic(expected: ('not enough liquidity', ))]
fn test_not_enough_quantity() {
let mut market = Market {
game_id: 0, location_id: 0, drug_id: 0, cash: SCALING_FACTOR * 1, quantity: 1
Expand Down
8 changes: 4 additions & 4 deletions src/systems/create.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ mod create_game {
use rollyourown::components::location::{Location, LocationTrait};
use rollyourown::components::market::{MarketTrait};
use rollyourown::constants::{
TRAVEL_RISK, CAPTURE_RISK, STARTING_CASH, STARTING_HEALTH,
STARTING_BAG_LIMIT
TRAVEL_RISK, CAPTURE_RISK, STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT
};
use rollyourown::utils::random;
use debug::PrintTrait;
Expand Down Expand Up @@ -144,8 +143,9 @@ mod create_game {

// emit game created
emit!(
ctx.world,
GameCreated { game_id, creator: ctx.origin, start_time, max_players, max_turns }
ctx.world, GameCreated {
game_id, creator: ctx.origin, start_time, max_players, max_turns
}
);

(game_id, ctx.origin)
Expand Down
12 changes: 6 additions & 6 deletions src/systems/decide.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod decide {
use dojo::world::Context;

use rollyourown::PlayerStatus;
use rollyourown::constants::{ COPS_DRUG_THRESHOLD,HEALTH_IMPACT,GANGS_PAYMENT};
use rollyourown::constants::{COPS_DRUG_THRESHOLD, HEALTH_IMPACT, GANGS_PAYMENT};
use rollyourown::components::game::{Game, GameTrait};
use rollyourown::components::risks::{Risks, RisksTrait};
use rollyourown::components::player::{Player, PlayerTrait};
Expand Down Expand Up @@ -53,7 +53,7 @@ mod decide {
cash_loss: u128
}

fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) {
fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) {
let player_id = ctx.origin;
let mut player = get!(ctx.world, (game_id, player_id).into(), Player);
assert(player.status != PlayerStatus::Normal, 'player response not needed');
Expand Down Expand Up @@ -110,14 +110,14 @@ mod decide {

emit!(ctx.world, Decision { game_id, player_id, action });
emit!(
ctx.world,
Consequence { game_id, player_id, outcome, health_loss, drug_loss, cash_loss }
ctx.world, Consequence {
game_id, player_id, outcome, health_loss, drug_loss, cash_loss
}
);
}



fn cops_payment(drug_count: u32) -> u128 {
fn cops_payment(drug_count: u32) -> u128 {
if drug_count < COPS_DRUG_THRESHOLD + 20 {
1000_0000 // $1000
} else if drug_count < COPS_DRUG_THRESHOLD + 50 {
Expand Down
4 changes: 1 addition & 3 deletions src/systems/join.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ mod join_game {
use rollyourown::components::game::Game;
use rollyourown::components::player::Player;
use rollyourown::components::location::{Location, LocationTrait};
use rollyourown::constants::{
STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT
};
use rollyourown::constants::{STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT};

#[event]
#[derive(Drop, starknet::Event)]
Expand Down
2 changes: 1 addition & 1 deletion src/systems/set_name.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ mod set_name {
use rollyourown::components::name::Name;

fn execute(ctx: Context, game_id: u32, player_name: felt252) {
set!(ctx.world, (Name { game_id, player_id: ctx.origin, short_string: player_name, }))
set!(ctx.world, (Name { game_id, player_id: ctx.origin, short_string: player_name, }))
}
}
3 changes: 1 addition & 2 deletions src/systems/travel.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ mod travel {
set!(ctx.world, (player));

emit!(
ctx.world,
Traveled {
ctx.world, Traveled {
game_id, player_id, from_location: player.location_id, to_location: next_location_id
}
);
Expand Down

0 comments on commit f6034ff

Please sign in to comment.