diff --git a/src/components/market.cairo b/src/components/market.cairo index 23411d046..5c7497101 100644 --- a/src/components/market.cairo +++ b/src/components/market.cairo @@ -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, } } } } @@ -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 diff --git a/src/constants.cairo b/src/constants.cairo index 2bae1e16b..f37546380 100644 --- a/src/constants.cairo +++ b/src/constants.cairo @@ -1,14 +1,13 @@ const SCALING_FACTOR: u128 = 10_000; -const TRAVEL_RISK: u8 = 50; // 50% chance of travel encounter +const TRAVEL_RISK: u8 = 75; // 75% chance of travel encounter const CAPTURE_RISK: u8 = 50; // 50% chance of capture const ENCOUNTER_BIAS_GANGS: u128 = 60; const COPS_DRUG_THRESHOLD: usize = 5; // cops encounter threshold const HEALTH_IMPACT: u8 = 10; -const COPS_PAYMENT: usize = 20; -const GANGS_PAYMENT: usize = 10; +const GANGS_PAYMENT: usize = 20; // starting stats const STARTING_CASH: u128 = 2000_0000; // $2000 diff --git a/src/systems/create.cairo b/src/systems/create.cairo index c04e9f535..f8a8028bd 100644 --- a/src/systems/create.cairo +++ b/src/systems/create.cairo @@ -143,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) diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 2e9b91cbb..fb925bb38 100644 --- a/src/systems/decide.cairo +++ b/src/systems/decide.cairo @@ -8,7 +8,7 @@ mod decide { use dojo::world::Context; use rollyourown::PlayerStatus; - use rollyourown::constants::{GANGS_PAYMENT, COPS_PAYMENT, HEALTH_IMPACT, COPS_DRUG_THRESHOLD}; + use rollyourown::constants::{GANGS_PAYMENT, HEALTH_IMPACT, COPS_DRUG_THRESHOLD}; use rollyourown::components::game::{Game, GameTrait}; use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; @@ -63,7 +63,9 @@ mod decide { let mut risks = get!(ctx.world, (game_id, player.location_id).into(), Risks); let seed = starknet::get_tx_info().unbox().transaction_hash; match risks.run(seed) { - bool::False => (Outcome::Captured, 0, 0, HEALTH_IMPACT), + bool::False => ( + Outcome::Captured, 0, 0, HEALTH_IMPACT * (1 + player.run_attempts) + ), bool::True => (Outcome::Escaped, 0, 0, 0) } }, @@ -107,8 +109,9 @@ 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 + } ); } diff --git a/src/systems/set_name.cairo b/src/systems/set_name.cairo index 2dbc455b1..1bf91d1b6 100644 --- a/src/systems/set_name.cairo +++ b/src/systems/set_name.cairo @@ -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, })) } } diff --git a/src/systems/travel.cairo b/src/systems/travel.cairo index aa1d432a1..c3cc93174 100644 --- a/src/systems/travel.cairo +++ b/src/systems/travel.cairo @@ -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 } ); diff --git a/web/src/pages/[gameId]/event/decision.tsx b/web/src/pages/[gameId]/event/decision.tsx index f429bb017..28bf11624 100644 --- a/web/src/pages/[gameId]/event/decision.tsx +++ b/web/src/pages/[gameId]/event/decision.tsx @@ -13,8 +13,9 @@ import Layout from "@/components/Layout"; import { Footer } from "@/components/Footer"; import Button from "@/components/Button"; import { formatCash } from "@/utils/ui"; +import { useToast } from "@/hooks/toast"; +import { Heart } from "@/components/icons"; -const BASE_PAYMENT = 500; const COPS_DRUG_THRESHOLD = 5; export default function Decision() { @@ -28,6 +29,7 @@ export default function Decision() { const [demand, setDemand] = useState(); const [penalty, setPenalty] = useState(); + const { toast } = useToast(); const { account } = useDojo(); const { decide } = useSystems(); const { addEncounter } = usePlayerStore(); @@ -43,7 +45,7 @@ export default function Decision() { case PlayerStatus.BeingMugged: setPrefixTitle("You encountered a..."); setTitle("Gang!"); - setDemand(`They want 10% of your DRUGS and $PAPER!`); + setDemand(`They want 20% of your DRUGS and $PAPER!`); break; case PlayerStatus.BeingArrested: const payment = formatCash(copsPayment(playerEntity.drugCount)); @@ -81,9 +83,19 @@ export default function Decision() { setPrefixTitle("Your escape..."); setTitle("Failed!"); setPenalty(`You loss ${event.healthLoss}HP!`); + toast( + `You were captured and loss ${event.healthLoss}HP!`, + Heart, + `http://amazing_explorer/${result.hash}`, + ); break; case Outcome.Died: + toast( + `You too ${event.healthLoss}HP damage and died...`, + Heart, + `http://amazing_explorer/${result.hash}`, + ); return router.push(`/${gameId}/end`); case Outcome.Escaped: