From cc51ff3893a9d80074ae82c702ba3db89c9bad90 Mon Sep 17 00:00:00 2001 From: broody Date: Mon, 18 Sep 2023 14:22:25 -0700 Subject: [PATCH] more balance --- src/components/risks.cairo | 8 +++-- src/constants.cairo | 8 +++-- src/systems/decide.cairo | 14 ++++----- web/src/pages/[gameId]/event/decision.tsx | 36 ++++------------------- 4 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/components/risks.cairo b/src/components/risks.cairo index 671bf38f9..adcab25dd 100644 --- a/src/components/risks.cairo +++ b/src/components/risks.cairo @@ -2,7 +2,7 @@ use traits::{Into, TryInto}; use option::OptionTrait; use debug::PrintTrait; -use rollyourown::constants::{SCALING_FACTOR, COPS_DRUG_THRESHOLD, ENCOUNTER_BIAS_GANGS}; +use rollyourown::constants::{SCALING_FACTOR, COPS_DRUG_THRESHOLD, GANGS_CASH_THRESHOLD, ENCOUNTER_BIAS_GANGS}; use rollyourown::PlayerStatus; #[derive(Component, Copy, Drop, Serde)] @@ -28,12 +28,16 @@ impl RisksImpl of RisksTrait { return match result <= ENCOUNTER_BIAS_GANGS { bool::False => { if drug_count < COPS_DRUG_THRESHOLD { - return PlayerStatus::BeingMugged; + return PlayerStatus::Normal; } PlayerStatus::BeingArrested }, bool::True => { + if cash <= GANGS_CASH_THRESHOLD { + return PlayerStatus::Normal; + } + PlayerStatus::BeingMugged } }; diff --git a/src/constants.cairo b/src/constants.cairo index 85aebc7df..03a57f68c 100644 --- a/src/constants.cairo +++ b/src/constants.cairo @@ -3,11 +3,13 @@ const SCALING_FACTOR: u128 = 10_000; const TRAVEL_RISK: u8 = 60; // 60% chance of travel encounter const CAPTURE_RISK: u8 = 60; // 60% chance of capture -const ENCOUNTER_BIAS_GANGS: u128 = 75; // 75% chance of gangs encounter vs cops -const COPS_DRUG_THRESHOLD: usize = 5; // cops encounter threshold +const ENCOUNTER_BIAS_GANGS: u128 = 50; // 50% chance of gangs encounter vs cops +const COPS_DRUG_THRESHOLD: usize = 2; // cops encounter threshold +const GANGS_CASH_THRESHOLD: u128 = 1000_0000; // gangs encounter threshold const HEALTH_IMPACT: u8 = 10; -const GANGS_PAYMENT: usize = 20; +const GANGS_PAYMENT: usize = 20; // 20% of cash +const COPS_PAYMENT: usize = 20; // 20% of drugs // starting stats const STARTING_CASH: u128 = 2000_0000; // $2000 diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 4365c5b1d..88468fef0 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, HEALTH_IMPACT, COPS_DRUG_THRESHOLD}; + use rollyourown::constants::{GANGS_PAYMENT, COPS_PAYMENT, HEALTH_IMPACT, COPS_DRUG_THRESHOLD}; use rollyourown::components::game::{Game, GameTrait}; use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; @@ -64,23 +64,19 @@ mod decide { let seed = starknet::get_tx_info().unbox().transaction_hash; match risks.run(seed) { bool::False => (Outcome::Escaped, 0, 0, 0), - bool::True => ( - Outcome::Captured, 0, 0, HEALTH_IMPACT * (1 + player.run_attempts) - ) + bool::True => (Outcome::Captured, 0, 0, HEALTH_IMPACT) } }, Action::Pay => { match player.status { PlayerStatus::Normal => (Outcome::Unsupported, 0, 0, 0), PlayerStatus::BeingMugged => { - let drug_loss = take_drugs(ctx, game_id, player_id, GANGS_PAYMENT); let cash_loss = (player.cash * GANGS_PAYMENT.into()) / 100; - (Outcome::Paid, cash_loss, drug_loss, 0) + (Outcome::Paid, cash_loss, 0, 0) }, PlayerStatus::BeingArrested => { - let cash_loss = cops_payment(player.drug_count); - assert(cash_loss <= player.cash, 'not enough cash to pay cops'); - (Outcome::Paid, cash_loss, 0, 0) + let drug_loss = take_drugs(ctx, game_id, player_id, COPS_PAYMENT); + (Outcome::Paid, 0, drug_loss, 0) } } }, diff --git a/web/src/pages/[gameId]/event/decision.tsx b/web/src/pages/[gameId]/event/decision.tsx index 28753ce3d..b3fad45fe 100644 --- a/web/src/pages/[gameId]/event/decision.tsx +++ b/web/src/pages/[gameId]/event/decision.tsx @@ -8,11 +8,10 @@ import { usePlayerStore } from "@/hooks/state"; import { ConsequenceEventData } from "@/dojo/events"; import { Heading, Text, VStack } from "@chakra-ui/react"; import { useRouter } from "next/router"; -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; 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"; import { playSound, Sounds } from "@/hooks/sound"; @@ -46,15 +45,12 @@ export default function Decision() { case PlayerStatus.BeingMugged: setPrefixTitle("You encountered a..."); setTitle("Gang!"); - setDemand(`They want 20% of your DRUGS and $PAPER!`); + setDemand(`They want 20% of your $PAPER!`); break; case PlayerStatus.BeingArrested: - const payment = formatCash(copsPayment(playerEntity.drugCount)); setPrefixTitle("You encountered the..."); setTitle("Cops!"); - setDemand( - `You're carrying DRUGS! These dirty cops are demanding ${payment} PAPER!`, - ); + setDemand(`The want 20% of your DRUGS!`); break; } @@ -62,13 +58,6 @@ export default function Decision() { } }, [playerEntity, isSubmitting]); - const canPay = useMemo(() => { - if (playerEntity && playerEntity.status == PlayerStatus.BeingArrested) { - return playerEntity.cash >= copsPayment(playerEntity.drugCount); - } - return true; - }, [playerEntity]); - useEffect(() => { if (status == PlayerStatus.BeingArrested) { playSound(Sounds.Police); @@ -137,7 +126,6 @@ export default function Decision() { prefixTitle={prefixTitle} title={title} demand={demand} - canPay={canPay} imageSrc={`/images/events/${ status == PlayerStatus.BeingMugged ? "muggers.gif" : "cops.gif" }`} @@ -151,25 +139,12 @@ export default function Decision() { ); } -const copsPayment = (drugCount: number) => { - if (drugCount < COPS_DRUG_THRESHOLD + 20) { - return 1000; - } else if (drugCount < COPS_DRUG_THRESHOLD + 50) { - return 5000; - } else if (drugCount < COPS_DRUG_THRESHOLD + 80) { - return 10000; - } else { - return 20000; - } -}; - const Encounter = ({ prefixTitle, title, demand, imageSrc, penalty, - canPay, isSubmitting, onPay, onRun, @@ -179,7 +154,6 @@ const Encounter = ({ demand?: string; imageSrc: string; penalty?: string; - canPay: boolean; isSubmitting?: boolean; onPay: () => void; onRun: () => void; @@ -242,14 +216,14 @@ const Encounter = ({