diff --git a/README.md b/README.md index f9b530449..38d6e3d50 100644 --- a/README.md +++ b/README.md @@ -62,13 +62,13 @@ flowchart TD C --> |Buys / Sells drugs on local markets|D[Select next location to travel to] D --> |Player travels without incident|END[Turn ends] D --> F[Player is Mugged] - F --> F1[Fight] + F --> F1[Pay] F --> F2[Run] F2 --> F12[Win] --> END F2 --> L[Lose] L --> |Player loses their stash|END D --> G[Chased by Cops] - G --> F1[Fight] + G --> F1[Pay] G --> F2[Run] F1 --> F12 F1 --> L diff --git a/Scarb.toml b/Scarb.toml index af8bfcaf1..cbb275236 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -15,8 +15,8 @@ dojo = { git = "https://github.com/dojoengine/dojo.git" } # Katana -rpc_url = "https://api.cartridge.gg/x/rollyourown/katana" -#rpc_url = "http://localhost:5050" +#rpc_url = "https://api.cartridge.gg/x/rollyourown/katana" +rpc_url = "http://localhost:5050" account_address = "0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973" private_key = "0x1800000000300000180000000000030000000000003006001800006600" diff --git a/src/components/market.cairo b/src/components/market.cairo index 8f3626955..314ccd411 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/components/risks.cairo b/src/components/risks.cairo index ece46b5de..4ed416c2a 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; +use rollyourown::constants::{SCALING_FACTOR, COPS_DRUG_THRESHOLD, ENCOUNTER_BIAS_GANGS}; use rollyourown::PlayerStatus; #[derive(Component, Copy, Drop, Serde)] @@ -25,15 +25,17 @@ impl RisksImpl of RisksTrait { let result: u128 = entropy.low % 100; // more bias towards gang encounter - return match result <= 30 { - bool::False => PlayerStatus::BeingMugged, - bool::True => { - // don't trigger if no drugs - if drug_count == 0 { + return match result <= ENCOUNTER_BIAS_GANGS { + bool::False => { + if drug_count < COPS_DRUG_THRESHOLD { return PlayerStatus::Normal; } + PlayerStatus::BeingArrested }, + bool::True => { + PlayerStatus::BeingMugged + } }; } diff --git a/src/constants.cairo b/src/constants.cairo index 1bd049525..20dbc5629 100644 --- a/src/constants.cairo +++ b/src/constants.cairo @@ -3,9 +3,12 @@ const SCALING_FACTOR: u128 = 10_000; const TRAVEL_RISK: u8 = 30; // 30% chance of travel encounter const CAPTURE_RISK: u8 = 50; // 50% chance of capture -const HEALTH_IMPACT: u8 = 10; +const ENCOUNTER_BIAS_GANGS: u128 = 60; +const COPS_DRUG_THRESHOLD: usize = 5; // cops encounter threshold -const BASE_PAYMENT: u128 = 500_0000; // base payment is $500 +const HEALTH_IMPACT: u8 = 10; +const COPS_PAYMENT: usize = 20; +const GANGS_PAYMENT: usize = 10; // starting stats const STARTING_CASH: u128 = 2000_0000; // $2000 diff --git a/src/systems/create.cairo b/src/systems/create.cairo index 80ec4b6c4..c04e9f535 100644 --- a/src/systems/create.cairo +++ b/src/systems/create.cairo @@ -19,7 +19,8 @@ mod create_game { use rollyourown::components::location::{Location, LocationTrait}; use rollyourown::components::market::{MarketTrait}; use rollyourown::constants::{ - SCALING_FACTOR, TRAVEL_RISK, CAPTURE_RISK, STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT + SCALING_FACTOR, TRAVEL_RISK, CAPTURE_RISK, STARTING_CASH, STARTING_HEALTH, + STARTING_BAG_LIMIT }; use rollyourown::utils::random; use debug::PrintTrait; @@ -86,7 +87,10 @@ mod create_game { set!( ctx.world, (Risks { - game_id, location_id: *location_id, travel: TRAVEL_RISK, capture: CAPTURE_RISK + game_id, + location_id: *location_id, + travel: TRAVEL_RISK, + capture: CAPTURE_RISK }) ); @@ -139,9 +143,8 @@ 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 46eb20c71..3c222acd7 100644 --- a/src/systems/decide.cairo +++ b/src/systems/decide.cairo @@ -8,7 +8,9 @@ mod decide { use dojo::world::Context; use rollyourown::PlayerStatus; - use rollyourown::constants::{BASE_PAYMENT, HEALTH_IMPACT}; + 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}; @@ -18,14 +20,12 @@ mod decide { enum Action { Run: (), Pay: (), - Fight: (), } #[derive(Copy, Drop, Serde, PartialEq)] enum Outcome { Died: (), Paid: (), - Fought: (), Escaped: (), Captured: (), Unsupported: (), @@ -36,15 +36,13 @@ mod decide { enum Event { Decision: Decision, Consequence: Consequence, - Losses: Losses } #[derive(Drop, starknet::Event)] struct Decision { game_id: u32, player_id: ContractAddress, - action: Action, - run_attempts: u8, + action: Action } #[derive(Drop, starknet::Event)] @@ -52,12 +50,6 @@ mod decide { game_id: u32, player_id: ContractAddress, outcome: Outcome, - } - - #[derive(Drop, starknet::Event)] - struct Losses { - game_id: u32, - player_id: ContractAddress, health_loss: u8, drug_loss: usize, cash_loss: u128 @@ -68,41 +60,32 @@ mod decide { let mut player = get!(ctx.world, (game_id, player_id).into(), Player); assert(player.status != PlayerStatus::Normal, 'player response not needed'); - let (mut outcome, cash_loss, drug_loss, health_loss) = match player.status { - PlayerStatus::Normal => (Outcome::Unsupported, 0, 0, 0), - PlayerStatus::BeingMugged => match action { - Action::Run => run( - ctx, - game_id, - player_id, - player.status, - player.cash, - player.location_id, - player.run_attempts - ), - Action::Pay => (Outcome::Unsupported, 0, 0, 0), // can't pay muggers - Action::Fight => fight(ctx, game_id, player_id), + let (mut outcome, cash_loss, drug_loss, health_loss) = match action { + Action::Run => { + 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::True => (Outcome::Escaped, 0, 0, 0) + } }, - PlayerStatus::BeingArrested => match action { - Action::Run => run( - ctx, - game_id, - player_id, - player.status, - player.cash, - player.location_id, - player.run_attempts - ), - Action::Pay => pay(ctx, game_id, player_id, player.cash), - Action::Fight => (Outcome::Unsupported, 0, 0, 0), // can't fight officers + 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) + }, + 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) + } + } }, }; - // you can only bribe cops and fight muggers, not the other way around - assert(outcome != Outcome::Unsupported, 'unsupported action'); - - // if captured, stay in captured state and faces the same decision again, can choose to run - // again but consequences increase each tinme (-health, +risk) if outcome == Outcome::Captured { player.run_attempts += 1; } else { @@ -112,88 +95,40 @@ mod decide { player.run_attempts = 0; } + player.cash -= cash_loss; + player.drug_count -= drug_loss; if health_loss >= player.health { player.health = 0; player.turns_remaining = 0; outcome = Outcome::Died; } else { - player.health -= health_loss; + player.health -= health_loss } - player.cash -= cash_loss; - player.drug_count -= drug_loss; - set!(ctx.world, (player)); - emit!(ctx.world, Consequence { game_id, player_id, outcome }); - if health_loss > 0 || cash_loss > 0 || drug_loss > 0 { - emit!(ctx.world, Losses { game_id, player_id, health_loss, drug_loss, cash_loss}); - } - } - - // Player will fight muggers, but it kinda hurts, taking 20hp of your health. You - // might also die if not enough health - fn fight(ctx: Context, game_id: u32, player_id: ContractAddress) -> (Outcome, u128, u32, u8) { - emit!(ctx.world, Decision { game_id, player_id, action: Action::Fight, run_attempts: 0 }); - (Outcome::Fought, 0, 0, 20) + emit!(ctx.world, Decision { game_id, player_id, action }); + emit!( + ctx.world, + Consequence { game_id, player_id, outcome, health_loss, drug_loss, cash_loss } + ); } - // Player will hand over either 20% of their cash or $400, which ever is more - fn pay( - ctx: Context, game_id: u32, player_id: ContractAddress, player_cash: u128 - ) -> (Outcome, u128, u32, u8) { - assert(player_cash >= BASE_PAYMENT, 'not enough cash kid'); - let cash_loss = cmp::max(player_cash / 5, BASE_PAYMENT); - - emit!(ctx.world, Decision { game_id, player_id, action: Action::Pay, run_attempts: 0 }); - (Outcome::Paid, cash_loss, 0, 0) - } - - // Player will try to run and can escape without consequence. However, if you - // are caught be ready to face the consequences: - // - caught escaping an officer - 10hp and 20% of your drugs - // - caught escaping muggers - 10hp and 20% of your cash - // - // In this captured state, players can choose to continue to run, the stash percentage - // you lose increments by +10% each time. (ie 20%, 30%, 40%, etc) and health continues - // to decrease by 10hp - fn run( - ctx: Context, - game_id: u32, - player_id: ContractAddress, - player_status: PlayerStatus, - player_cash: u128, - location_id: felt252, - run_attempts: u8, - ) -> (Outcome, u128, u32, u8) { - let mut risks = get!(ctx.world, (game_id, location_id).into(), Risks); - let seed = starknet::get_tx_info().unbox().transaction_hash; - let got_away = risks.run(seed); - - emit!(ctx.world, Decision { game_id, player_id, action: Action::Run, run_attempts }); - match got_away { - bool::False => match player_status { - PlayerStatus::Normal => { - (Outcome::Unsupported, 0, 0, 0) - }, - PlayerStatus::BeingMugged => { - let additional_penalty: u128 = run_attempts.into() * 10; - let cash_loss = (player_cash * (20 + additional_penalty)) / 100; - - (Outcome::Captured, cash_loss, 0, HEALTH_IMPACT) - }, - PlayerStatus::BeingArrested => { - let drug_count_loss = take_drugs(ctx, game_id, player_id, run_attempts); - (Outcome::Captured, 0, drug_count_loss, HEALTH_IMPACT) - } - }, - bool::True => { - (Outcome::Escaped, 0, 0, 0) - } + 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 { + 5000_0000 // $5000 + } else if drug_count < COPS_DRUG_THRESHOLD + 80 { + 10000_0000 // $10000 + } else { + 20000_0000 // $20000 } } - fn take_drugs(ctx: Context, game_id: u32, player_id: ContractAddress, run_attempts: u8) -> usize { + fn take_drugs( + ctx: Context, game_id: u32, player_id: ContractAddress, percentage: usize + ) -> usize { let mut drugs = DrugTrait::all(); let mut total_drug_loss = 0; loop { @@ -201,10 +136,14 @@ mod decide { Option::Some(drug_id) => { let mut drug = get!(ctx.world, (game_id, player_id, *drug_id), Drug); if (drug.quantity != 0) { - let additional_penalty: u32 = run_attempts.into() * 10; - let drug_loss = (drug.quantity * (20 + additional_penalty)) / 100; + let mut drug_loss = (drug.quantity * percentage) / 100; + drug_loss = if drug_loss == 0 { + 1 + } else { + drug_loss + }; drug.quantity -= drug_loss; - total_drug_loss += drug.quantity; + total_drug_loss += drug_loss; set!(ctx.world, (drug)); } diff --git a/src/systems/set_name.cairo b/src/systems/set_name.cairo index 1bf91d1b6..2dbc455b1 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 4961db86e..5f0db09b2 100644 --- a/src/systems/travel.cairo +++ b/src/systems/travel.cairo @@ -69,7 +69,8 @@ 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/dojo/events.ts b/web/src/dojo/events.ts index e07f27b55..52a7dc62e 100644 --- a/web/src/dojo/events.ts +++ b/web/src/dojo/events.ts @@ -60,6 +60,9 @@ export interface DecisionEventData extends BaseEventData { export interface ConsequenceEventData extends BaseEventData { playerId: string; outcome: Outcome; + healthLoss: number; + drugLoss: number; + cashLoss: number; } export const parseEvent = ( @@ -110,6 +113,9 @@ export const parseEvent = ( gameId: num.toHexString(raw.data[0]), playerId: num.toHexString(raw.data[1]), outcome: Number(raw.data[2]), + healthLoss: Number(raw.data[3]), + drugLoss: Number(raw.data[4]), + cashLoss: Number(raw.data[5]), } as ConsequenceEventData; case RyoEvents.Traveled: case RyoEvents.Bought: diff --git a/web/src/dojo/helpers.ts b/web/src/dojo/helpers.ts index ed232f24e..633bf36f5 100644 --- a/web/src/dojo/helpers.ts +++ b/web/src/dojo/helpers.ts @@ -119,7 +119,7 @@ const drugs: DrugInfo[] = [ export const outcomes: OutcomeInfo[] = [ { - name: "Bribed the Cop", + name: "Paid the Cop", type: Outcome.Paid, status: PlayerStatus.BeingArrested, imageSrc: "/images/sunset.png", @@ -129,17 +129,7 @@ export const outcomes: OutcomeInfo[] = [ color: "yellow.400", }, { - name: "Got Arrested", - type: Outcome.Captured, - status: PlayerStatus.BeingArrested, - imageSrc: "/images/events/police_cruiser.gif", - description: "You lost some health and drugs", - getResponse: (isInitial: boolean) => - getCopResponses(Outcome.Captured, isInitial), - color: "red", - }, - { - name: "Escaped the Cops", + name: "Escaped", type: Outcome.Escaped, status: PlayerStatus.BeingArrested, imageSrc: "/images/events/escaped.png", @@ -148,27 +138,17 @@ export const outcomes: OutcomeInfo[] = [ color: "neon.200", }, { - name: "Fought the Gang", - type: Outcome.Fought, - status: PlayerStatus.BeingMugged, - imageSrc: "/images/events/fought.png", - description: "You lost some health", - getResponse: (isInitial: boolean) => - getMuggerResponses(Outcome.Fought, isInitial), - color: "yellow.400", - }, - { - name: "Got Captured", - type: Outcome.Captured, + name: "Paid the Gang", + type: Outcome.Paid, status: PlayerStatus.BeingMugged, imageSrc: "/images/sunset.png", - description: "You some some health and cash", + description: "You paid the gang off", getResponse: (isInitial: boolean) => - getMuggerResponses(Outcome.Captured, isInitial), - color: "red", + getMuggerResponses(Outcome.Escaped, isInitial), + color: "neon.200", }, { - name: "Escaped the Gang", + name: "Escaped", type: Outcome.Escaped, status: PlayerStatus.BeingMugged, imageSrc: "/images/events/escaped.png", @@ -176,6 +156,37 @@ export const outcomes: OutcomeInfo[] = [ getMuggerResponses(Outcome.Escaped, isInitial), color: "neon.200", }, + + // { + // name: "Got Arrested", + // type: Outcome.Captured, + // status: PlayerStatus.BeingArrested, + // imageSrc: "/images/events/police_cruiser.gif", + // description: "You lost some health and drugs", + // getResponse: (isInitial: boolean) => + // getCopResponses(Outcome.Captured, isInitial), + // color: "red", + // }, + // { + // name: "Fought the Gang", + // type: Outcome.Fought, + // status: PlayerStatus.BeingMugged, + // imageSrc: "/images/events/fought.png", + // description: "You lost 20HP", + // getResponse: (isInitial: boolean) => + // getMuggerResponses(Outcome.Fought, isInitial), + // color: "yellow.400", + // }, + // { + // name: "Got Captured", + // type: Outcome.Captured, + // status: PlayerStatus.BeingMugged, + // imageSrc: "/images/sunset.png", + // description: "You some some health and cash", + // getResponse: (isInitial: boolean) => + // getMuggerResponses(Outcome.Captured, isInitial), + // color: "red", + // }, ]; function findBy(array: T[], key: keyof T, value: any): T | undefined { diff --git a/web/src/dojo/types.ts b/web/src/dojo/types.ts index 322d93a16..f018fd8fe 100644 --- a/web/src/dojo/types.ts +++ b/web/src/dojo/types.ts @@ -25,13 +25,11 @@ export enum PlayerStatus { export enum Action { Run, Pay, - Fight, } export enum Outcome { Died, Paid, - Fought, Escaped, Captured, } diff --git a/web/src/generated/graphql.ts b/web/src/generated/graphql.ts index 96ddc65c9..bba99ced3 100644 --- a/web/src/generated/graphql.ts +++ b/web/src/generated/graphql.ts @@ -1,10 +1,22 @@ -import { useQuery, useInfiniteQuery, UseQueryOptions, UseInfiniteQueryOptions, QueryFunctionContext } from 'react-query'; -import { useFetchData } from '@/hooks/fetcher'; +import { + useQuery, + useInfiniteQuery, + UseQueryOptions, + UseInfiniteQueryOptions, + QueryFunctionContext, +} from "react-query"; +import { useFetchData } from "@/hooks/fetcher"; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; +export type Exact = { + [K in keyof T]: T[K]; +}; +export type MakeOptional = Omit & { + [SubKey in K]?: Maybe; +}; +export type MakeMaybe = Omit & { + [SubKey in K]: Maybe; +}; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { ID: string; @@ -26,51 +38,51 @@ export type Scalars = { }; export type Component = { - __typename?: 'Component'; - classHash?: Maybe; - createdAt?: Maybe; - id?: Maybe; - name?: Maybe; - transactionHash?: Maybe; + __typename?: "Component"; + classHash?: Maybe; + createdAt?: Maybe; + id?: Maybe; + name?: Maybe; + transactionHash?: Maybe; }; export type ComponentConnection = { - __typename?: 'ComponentConnection'; + __typename?: "ComponentConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type ComponentEdge = { - __typename?: 'ComponentEdge'; - cursor: Scalars['Cursor']; + __typename?: "ComponentEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; export type ComponentUnion = Drug | Game | Market | Name | Player | Risks; export enum Direction { - Asc = 'ASC', - Desc = 'DESC' + Asc = "ASC", + Desc = "DESC", } export type Drug = { - __typename?: 'Drug'; - drug_id?: Maybe; + __typename?: "Drug"; + drug_id?: Maybe; entity?: Maybe; - game_id?: Maybe; - player_id?: Maybe; - quantity?: Maybe; + game_id?: Maybe; + player_id?: Maybe; + quantity?: Maybe; }; export type DrugConnection = { - __typename?: 'DrugConnection'; + __typename?: "DrugConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type DrugEdge = { - __typename?: 'DrugEdge'; - cursor: Scalars['Cursor']; + __typename?: "DrugEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; @@ -80,104 +92,104 @@ export type DrugOrder = { }; export enum DrugOrderOrderField { - DrugId = 'DRUG_ID', - GameId = 'GAME_ID', - PlayerId = 'PLAYER_ID', - Quantity = 'QUANTITY' + DrugId = "DRUG_ID", + GameId = "GAME_ID", + PlayerId = "PLAYER_ID", + Quantity = "QUANTITY", } export type DrugWhereInput = { - drug_id?: InputMaybe; - drug_idGT?: InputMaybe; - drug_idGTE?: InputMaybe; - drug_idLT?: InputMaybe; - drug_idLTE?: InputMaybe; - drug_idNEQ?: InputMaybe; - game_id?: InputMaybe; - game_idGT?: InputMaybe; - game_idGTE?: InputMaybe; - game_idLT?: InputMaybe; - game_idLTE?: InputMaybe; - game_idNEQ?: InputMaybe; - player_id?: InputMaybe; - player_idGT?: InputMaybe; - player_idGTE?: InputMaybe; - player_idLT?: InputMaybe; - player_idLTE?: InputMaybe; - player_idNEQ?: InputMaybe; - quantity?: InputMaybe; - quantityGT?: InputMaybe; - quantityGTE?: InputMaybe; - quantityLT?: InputMaybe; - quantityLTE?: InputMaybe; - quantityNEQ?: InputMaybe; + drug_id?: InputMaybe; + drug_idGT?: InputMaybe; + drug_idGTE?: InputMaybe; + drug_idLT?: InputMaybe; + drug_idLTE?: InputMaybe; + drug_idNEQ?: InputMaybe; + game_id?: InputMaybe; + game_idGT?: InputMaybe; + game_idGTE?: InputMaybe; + game_idLT?: InputMaybe; + game_idLTE?: InputMaybe; + game_idNEQ?: InputMaybe; + player_id?: InputMaybe; + player_idGT?: InputMaybe; + player_idGTE?: InputMaybe; + player_idLT?: InputMaybe; + player_idLTE?: InputMaybe; + player_idNEQ?: InputMaybe; + quantity?: InputMaybe; + quantityGT?: InputMaybe; + quantityGTE?: InputMaybe; + quantityLT?: InputMaybe; + quantityLTE?: InputMaybe; + quantityNEQ?: InputMaybe; }; export type Entity = { - __typename?: 'Entity'; - componentNames?: Maybe; + __typename?: "Entity"; + componentNames?: Maybe; components?: Maybe>>; - createdAt?: Maybe; - id?: Maybe; - keys?: Maybe>>; - updatedAt?: Maybe; + createdAt?: Maybe; + id?: Maybe; + keys?: Maybe>>; + updatedAt?: Maybe; }; export type EntityConnection = { - __typename?: 'EntityConnection'; + __typename?: "EntityConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type EntityEdge = { - __typename?: 'EntityEdge'; - cursor: Scalars['Cursor']; + __typename?: "EntityEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; export type Event = { - __typename?: 'Event'; - createdAt?: Maybe; - data?: Maybe; - id?: Maybe; - keys?: Maybe; + __typename?: "Event"; + createdAt?: Maybe; + data?: Maybe; + id?: Maybe; + keys?: Maybe; systemCall: SystemCall; - systemCallId?: Maybe; + systemCallId?: Maybe; }; export type EventConnection = { - __typename?: 'EventConnection'; + __typename?: "EventConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type EventEdge = { - __typename?: 'EventEdge'; - cursor: Scalars['Cursor']; + __typename?: "EventEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; export type Game = { - __typename?: 'Game'; - creator?: Maybe; + __typename?: "Game"; + creator?: Maybe; entity?: Maybe; - game_id?: Maybe; - is_finished?: Maybe; - max_players?: Maybe; - max_turns?: Maybe; - num_players?: Maybe; - start_time?: Maybe; + game_id?: Maybe; + is_finished?: Maybe; + max_players?: Maybe; + max_turns?: Maybe; + num_players?: Maybe; + start_time?: Maybe; }; export type GameConnection = { - __typename?: 'GameConnection'; + __typename?: "GameConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type GameEdge = { - __typename?: 'GameEdge'; - cursor: Scalars['Cursor']; + __typename?: "GameEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; @@ -187,79 +199,79 @@ export type GameOrder = { }; export enum GameOrderOrderField { - Creator = 'CREATOR', - GameId = 'GAME_ID', - IsFinished = 'IS_FINISHED', - MaxPlayers = 'MAX_PLAYERS', - MaxTurns = 'MAX_TURNS', - NumPlayers = 'NUM_PLAYERS', - StartTime = 'START_TIME' + Creator = "CREATOR", + GameId = "GAME_ID", + IsFinished = "IS_FINISHED", + MaxPlayers = "MAX_PLAYERS", + MaxTurns = "MAX_TURNS", + NumPlayers = "NUM_PLAYERS", + StartTime = "START_TIME", } export type GameWhereInput = { - creator?: InputMaybe; - creatorGT?: InputMaybe; - creatorGTE?: InputMaybe; - creatorLT?: InputMaybe; - creatorLTE?: InputMaybe; - creatorNEQ?: InputMaybe; - game_id?: InputMaybe; - game_idGT?: InputMaybe; - game_idGTE?: InputMaybe; - game_idLT?: InputMaybe; - game_idLTE?: InputMaybe; - game_idNEQ?: InputMaybe; - is_finished?: InputMaybe; - is_finishedGT?: InputMaybe; - is_finishedGTE?: InputMaybe; - is_finishedLT?: InputMaybe; - is_finishedLTE?: InputMaybe; - is_finishedNEQ?: InputMaybe; - max_players?: InputMaybe; - max_playersGT?: InputMaybe; - max_playersGTE?: InputMaybe; - max_playersLT?: InputMaybe; - max_playersLTE?: InputMaybe; - max_playersNEQ?: InputMaybe; - max_turns?: InputMaybe; - max_turnsGT?: InputMaybe; - max_turnsGTE?: InputMaybe; - max_turnsLT?: InputMaybe; - max_turnsLTE?: InputMaybe; - max_turnsNEQ?: InputMaybe; - num_players?: InputMaybe; - num_playersGT?: InputMaybe; - num_playersGTE?: InputMaybe; - num_playersLT?: InputMaybe; - num_playersLTE?: InputMaybe; - num_playersNEQ?: InputMaybe; - start_time?: InputMaybe; - start_timeGT?: InputMaybe; - start_timeGTE?: InputMaybe; - start_timeLT?: InputMaybe; - start_timeLTE?: InputMaybe; - start_timeNEQ?: InputMaybe; + creator?: InputMaybe; + creatorGT?: InputMaybe; + creatorGTE?: InputMaybe; + creatorLT?: InputMaybe; + creatorLTE?: InputMaybe; + creatorNEQ?: InputMaybe; + game_id?: InputMaybe; + game_idGT?: InputMaybe; + game_idGTE?: InputMaybe; + game_idLT?: InputMaybe; + game_idLTE?: InputMaybe; + game_idNEQ?: InputMaybe; + is_finished?: InputMaybe; + is_finishedGT?: InputMaybe; + is_finishedGTE?: InputMaybe; + is_finishedLT?: InputMaybe; + is_finishedLTE?: InputMaybe; + is_finishedNEQ?: InputMaybe; + max_players?: InputMaybe; + max_playersGT?: InputMaybe; + max_playersGTE?: InputMaybe; + max_playersLT?: InputMaybe; + max_playersLTE?: InputMaybe; + max_playersNEQ?: InputMaybe; + max_turns?: InputMaybe; + max_turnsGT?: InputMaybe; + max_turnsGTE?: InputMaybe; + max_turnsLT?: InputMaybe; + max_turnsLTE?: InputMaybe; + max_turnsNEQ?: InputMaybe; + num_players?: InputMaybe; + num_playersGT?: InputMaybe; + num_playersGTE?: InputMaybe; + num_playersLT?: InputMaybe; + num_playersLTE?: InputMaybe; + num_playersNEQ?: InputMaybe; + start_time?: InputMaybe; + start_timeGT?: InputMaybe; + start_timeGTE?: InputMaybe; + start_timeLT?: InputMaybe; + start_timeLTE?: InputMaybe; + start_timeNEQ?: InputMaybe; }; export type Market = { - __typename?: 'Market'; - cash?: Maybe; - drug_id?: Maybe; + __typename?: "Market"; + cash?: Maybe; + drug_id?: Maybe; entity?: Maybe; - game_id?: Maybe; - location_id?: Maybe; - quantity?: Maybe; + game_id?: Maybe; + location_id?: Maybe; + quantity?: Maybe; }; export type MarketConnection = { - __typename?: 'MarketConnection'; + __typename?: "MarketConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type MarketEdge = { - __typename?: 'MarketEdge'; - cursor: Scalars['Cursor']; + __typename?: "MarketEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; @@ -269,63 +281,63 @@ export type MarketOrder = { }; export enum MarketOrderOrderField { - Cash = 'CASH', - DrugId = 'DRUG_ID', - GameId = 'GAME_ID', - LocationId = 'LOCATION_ID', - Quantity = 'QUANTITY' + Cash = "CASH", + DrugId = "DRUG_ID", + GameId = "GAME_ID", + LocationId = "LOCATION_ID", + Quantity = "QUANTITY", } export type MarketWhereInput = { - cash?: InputMaybe; - cashGT?: InputMaybe; - cashGTE?: InputMaybe; - cashLT?: InputMaybe; - cashLTE?: InputMaybe; - cashNEQ?: InputMaybe; - drug_id?: InputMaybe; - drug_idGT?: InputMaybe; - drug_idGTE?: InputMaybe; - drug_idLT?: InputMaybe; - drug_idLTE?: InputMaybe; - drug_idNEQ?: InputMaybe; - game_id?: InputMaybe; - game_idGT?: InputMaybe; - game_idGTE?: InputMaybe; - game_idLT?: InputMaybe; - game_idLTE?: InputMaybe; - game_idNEQ?: InputMaybe; - location_id?: InputMaybe; - location_idGT?: InputMaybe; - location_idGTE?: InputMaybe; - location_idLT?: InputMaybe; - location_idLTE?: InputMaybe; - location_idNEQ?: InputMaybe; - quantity?: InputMaybe; - quantityGT?: InputMaybe; - quantityGTE?: InputMaybe; - quantityLT?: InputMaybe; - quantityLTE?: InputMaybe; - quantityNEQ?: InputMaybe; + cash?: InputMaybe; + cashGT?: InputMaybe; + cashGTE?: InputMaybe; + cashLT?: InputMaybe; + cashLTE?: InputMaybe; + cashNEQ?: InputMaybe; + drug_id?: InputMaybe; + drug_idGT?: InputMaybe; + drug_idGTE?: InputMaybe; + drug_idLT?: InputMaybe; + drug_idLTE?: InputMaybe; + drug_idNEQ?: InputMaybe; + game_id?: InputMaybe; + game_idGT?: InputMaybe; + game_idGTE?: InputMaybe; + game_idLT?: InputMaybe; + game_idLTE?: InputMaybe; + game_idNEQ?: InputMaybe; + location_id?: InputMaybe; + location_idGT?: InputMaybe; + location_idGTE?: InputMaybe; + location_idLT?: InputMaybe; + location_idLTE?: InputMaybe; + location_idNEQ?: InputMaybe; + quantity?: InputMaybe; + quantityGT?: InputMaybe; + quantityGTE?: InputMaybe; + quantityLT?: InputMaybe; + quantityLTE?: InputMaybe; + quantityNEQ?: InputMaybe; }; export type Name = { - __typename?: 'Name'; + __typename?: "Name"; entity?: Maybe; - game_id?: Maybe; - player_id?: Maybe; - short_string?: Maybe; + game_id?: Maybe; + player_id?: Maybe; + short_string?: Maybe; }; export type NameConnection = { - __typename?: 'NameConnection'; + __typename?: "NameConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type NameEdge = { - __typename?: 'NameEdge'; - cursor: Scalars['Cursor']; + __typename?: "NameEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; @@ -335,56 +347,56 @@ export type NameOrder = { }; export enum NameOrderOrderField { - GameId = 'GAME_ID', - PlayerId = 'PLAYER_ID', - ShortString = 'SHORT_STRING' + GameId = "GAME_ID", + PlayerId = "PLAYER_ID", + ShortString = "SHORT_STRING", } export type NameWhereInput = { - game_id?: InputMaybe; - game_idGT?: InputMaybe; - game_idGTE?: InputMaybe; - game_idLT?: InputMaybe; - game_idLTE?: InputMaybe; - game_idNEQ?: InputMaybe; - player_id?: InputMaybe; - player_idGT?: InputMaybe; - player_idGTE?: InputMaybe; - player_idLT?: InputMaybe; - player_idLTE?: InputMaybe; - player_idNEQ?: InputMaybe; - short_string?: InputMaybe; - short_stringGT?: InputMaybe; - short_stringGTE?: InputMaybe; - short_stringLT?: InputMaybe; - short_stringLTE?: InputMaybe; - short_stringNEQ?: InputMaybe; + game_id?: InputMaybe; + game_idGT?: InputMaybe; + game_idGTE?: InputMaybe; + game_idLT?: InputMaybe; + game_idLTE?: InputMaybe; + game_idNEQ?: InputMaybe; + player_id?: InputMaybe; + player_idGT?: InputMaybe; + player_idGTE?: InputMaybe; + player_idLT?: InputMaybe; + player_idLTE?: InputMaybe; + player_idNEQ?: InputMaybe; + short_string?: InputMaybe; + short_stringGT?: InputMaybe; + short_stringGTE?: InputMaybe; + short_stringLT?: InputMaybe; + short_stringLTE?: InputMaybe; + short_stringNEQ?: InputMaybe; }; export type Player = { - __typename?: 'Player'; - bag_limit?: Maybe; - cash?: Maybe; - drug_count?: Maybe; + __typename?: "Player"; + bag_limit?: Maybe; + cash?: Maybe; + drug_count?: Maybe; entity?: Maybe; - game_id?: Maybe; - health?: Maybe; - location_id?: Maybe; - player_id?: Maybe; - run_attempts?: Maybe; - status?: Maybe; - turns_remaining?: Maybe; + game_id?: Maybe; + health?: Maybe; + location_id?: Maybe; + player_id?: Maybe; + run_attempts?: Maybe; + status?: Maybe; + turns_remaining?: Maybe; }; export type PlayerConnection = { - __typename?: 'PlayerConnection'; + __typename?: "PlayerConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type PlayerEdge = { - __typename?: 'PlayerEdge'; - cursor: Scalars['Cursor']; + __typename?: "PlayerEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; @@ -394,83 +406,83 @@ export type PlayerOrder = { }; export enum PlayerOrderOrderField { - BagLimit = 'BAG_LIMIT', - Cash = 'CASH', - DrugCount = 'DRUG_COUNT', - GameId = 'GAME_ID', - Health = 'HEALTH', - LocationId = 'LOCATION_ID', - PlayerId = 'PLAYER_ID', - RunAttempts = 'RUN_ATTEMPTS', - Status = 'STATUS', - TurnsRemaining = 'TURNS_REMAINING' + BagLimit = "BAG_LIMIT", + Cash = "CASH", + DrugCount = "DRUG_COUNT", + GameId = "GAME_ID", + Health = "HEALTH", + LocationId = "LOCATION_ID", + PlayerId = "PLAYER_ID", + RunAttempts = "RUN_ATTEMPTS", + Status = "STATUS", + TurnsRemaining = "TURNS_REMAINING", } export type PlayerWhereInput = { - bag_limit?: InputMaybe; - bag_limitGT?: InputMaybe; - bag_limitGTE?: InputMaybe; - bag_limitLT?: InputMaybe; - bag_limitLTE?: InputMaybe; - bag_limitNEQ?: InputMaybe; - cash?: InputMaybe; - cashGT?: InputMaybe; - cashGTE?: InputMaybe; - cashLT?: InputMaybe; - cashLTE?: InputMaybe; - cashNEQ?: InputMaybe; - drug_count?: InputMaybe; - drug_countGT?: InputMaybe; - drug_countGTE?: InputMaybe; - drug_countLT?: InputMaybe; - drug_countLTE?: InputMaybe; - drug_countNEQ?: InputMaybe; - game_id?: InputMaybe; - game_idGT?: InputMaybe; - game_idGTE?: InputMaybe; - game_idLT?: InputMaybe; - game_idLTE?: InputMaybe; - game_idNEQ?: InputMaybe; - health?: InputMaybe; - healthGT?: InputMaybe; - healthGTE?: InputMaybe; - healthLT?: InputMaybe; - healthLTE?: InputMaybe; - healthNEQ?: InputMaybe; - location_id?: InputMaybe; - location_idGT?: InputMaybe; - location_idGTE?: InputMaybe; - location_idLT?: InputMaybe; - location_idLTE?: InputMaybe; - location_idNEQ?: InputMaybe; - player_id?: InputMaybe; - player_idGT?: InputMaybe; - player_idGTE?: InputMaybe; - player_idLT?: InputMaybe; - player_idLTE?: InputMaybe; - player_idNEQ?: InputMaybe; - run_attempts?: InputMaybe; - run_attemptsGT?: InputMaybe; - run_attemptsGTE?: InputMaybe; - run_attemptsLT?: InputMaybe; - run_attemptsLTE?: InputMaybe; - run_attemptsNEQ?: InputMaybe; - status?: InputMaybe; - statusGT?: InputMaybe; - statusGTE?: InputMaybe; - statusLT?: InputMaybe; - statusLTE?: InputMaybe; - statusNEQ?: InputMaybe; - turns_remaining?: InputMaybe; - turns_remainingGT?: InputMaybe; - turns_remainingGTE?: InputMaybe; - turns_remainingLT?: InputMaybe; - turns_remainingLTE?: InputMaybe; - turns_remainingNEQ?: InputMaybe; + bag_limit?: InputMaybe; + bag_limitGT?: InputMaybe; + bag_limitGTE?: InputMaybe; + bag_limitLT?: InputMaybe; + bag_limitLTE?: InputMaybe; + bag_limitNEQ?: InputMaybe; + cash?: InputMaybe; + cashGT?: InputMaybe; + cashGTE?: InputMaybe; + cashLT?: InputMaybe; + cashLTE?: InputMaybe; + cashNEQ?: InputMaybe; + drug_count?: InputMaybe; + drug_countGT?: InputMaybe; + drug_countGTE?: InputMaybe; + drug_countLT?: InputMaybe; + drug_countLTE?: InputMaybe; + drug_countNEQ?: InputMaybe; + game_id?: InputMaybe; + game_idGT?: InputMaybe; + game_idGTE?: InputMaybe; + game_idLT?: InputMaybe; + game_idLTE?: InputMaybe; + game_idNEQ?: InputMaybe; + health?: InputMaybe; + healthGT?: InputMaybe; + healthGTE?: InputMaybe; + healthLT?: InputMaybe; + healthLTE?: InputMaybe; + healthNEQ?: InputMaybe; + location_id?: InputMaybe; + location_idGT?: InputMaybe; + location_idGTE?: InputMaybe; + location_idLT?: InputMaybe; + location_idLTE?: InputMaybe; + location_idNEQ?: InputMaybe; + player_id?: InputMaybe; + player_idGT?: InputMaybe; + player_idGTE?: InputMaybe; + player_idLT?: InputMaybe; + player_idLTE?: InputMaybe; + player_idNEQ?: InputMaybe; + run_attempts?: InputMaybe; + run_attemptsGT?: InputMaybe; + run_attemptsGTE?: InputMaybe; + run_attemptsLT?: InputMaybe; + run_attemptsLTE?: InputMaybe; + run_attemptsNEQ?: InputMaybe; + status?: InputMaybe; + statusGT?: InputMaybe; + statusGTE?: InputMaybe; + statusLT?: InputMaybe; + statusLTE?: InputMaybe; + statusNEQ?: InputMaybe; + turns_remaining?: InputMaybe; + turns_remainingGT?: InputMaybe; + turns_remainingGTE?: InputMaybe; + turns_remainingLT?: InputMaybe; + turns_remainingLTE?: InputMaybe; + turns_remainingNEQ?: InputMaybe; }; export type Query = { - __typename?: 'Query'; + __typename?: "Query"; component: Component; components?: Maybe; drugComponents?: Maybe; @@ -489,118 +501,106 @@ export type Query = { systems?: Maybe; }; - export type QueryComponentArgs = { - id: Scalars['ID']; + id: Scalars["ID"]; }; - export type QueryDrugComponentsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; order?: InputMaybe; where?: InputMaybe; }; - export type QueryEntitiesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - keys?: InputMaybe>>; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + keys?: InputMaybe>>; + last?: InputMaybe; }; - export type QueryEntityArgs = { - id: Scalars['ID']; + id: Scalars["ID"]; }; - export type QueryEventArgs = { - id: Scalars['ID']; + id: Scalars["ID"]; }; - export type QueryGameComponentsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; order?: InputMaybe; where?: InputMaybe; }; - export type QueryMarketComponentsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; order?: InputMaybe; where?: InputMaybe; }; - export type QueryNameComponentsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; order?: InputMaybe; where?: InputMaybe; }; - export type QueryPlayerComponentsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; order?: InputMaybe; where?: InputMaybe; }; - export type QueryRisksComponentsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; order?: InputMaybe; where?: InputMaybe; }; - export type QuerySystemArgs = { - id: Scalars['ID']; + id: Scalars["ID"]; }; - export type QuerySystemCallArgs = { - id: Scalars['Int']; + id: Scalars["Int"]; }; export type Risks = { - __typename?: 'Risks'; - capture?: Maybe; + __typename?: "Risks"; + capture?: Maybe; entity?: Maybe; - game_id?: Maybe; - location_id?: Maybe; - travel?: Maybe; + game_id?: Maybe; + location_id?: Maybe; + travel?: Maybe; }; export type RisksConnection = { - __typename?: 'RisksConnection'; + __typename?: "RisksConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type RisksEdge = { - __typename?: 'RisksEdge'; - cursor: Scalars['Cursor']; + __typename?: "RisksEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; @@ -610,124 +610,240 @@ export type RisksOrder = { }; export enum RisksOrderOrderField { - Capture = 'CAPTURE', - GameId = 'GAME_ID', - LocationId = 'LOCATION_ID', - Travel = 'TRAVEL' + Capture = "CAPTURE", + GameId = "GAME_ID", + LocationId = "LOCATION_ID", + Travel = "TRAVEL", } export type RisksWhereInput = { - capture?: InputMaybe; - captureGT?: InputMaybe; - captureGTE?: InputMaybe; - captureLT?: InputMaybe; - captureLTE?: InputMaybe; - captureNEQ?: InputMaybe; - game_id?: InputMaybe; - game_idGT?: InputMaybe; - game_idGTE?: InputMaybe; - game_idLT?: InputMaybe; - game_idLTE?: InputMaybe; - game_idNEQ?: InputMaybe; - location_id?: InputMaybe; - location_idGT?: InputMaybe; - location_idGTE?: InputMaybe; - location_idLT?: InputMaybe; - location_idLTE?: InputMaybe; - location_idNEQ?: InputMaybe; - travel?: InputMaybe; - travelGT?: InputMaybe; - travelGTE?: InputMaybe; - travelLT?: InputMaybe; - travelLTE?: InputMaybe; - travelNEQ?: InputMaybe; + capture?: InputMaybe; + captureGT?: InputMaybe; + captureGTE?: InputMaybe; + captureLT?: InputMaybe; + captureLTE?: InputMaybe; + captureNEQ?: InputMaybe; + game_id?: InputMaybe; + game_idGT?: InputMaybe; + game_idGTE?: InputMaybe; + game_idLT?: InputMaybe; + game_idLTE?: InputMaybe; + game_idNEQ?: InputMaybe; + location_id?: InputMaybe; + location_idGT?: InputMaybe; + location_idGTE?: InputMaybe; + location_idLT?: InputMaybe; + location_idLTE?: InputMaybe; + location_idNEQ?: InputMaybe; + travel?: InputMaybe; + travelGT?: InputMaybe; + travelGTE?: InputMaybe; + travelLT?: InputMaybe; + travelLTE?: InputMaybe; + travelNEQ?: InputMaybe; }; export type Subscription = { - __typename?: 'Subscription'; + __typename?: "Subscription"; componentRegistered: Component; entityUpdated: Entity; }; export type System = { - __typename?: 'System'; - classHash?: Maybe; - createdAt?: Maybe; - id?: Maybe; - name?: Maybe; + __typename?: "System"; + classHash?: Maybe; + createdAt?: Maybe; + id?: Maybe; + name?: Maybe; systemCalls: Array; - transactionHash?: Maybe; + transactionHash?: Maybe; }; export type SystemCall = { - __typename?: 'SystemCall'; - createdAt?: Maybe; - data?: Maybe; - id?: Maybe; + __typename?: "SystemCall"; + createdAt?: Maybe; + data?: Maybe; + id?: Maybe; system: System; - systemId?: Maybe; - transactionHash?: Maybe; + systemId?: Maybe; + transactionHash?: Maybe; }; export type SystemCallConnection = { - __typename?: 'SystemCallConnection'; + __typename?: "SystemCallConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type SystemCallEdge = { - __typename?: 'SystemCallEdge'; - cursor: Scalars['Cursor']; + __typename?: "SystemCallEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; export type SystemConnection = { - __typename?: 'SystemConnection'; + __typename?: "SystemConnection"; edges?: Maybe>>; - totalCount: Scalars['Int']; + totalCount: Scalars["Int"]; }; export type SystemEdge = { - __typename?: 'SystemEdge'; - cursor: Scalars['Cursor']; + __typename?: "SystemEdge"; + cursor: Scalars["Cursor"]; node?: Maybe; }; -export type AvailableGamesQueryVariables = Exact<{ [key: string]: never; }>; - - -export type AvailableGamesQuery = { __typename?: 'Query', gameComponents?: { __typename?: 'GameConnection', totalCount: number, edges?: Array<{ __typename?: 'GameEdge', cursor: any, node?: { __typename?: 'Game', creator?: any | null, num_players?: any | null, max_players?: any | null, max_turns?: any | null, start_time?: any | null } | null } | null> | null } | null }; +export type AvailableGamesQueryVariables = Exact<{ [key: string]: never }>; + +export type AvailableGamesQuery = { + __typename?: "Query"; + gameComponents?: { + __typename?: "GameConnection"; + totalCount: number; + edges?: Array<{ + __typename?: "GameEdge"; + cursor: any; + node?: { + __typename?: "Game"; + creator?: any | null; + num_players?: any | null; + max_players?: any | null; + max_turns?: any | null; + start_time?: any | null; + } | null; + } | null> | null; + } | null; +}; export type GlobalScoresQueryVariables = Exact<{ - limit?: InputMaybe; + limit?: InputMaybe; }>; - -export type GlobalScoresQuery = { __typename?: 'Query', playerComponents?: { __typename?: 'PlayerConnection', totalCount: number, edges?: Array<{ __typename?: 'PlayerEdge', cursor: any, node?: { __typename?: 'Player', cash?: any | null, entity?: { __typename?: 'Entity', keys?: Array | null, components?: Array<{ __typename: 'Drug' } | { __typename: 'Game' } | { __typename: 'Market' } | { __typename: 'Name', short_string?: any | null } | { __typename: 'Player' } | { __typename: 'Risks' } | null> | null } | null } | null } | null> | null } | null }; +export type GlobalScoresQuery = { + __typename?: "Query"; + playerComponents?: { + __typename?: "PlayerConnection"; + totalCount: number; + edges?: Array<{ + __typename?: "PlayerEdge"; + cursor: any; + node?: { + __typename?: "Player"; + cash?: any | null; + entity?: { + __typename?: "Entity"; + keys?: Array | null; + components?: Array< + | { __typename: "Drug" } + | { __typename: "Game" } + | { __typename: "Market" } + | { __typename: "Name"; short_string?: any | null } + | { __typename: "Player" } + | { __typename: "Risks" } + | null + > | null; + } | null; + } | null; + } | null> | null; + } | null; +}; export type GameEntityQueryVariables = Exact<{ - id: Scalars['ID']; + id: Scalars["ID"]; }>; - -export type GameEntityQuery = { __typename?: 'Query', entity: { __typename?: 'Entity', components?: Array<{ __typename: 'Drug' } | { __typename: 'Game', creator?: any | null, is_finished?: any | null, max_players?: any | null, max_turns?: any | null, num_players?: any | null, start_time?: any | null } | { __typename: 'Market' } | { __typename: 'Name' } | { __typename: 'Player' } | { __typename: 'Risks' } | null> | null } }; +export type GameEntityQuery = { + __typename?: "Query"; + entity: { + __typename?: "Entity"; + components?: Array< + | { __typename: "Drug" } + | { + __typename: "Game"; + creator?: any | null; + is_finished?: any | null; + max_players?: any | null; + max_turns?: any | null; + num_players?: any | null; + start_time?: any | null; + } + | { __typename: "Market" } + | { __typename: "Name" } + | { __typename: "Player" } + | { __typename: "Risks" } + | null + > | null; + }; +}; export type PlayerEntityQueryVariables = Exact<{ - gameId: Scalars['String']; - playerId: Scalars['String']; + gameId: Scalars["String"]; + playerId: Scalars["String"]; }>; - -export type PlayerEntityQuery = { __typename?: 'Query', entities?: { __typename?: 'EntityConnection', totalCount: number, edges?: Array<{ __typename?: 'EntityEdge', cursor: any, node?: { __typename?: 'Entity', keys?: Array | null, components?: Array<{ __typename: 'Drug', drug_id?: any | null, quantity?: any | null } | { __typename: 'Game' } | { __typename: 'Market' } | { __typename: 'Name' } | { __typename: 'Player', cash?: any | null, status?: any | null, health?: any | null, drug_count?: any | null, bag_limit?: any | null, location_id?: any | null, turns_remaining?: any | null } | { __typename: 'Risks' } | null> | null } | null } | null> | null } | null }; +export type PlayerEntityQuery = { + __typename?: "Query"; + entities?: { + __typename?: "EntityConnection"; + totalCount: number; + edges?: Array<{ + __typename?: "EntityEdge"; + cursor: any; + node?: { + __typename?: "Entity"; + keys?: Array | null; + components?: Array< + | { __typename: "Drug"; drug_id?: any | null; quantity?: any | null } + | { __typename: "Game" } + | { __typename: "Market" } + | { __typename: "Name" } + | { + __typename: "Player"; + cash?: any | null; + status?: any | null; + health?: any | null; + drug_count?: any | null; + bag_limit?: any | null; + location_id?: any | null; + turns_remaining?: any | null; + } + | { __typename: "Risks" } + | null + > | null; + } | null; + } | null> | null; + } | null; +}; export type LocationEntitiesQueryVariables = Exact<{ - gameId: Scalars['String']; - locationId: Scalars['String']; + gameId: Scalars["String"]; + locationId: Scalars["String"]; }>; - -export type LocationEntitiesQuery = { __typename?: 'Query', entities?: { __typename?: 'EntityConnection', totalCount: number, edges?: Array<{ __typename?: 'EntityEdge', cursor: any, node?: { __typename?: 'Entity', keys?: Array | null, components?: Array<{ __typename: 'Drug' } | { __typename: 'Game' } | { __typename: 'Market', cash?: any | null, quantity?: any | null } | { __typename: 'Name' } | { __typename: 'Player' } | { __typename: 'Risks', travel?: any | null } | null> | null } | null } | null> | null } | null }; - +export type LocationEntitiesQuery = { + __typename?: "Query"; + entities?: { + __typename?: "EntityConnection"; + totalCount: number; + edges?: Array<{ + __typename?: "EntityEdge"; + cursor: any; + node?: { + __typename?: "Entity"; + keys?: Array | null; + components?: Array< + | { __typename: "Drug" } + | { __typename: "Game" } + | { __typename: "Market"; cash?: any | null; quantity?: any | null } + | { __typename: "Name" } + | { __typename: "Player" } + | { __typename: "Risks"; travel?: any | null } + | null + > | null; + } | null; + } | null> | null; + } | null; +}; export const AvailableGamesDocument = ` query AvailableGames { @@ -747,39 +863,49 @@ export const AvailableGamesDocument = ` } `; export const useAvailableGamesQuery = < - TData = AvailableGamesQuery, - TError = unknown - >( - variables?: AvailableGamesQueryVariables, - options?: UseQueryOptions - ) => - useQuery( - variables === undefined ? ['AvailableGames'] : ['AvailableGames', variables], - useFetchData(AvailableGamesDocument).bind(null, variables), - options - ); - -useAvailableGamesQuery.getKey = (variables?: AvailableGamesQueryVariables) => variables === undefined ? ['AvailableGames'] : ['AvailableGames', variables]; -; - + TData = AvailableGamesQuery, + TError = unknown, +>( + variables?: AvailableGamesQueryVariables, + options?: UseQueryOptions, +) => + useQuery( + variables === undefined + ? ["AvailableGames"] + : ["AvailableGames", variables], + useFetchData( + AvailableGamesDocument, + ).bind(null, variables), + options, + ); + +useAvailableGamesQuery.getKey = (variables?: AvailableGamesQueryVariables) => + variables === undefined ? ["AvailableGames"] : ["AvailableGames", variables]; export const useInfiniteAvailableGamesQuery = < - TData = AvailableGamesQuery, - TError = unknown - >( - variables?: AvailableGamesQueryVariables, - options?: UseInfiniteQueryOptions - ) =>{ - const query = useFetchData(AvailableGamesDocument) - return useInfiniteQuery( - variables === undefined ? ['AvailableGames.infinite'] : ['AvailableGames.infinite', variables], - (metaData) => query({...variables, ...(metaData.pageParam ?? {})}), - options - )}; - - -useInfiniteAvailableGamesQuery.getKey = (variables?: AvailableGamesQueryVariables) => variables === undefined ? ['AvailableGames.infinite'] : ['AvailableGames.infinite', variables]; -; + TData = AvailableGamesQuery, + TError = unknown, +>( + variables?: AvailableGamesQueryVariables, + options?: UseInfiniteQueryOptions, +) => { + const query = useFetchData( + AvailableGamesDocument, + ); + return useInfiniteQuery( + variables === undefined + ? ["AvailableGames.infinite"] + : ["AvailableGames.infinite", variables], + (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), + options, + ); +}; +useInfiniteAvailableGamesQuery.getKey = ( + variables?: AvailableGamesQueryVariables, +) => + variables === undefined + ? ["AvailableGames.infinite"] + : ["AvailableGames.infinite", variables]; export const GlobalScoresDocument = ` query GlobalScores($limit: Int) { playerComponents( @@ -807,39 +933,47 @@ export const GlobalScoresDocument = ` } `; export const useGlobalScoresQuery = < - TData = GlobalScoresQuery, - TError = unknown - >( - variables?: GlobalScoresQueryVariables, - options?: UseQueryOptions - ) => - useQuery( - variables === undefined ? ['GlobalScores'] : ['GlobalScores', variables], - useFetchData(GlobalScoresDocument).bind(null, variables), - options - ); - -useGlobalScoresQuery.getKey = (variables?: GlobalScoresQueryVariables) => variables === undefined ? ['GlobalScores'] : ['GlobalScores', variables]; -; - + TData = GlobalScoresQuery, + TError = unknown, +>( + variables?: GlobalScoresQueryVariables, + options?: UseQueryOptions, +) => + useQuery( + variables === undefined ? ["GlobalScores"] : ["GlobalScores", variables], + useFetchData( + GlobalScoresDocument, + ).bind(null, variables), + options, + ); + +useGlobalScoresQuery.getKey = (variables?: GlobalScoresQueryVariables) => + variables === undefined ? ["GlobalScores"] : ["GlobalScores", variables]; export const useInfiniteGlobalScoresQuery = < - TData = GlobalScoresQuery, - TError = unknown - >( - variables?: GlobalScoresQueryVariables, - options?: UseInfiniteQueryOptions - ) =>{ - const query = useFetchData(GlobalScoresDocument) - return useInfiniteQuery( - variables === undefined ? ['GlobalScores.infinite'] : ['GlobalScores.infinite', variables], - (metaData) => query({...variables, ...(metaData.pageParam ?? {})}), - options - )}; - - -useInfiniteGlobalScoresQuery.getKey = (variables?: GlobalScoresQueryVariables) => variables === undefined ? ['GlobalScores.infinite'] : ['GlobalScores.infinite', variables]; -; + TData = GlobalScoresQuery, + TError = unknown, +>( + variables?: GlobalScoresQueryVariables, + options?: UseInfiniteQueryOptions, +) => { + const query = useFetchData( + GlobalScoresDocument, + ); + return useInfiniteQuery( + variables === undefined + ? ["GlobalScores.infinite"] + : ["GlobalScores.infinite", variables], + (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), + options, + ); +}; +useInfiniteGlobalScoresQuery.getKey = ( + variables?: GlobalScoresQueryVariables, +) => + variables === undefined + ? ["GlobalScores.infinite"] + : ["GlobalScores.infinite", variables]; export const GameEntityDocument = ` query GameEntity($id: ID!) { entity(id: $id) { @@ -857,40 +991,43 @@ export const GameEntityDocument = ` } } `; -export const useGameEntityQuery = < - TData = GameEntityQuery, - TError = unknown - >( - variables: GameEntityQueryVariables, - options?: UseQueryOptions - ) => - useQuery( - ['GameEntity', variables], - useFetchData(GameEntityDocument).bind(null, variables), - options - ); - -useGameEntityQuery.getKey = (variables: GameEntityQueryVariables) => ['GameEntity', variables]; -; - +export const useGameEntityQuery = ( + variables: GameEntityQueryVariables, + options?: UseQueryOptions, +) => + useQuery( + ["GameEntity", variables], + useFetchData( + GameEntityDocument, + ).bind(null, variables), + options, + ); + +useGameEntityQuery.getKey = (variables: GameEntityQueryVariables) => [ + "GameEntity", + variables, +]; export const useInfiniteGameEntityQuery = < - TData = GameEntityQuery, - TError = unknown - >( - variables: GameEntityQueryVariables, - options?: UseInfiniteQueryOptions - ) =>{ - const query = useFetchData(GameEntityDocument) - return useInfiniteQuery( - ['GameEntity.infinite', variables], - (metaData) => query({...variables, ...(metaData.pageParam ?? {})}), - options - )}; - - -useInfiniteGameEntityQuery.getKey = (variables: GameEntityQueryVariables) => ['GameEntity.infinite', variables]; -; + TData = GameEntityQuery, + TError = unknown, +>( + variables: GameEntityQueryVariables, + options?: UseInfiniteQueryOptions, +) => { + const query = useFetchData( + GameEntityDocument, + ); + return useInfiniteQuery( + ["GameEntity.infinite", variables], + (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), + options, + ); +}; +useInfiniteGameEntityQuery.getKey = (variables: GameEntityQueryVariables) => [ + "GameEntity.infinite", + variables, +]; export const PlayerEntityDocument = ` query PlayerEntity($gameId: String!, $playerId: String!) { entities(keys: [$gameId, $playerId]) { @@ -921,39 +1058,44 @@ export const PlayerEntityDocument = ` } `; export const usePlayerEntityQuery = < - TData = PlayerEntityQuery, - TError = unknown - >( - variables: PlayerEntityQueryVariables, - options?: UseQueryOptions - ) => - useQuery( - ['PlayerEntity', variables], - useFetchData(PlayerEntityDocument).bind(null, variables), - options - ); - -usePlayerEntityQuery.getKey = (variables: PlayerEntityQueryVariables) => ['PlayerEntity', variables]; -; - + TData = PlayerEntityQuery, + TError = unknown, +>( + variables: PlayerEntityQueryVariables, + options?: UseQueryOptions, +) => + useQuery( + ["PlayerEntity", variables], + useFetchData( + PlayerEntityDocument, + ).bind(null, variables), + options, + ); + +usePlayerEntityQuery.getKey = (variables: PlayerEntityQueryVariables) => [ + "PlayerEntity", + variables, +]; export const useInfinitePlayerEntityQuery = < - TData = PlayerEntityQuery, - TError = unknown - >( - variables: PlayerEntityQueryVariables, - options?: UseInfiniteQueryOptions - ) =>{ - const query = useFetchData(PlayerEntityDocument) - return useInfiniteQuery( - ['PlayerEntity.infinite', variables], - (metaData) => query({...variables, ...(metaData.pageParam ?? {})}), - options - )}; - - -useInfinitePlayerEntityQuery.getKey = (variables: PlayerEntityQueryVariables) => ['PlayerEntity.infinite', variables]; -; + TData = PlayerEntityQuery, + TError = unknown, +>( + variables: PlayerEntityQueryVariables, + options?: UseInfiniteQueryOptions, +) => { + const query = useFetchData( + PlayerEntityDocument, + ); + return useInfiniteQuery( + ["PlayerEntity.infinite", variables], + (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), + options, + ); +}; +useInfinitePlayerEntityQuery.getKey = ( + variables: PlayerEntityQueryVariables, +) => ["PlayerEntity.infinite", variables]; export const LocationEntitiesDocument = ` query LocationEntities($gameId: String!, $locationId: String!) { entities(keys: [$gameId, $locationId]) { @@ -978,35 +1120,41 @@ export const LocationEntitiesDocument = ` } `; export const useLocationEntitiesQuery = < - TData = LocationEntitiesQuery, - TError = unknown - >( - variables: LocationEntitiesQueryVariables, - options?: UseQueryOptions - ) => - useQuery( - ['LocationEntities', variables], - useFetchData(LocationEntitiesDocument).bind(null, variables), - options - ); - -useLocationEntitiesQuery.getKey = (variables: LocationEntitiesQueryVariables) => ['LocationEntities', variables]; -; - + TData = LocationEntitiesQuery, + TError = unknown, +>( + variables: LocationEntitiesQueryVariables, + options?: UseQueryOptions, +) => + useQuery( + ["LocationEntities", variables], + useFetchData( + LocationEntitiesDocument, + ).bind(null, variables), + options, + ); + +useLocationEntitiesQuery.getKey = ( + variables: LocationEntitiesQueryVariables, +) => ["LocationEntities", variables]; export const useInfiniteLocationEntitiesQuery = < - TData = LocationEntitiesQuery, - TError = unknown - >( - variables: LocationEntitiesQueryVariables, - options?: UseInfiniteQueryOptions - ) =>{ - const query = useFetchData(LocationEntitiesDocument) - return useInfiniteQuery( - ['LocationEntities.infinite', variables], - (metaData) => query({...variables, ...(metaData.pageParam ?? {})}), - options - )}; - - -useInfiniteLocationEntitiesQuery.getKey = (variables: LocationEntitiesQueryVariables) => ['LocationEntities.infinite', variables]; -; + TData = LocationEntitiesQuery, + TError = unknown, +>( + variables: LocationEntitiesQueryVariables, + options?: UseInfiniteQueryOptions, +) => { + const query = useFetchData< + LocationEntitiesQuery, + LocationEntitiesQueryVariables + >(LocationEntitiesDocument); + return useInfiniteQuery( + ["LocationEntities.infinite", variables], + (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), + options, + ); +}; + +useInfiniteLocationEntitiesQuery.getKey = ( + variables: LocationEntitiesQueryVariables, +) => ["LocationEntities.infinite", variables]; diff --git a/web/src/generated/introspection.ts b/web/src/generated/introspection.ts index 5cd553c8b..69f089f8e 100644 --- a/web/src/generated/introspection.ts +++ b/web/src/generated/introspection.ts @@ -1,20 +1,11 @@ - - export interface PossibleTypesResultData { - possibleTypes: { - [key: string]: string[] - } - } - const result: PossibleTypesResultData = { - "possibleTypes": { - "ComponentUnion": [ - "Drug", - "Game", - "Market", - "Name", - "Player", - "Risks" - ] - } +export interface PossibleTypesResultData { + possibleTypes: { + [key: string]: string[]; + }; +} +const result: PossibleTypesResultData = { + possibleTypes: { + ComponentUnion: ["Drug", "Game", "Market", "Name", "Player", "Risks"], + }, }; - export default result; - \ No newline at end of file +export default result; diff --git a/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx b/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx index 6d50d2f75..1711bba65 100644 --- a/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx +++ b/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx @@ -234,6 +234,7 @@ const QuantitySelector = ({ (d) => d.id === drug.id, )?.quantity; setMax(playerQuantity || 0); + setQuantity(playerQuantity || 0); } }, [type, drug, player, market]); diff --git a/web/src/pages/[gameId]/event/consequence.tsx b/web/src/pages/[gameId]/event/consequence.tsx index 1e679d951..6ce94c748 100644 --- a/web/src/pages/[gameId]/event/consequence.tsx +++ b/web/src/pages/[gameId]/event/consequence.tsx @@ -51,7 +51,7 @@ export default function Consequence() { width={400} height={400} /> - + {response} diff --git a/web/src/pages/[gameId]/event/decision.tsx b/web/src/pages/[gameId]/event/decision.tsx index ffad01774..8961401ce 100644 --- a/web/src/pages/[gameId]/event/decision.tsx +++ b/web/src/pages/[gameId]/event/decision.tsx @@ -8,19 +8,26 @@ 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, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import Layout from "@/components/Layout"; import { Footer } from "@/components/Footer"; import Button from "@/components/Button"; +import { formatCash } from "@/utils/ui"; -const BASE_PAYMENT = 400; +const BASE_PAYMENT = 500; +const COPS_DRUG_THRESHOLD = 5; export default function Decision() { const router = useRouter(); const gameId = router.query.gameId as string; const nextLocation = getLocationById(router.query.nextId as string); - const [isSubmitting, setIsSubmitting] = useState(false); const [status, setStatus] = useState(); + const [isSubmitting, setIsSubmitting] = useState(false); + const [prefixTitle, setPrefixTitle] = useState(); + const [title, setTitle] = useState(); + const [demand, setDemand] = useState(); + const [penalty, setPenalty] = useState(); + const { account } = useDojo(); const { decide } = useSystems(); const { addEncounter } = usePlayerStore(); @@ -32,26 +39,61 @@ export default function Decision() { useEffect(() => { if (playerEntity && !isSubmitting) { + switch (playerEntity.status) { + case PlayerStatus.BeingMugged: + setPrefixTitle("You encountered a..."); + setTitle("Gang!"); + setDemand(`They want 10% of your DRUGS and $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!`, + ); + break; + } + setStatus(playerEntity.status); } }, [playerEntity]); + const canPay = useMemo(() => { + if (playerEntity && playerEntity.status == PlayerStatus.BeingArrested) { + return playerEntity.cash >= copsPayment(playerEntity.drugCount); + } + return true; + }, [playerEntity]); + const onDecision = useCallback( async (action: Action) => { setIsSubmitting(true); + setPenalty(""); + const result = await decide(gameId, action, nextLocation.id); const event = result.event! as ConsequenceEventData; addEncounter(playerEntity!.status, event.outcome); - if (event.outcome === Outcome.Died) { - return router.push(`/${gameId}/end`); - } + switch (event.outcome) { + case Outcome.Captured: + setIsSubmitting(false); + setPrefixTitle("Your escape..."); + setTitle("Failed!"); + setPenalty(`You loss ${event.healthLoss}HP!`); + break; + + case Outcome.Died: + return router.push(`/${gameId}/end`); - router.replace( - `/${gameId}/event/consequence?outcome=${event.outcome}&status=${ - playerEntity!.status - }`, - ); + case Outcome.Escaped: + case Outcome.Paid: + return router.replace( + `/${gameId}/event/consequence?outcome=${event.outcome}&status=${ + playerEntity!.status + }`, + ); + } }, [gameId, nextLocation, router, playerEntity, addEncounter, decide], ); @@ -69,58 +111,66 @@ export default function Decision() { return ( <> - {status == PlayerStatus.BeingMugged && ( - onDecision(Action.Run)} - fight={() => onDecision(Action.Fight)} - /> - )} - - {status == PlayerStatus.BeingArrested && ( - onDecision(Action.Run)} - pay={() => onDecision(Action.Pay)} - /> - )} + onDecision(Action.Run)} + onPay={() => onDecision(Action.Pay)} + /> ); } +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, - cash, - run, - pay, - fight, + penalty, + canPay, + isSubmitting, + onPay, + onRun, }: { - prefixTitle: string; - title: string; - demand: string; + prefixTitle?: string; + title?: string; + demand?: string; imageSrc: string; - cash: number; - run: () => void; - pay?: () => void; - fight?: () => void; + penalty?: string; + canPay: boolean; + isSubmitting?: boolean; + onPay: () => void; + onRun: () => void; }) => { const [isPaying, setIsPaying] = useState(false); const [isRunning, setIsRunning] = useState(false); - const [isFighting, setIsFighting] = useState(false); + + useEffect(() => { + if (!isSubmitting) { + setIsPaying(false); + setIsRunning(false); + } + }, [isSubmitting]); return ( <> @@ -135,52 +185,50 @@ const Encounter = ({ {title} - adverse event - - - Better think fast... - * {demand} * + adverse event + + + {isSubmitting ? ( + <> + {isRunning && You split without a second thought} + {isPaying && You decided to pay up} + + ) : ( + <> + {demand} + {penalty} + + )}