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/components/player.cairo b/src/components/player.cairo index a3bebd38a..905f189a1 100644 --- a/src/components/player.cairo +++ b/src/components/player.cairo @@ -15,6 +15,7 @@ struct Player { drug_count: usize, bag_limit: usize, turns_remaining: usize, + turns_remaining_on_death: usize } #[generate_trait] diff --git a/src/components/risks.cairo b/src/components/risks.cairo index 671bf38f9..583f715da 100644 --- a/src/components/risks.cairo +++ b/src/components/risks.cairo @@ -18,8 +18,8 @@ struct Risks { #[generate_trait] impl RisksImpl of RisksTrait { #[inline(always)] - fn travel(ref self: Risks, seed: felt252, cash: u128, drug_count: usize) -> PlayerStatus { - if occurs(seed, self.travel) { + fn travel(self: @Risks, seed: felt252, cash: u128, drug_count: usize) -> PlayerStatus { + if occurs(seed, *self.travel) { let seed = pedersen::pedersen(seed, seed); let entropy: u256 = seed.into(); let result: u128 = entropy.low % 100; @@ -43,8 +43,8 @@ impl RisksImpl of RisksTrait { } #[inline(always)] - fn run(ref self: Risks, seed: felt252) -> bool { - occurs(seed, self.capture) + fn run(self: @Risks, seed: felt252) -> bool { + occurs(seed, *self.capture) } } diff --git a/src/systems/create.cairo b/src/systems/create.cairo index c04e9f535..f86512509 100644 --- a/src/systems/create.cairo +++ b/src/systems/create.cairo @@ -19,8 +19,7 @@ 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 + TRAVEL_RISK, CAPTURE_RISK, STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT }; use rollyourown::utils::random; use debug::PrintTrait; @@ -65,6 +64,7 @@ mod create_game { drug_count: 0, bag_limit: STARTING_BAG_LIMIT, turns_remaining: max_turns, + turns_remaining_on_death: 0 }; let game = Game { @@ -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 4365c5b1d..e7ccc2fea 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::{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}; @@ -100,6 +100,7 @@ mod decide { if health_loss >= player.health { player.health = 0; player.turns_remaining = 0; + player.turns_remaining_on_death = player.turns_remaining; outcome = Outcome::Died; } else { player.health -= health_loss @@ -109,11 +110,13 @@ 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 { if drug_count < COPS_DRUG_THRESHOLD + 20 { 1000_0000 // $1000 @@ -126,6 +129,7 @@ mod decide { } } + fn take_drugs( ctx: Context, game_id: u32, player_id: ContractAddress, percentage: usize ) -> usize { diff --git a/src/systems/join.cairo b/src/systems/join.cairo index e13d5ffe4..8b4dad143 100644 --- a/src/systems/join.cairo +++ b/src/systems/join.cairo @@ -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::{ - SCALING_FACTOR, STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT - }; + use rollyourown::constants::{STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT}; #[event] #[derive(Drop, starknet::Event)] @@ -52,6 +50,7 @@ mod join_game { drug_count: 0, bag_limit: STARTING_BAG_LIMIT, turns_remaining: game.max_turns, + turns_remaining_on_death: 0 }; set!(ctx.world, (game, player)); 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..1a39b9aa8 100644 --- a/src/systems/travel.cairo +++ b/src/systems/travel.cairo @@ -47,11 +47,11 @@ mod travel { assert(game.tick(), 'game cannot progress'); let player_id = ctx.origin; - let mut player = get!(ctx.world, (game_id, player_id).into(), Player); + let mut player: Player = get!(ctx.world, (game_id, player_id).into(), Player); assert(player.can_continue(), 'player cannot travel'); assert(player.location_id != next_location_id, 'already at location'); - let mut risks = get!(ctx.world, (game_id, next_location_id).into(), Risks); + let mut risks: Risks = get!(ctx.world, (game_id, next_location_id).into(), Risks); let seed = starknet::get_tx_info().unbox().transaction_hash; player.status = risks.travel(seed, player.cash, player.drug_count); if player.status != PlayerStatus::Normal { @@ -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/public/sounds/GameOver.mp3 b/web/public/sounds/GameOver.mp3 new file mode 100644 index 000000000..4b83826d2 Binary files /dev/null and b/web/public/sounds/GameOver.mp3 differ diff --git a/web/src/components/icons/Skull.tsx b/web/src/components/icons/Skull.tsx new file mode 100644 index 000000000..387325f19 --- /dev/null +++ b/web/src/components/icons/Skull.tsx @@ -0,0 +1,9 @@ +import { Icon, IconProps } from "."; + +export const Skull = (props: IconProps) => { + return ( + + + + ); +}; \ No newline at end of file diff --git a/web/src/components/icons/index.tsx b/web/src/components/icons/index.tsx index b4879b4d0..896fce3de 100644 --- a/web/src/components/icons/index.tsx +++ b/web/src/components/icons/index.tsx @@ -45,6 +45,7 @@ export * from "./Roll"; export * from "./Close"; export * from "./ExternalLink"; export * from "./Heart"; +export * from "./Skull"; // Template for adding new icons. When copying svg from figma, viewBox is assumed // to be 36x36, otherwise override within individual icons. diff --git a/web/src/dojo/entities/usePlayerEntity.tsx b/web/src/dojo/entities/usePlayerEntity.tsx index 595276697..ec3078329 100644 --- a/web/src/dojo/entities/usePlayerEntity.tsx +++ b/web/src/dojo/entities/usePlayerEntity.tsx @@ -17,6 +17,7 @@ export class PlayerEntity { cash: number; health: number; turnsRemaining: number; + turnsRemainingOnDeath: number; drugCount: number; bagLimit: number; locationId: string; @@ -27,6 +28,7 @@ export class PlayerEntity { this.cash = Number(player.cash) / SCALING_FACTOR; this.health = player.health; this.turnsRemaining = player.turns_remaining; + this.turnsRemainingOnDeath = player.turns_remaining_on_death; this.drugCount = player.drug_count; this.bagLimit = player.bag_limit; this.locationId = player.location_id; diff --git a/web/src/dojo/events.ts b/web/src/dojo/events.ts index 52a7dc62e..b44916148 100644 --- a/web/src/dojo/events.ts +++ b/web/src/dojo/events.ts @@ -14,7 +14,7 @@ export enum RyoEvents { Sold = "0x123e760cef925d0b4f685db5e1ac87aadaf1ad9f8069122a5bb03353444c386", AdverseEvent = "0x3605d6af5b08d01a1b42fa16a5f4dc202724f1664912948dcdbe99f5c93d0a0", Decision = "0xc9315f646a66dd126a564fa76bfdc00bdb47abe0d8187e464f69215dbf432a", - Consqeuence = "0x1335a57b72e0bcb464f40bf1f140f691ec93e4147b91d0760640c19999b841d", + Consequence = "0x1335a57b72e0bcb464f40bf1f140f691ec93e4147b91d0760640c19999b841d", } export interface BaseEventData { @@ -108,7 +108,7 @@ export const parseEvent = ( playerId: num.toHexString(raw.data[1]), action: Number(raw.data[2]), } as DecisionEventData; - case RyoEvents.Consqeuence: + case RyoEvents.Consequence: return { gameId: num.toHexString(raw.data[0]), playerId: num.toHexString(raw.data[1]), diff --git a/web/src/dojo/helpers.ts b/web/src/dojo/helpers.ts index 71e50191e..d86d8635b 100644 --- a/web/src/dojo/helpers.ts +++ b/web/src/dojo/helpers.ts @@ -157,6 +157,24 @@ export const outcomes: OutcomeInfo[] = [ getMuggerResponses(Outcome.Escaped, isInitial), color: "neon.200", }, + { + name: "Got killed by the Gang", + type: Outcome.Died, + status: PlayerStatus.BeingMugged, + imageSrc: "/images/events/fought.png", + getResponse: (isInitial: boolean) => + getMuggerResponses(Outcome.Died, isInitial), + color: "red", + }, + { + name: "Got killed by the Cops", + type: Outcome.Died, + status: PlayerStatus.BeingArrested, + imageSrc: "/images/events/fought.png", + getResponse: (isInitial: boolean) => + getMuggerResponses(Outcome.Died, isInitial), + color: "red", + }, ]; function findBy(array: T[], key: keyof T, value: any): T | undefined { @@ -191,11 +209,13 @@ export function getOutcomeInfo( status: PlayerStatus, type: Outcome, ): OutcomeInfo { - return ( - outcomes.find((item) => { + const found = outcomes.find((item) => { return item.status === status && item.type === type; - }) || outcomes[0] - ); + }); + if(!found) { + console.log(`getOutcomeInfo outcome ${status} ${type} not found !`) + } + return found || outcomes[0] } export function sortDrugMarkets(drugMarkets?: DrugMarket[]): DrugMarket[] { diff --git a/web/src/dojo/systems/useSystems.tsx b/web/src/dojo/systems/useSystems.tsx index 0aa270354..2fbf621d2 100644 --- a/web/src/dojo/systems/useSystems.tsx +++ b/web/src/dojo/systems/useSystems.tsx @@ -2,6 +2,7 @@ import { useCallback } from "react"; import { useDojo } from ".."; import { BaseEventData, parseEvent, RyoEvents } from "../events"; import { Action } from "../types"; +import { shortString } from "starknet"; export interface SystemsInterface { create: ( @@ -41,7 +42,7 @@ export interface SystemExecuteResult { export const useSystems = (): SystemsInterface => { const { execute, account, error, isPending } = useDojo(); - const executeAndReciept = useCallback( + const executeAndReceipt = useCallback( async (method: string, params: Array) => { if (!account) { throw new Error("No account connected"); @@ -60,7 +61,7 @@ export const useSystems = (): SystemsInterface => { const create = useCallback( async (startTime: number, maxPlayers: number, maxTurns: number) => { - const receipt = await executeAndReciept("create_game", [ + const receipt = await executeAndReceipt("create_game", [ startTime, maxPlayers, maxTurns, @@ -76,12 +77,12 @@ export const useSystems = (): SystemsInterface => { event, }; }, - [executeAndReciept], + [executeAndReceipt], ); const travel = useCallback( async (gameId: string, locationId: string) => { - const receipt = await executeAndReciept("travel", [gameId, locationId]); + const receipt = await executeAndReceipt("travel", [gameId, locationId]); const hash = "transaction_hash" in receipt ? receipt.transaction_hash : ""; @@ -95,12 +96,12 @@ export const useSystems = (): SystemsInterface => { return result; }, - [executeAndReciept], + [executeAndReceipt], ); const join = useCallback( async (gameId: string) => { - const receipt = await executeAndReciept("join_game", [gameId]); + const receipt = await executeAndReceipt("join_game", [gameId]); const event = parseEvent(receipt, RyoEvents.PlayerJoined); const hash = @@ -111,7 +112,7 @@ export const useSystems = (): SystemsInterface => { event, }; }, - [executeAndReciept], + [executeAndReceipt], ); const buy = useCallback( @@ -121,7 +122,7 @@ export const useSystems = (): SystemsInterface => { drugId: string, quantity: number, ) => { - const receipt = await executeAndReciept("buy", [ + const receipt = await executeAndReceipt("buy", [ gameId, locationId, drugId, @@ -134,7 +135,7 @@ export const useSystems = (): SystemsInterface => { hash, }; }, - [executeAndReciept], + [executeAndReceipt], ); const sell = useCallback( @@ -144,7 +145,7 @@ export const useSystems = (): SystemsInterface => { drugId: string, quantity: number, ) => { - const receipt = await executeAndReciept("sell", [ + const receipt = await executeAndReceipt("sell", [ gameId, locationId, drugId, @@ -157,12 +158,14 @@ export const useSystems = (): SystemsInterface => { hash, }; }, - [executeAndReciept], + [executeAndReceipt], ); const setName = useCallback( async (gameId: string, playerName: string) => { - const receipt = await executeAndReciept("set_name", [gameId, playerName]); + // not working if name is number only + const name = shortString.encodeShortString(playerName); + const receipt = await executeAndReceipt("set_name", [gameId, name]); const hash = "transaction_hash" in receipt ? receipt.transaction_hash : ""; @@ -170,18 +173,18 @@ export const useSystems = (): SystemsInterface => { hash, }; }, - [executeAndReciept], + [executeAndReceipt], ); const decide = useCallback( async (gameId: string, action: Action, nextLocationId: string) => { - const receipt = await executeAndReciept("decide", [ + const receipt = await executeAndReceipt("decide", [ gameId, action, nextLocationId, ]); - const event = parseEvent(receipt, RyoEvents.Consqeuence); + const event = parseEvent(receipt, RyoEvents.Consequence); const hash = "transaction_hash" in receipt ? receipt.transaction_hash : ""; return { @@ -189,7 +192,7 @@ export const useSystems = (): SystemsInterface => { event, }; }, - [executeAndReciept], + [executeAndReceipt], ); return { diff --git a/web/src/generated/graphql.ts b/web/src/generated/graphql.ts index b407071d9..228aa5b76 100644 --- a/web/src/generated/graphql.ts +++ b/web/src/generated/graphql.ts @@ -1,22 +1,10 @@ -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; @@ -38,51 +26,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; }; @@ -92,104 +80,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; }; @@ -199,79 +187,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; }; @@ -281,63 +269,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; }; @@ -347,56 +335,57 @@ 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; + turns_remaining_on_death?: 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; }; @@ -406,83 +395,90 @@ 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', + TurnsRemainingOnDeath = 'TURNS_REMAINING_ON_DEATH' } 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; + turns_remaining_on_death?: InputMaybe; + turns_remaining_on_deathGT?: InputMaybe; + turns_remaining_on_deathGTE?: InputMaybe; + turns_remaining_on_deathLT?: InputMaybe; + turns_remaining_on_deathLTE?: InputMaybe; + turns_remaining_on_deathNEQ?: InputMaybe; }; export type Query = { - __typename?: "Query"; + __typename?: 'Query'; component: Component; components?: Maybe; drugComponents?: Maybe; @@ -501,106 +497,118 @@ 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,261 +618,131 @@ 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 MarketPricesQueryVariables = Exact<{ - gameId?: InputMaybe; + gameId?: InputMaybe; }>; -export type MarketPricesQuery = { - __typename?: "Query"; - marketComponents?: { - __typename?: "MarketConnection"; - edges?: Array<{ - __typename?: "MarketEdge"; - node?: { - __typename?: "Market"; - drug_id?: any | null; - location_id?: any | null; - quantity?: any | null; - cash?: any | null; - } | null; - } | null> | null; - } | null; -}; + +export type MarketPricesQuery = { __typename?: 'Query', marketComponents?: { __typename?: 'MarketConnection', edges?: Array<{ __typename?: 'MarketEdge', node?: { __typename?: 'Market', drug_id?: any | null, location_id?: any | null, quantity?: any | null, cash?: any | 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, turns_remaining_on_death?: 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 { @@ -884,49 +762,39 @@ 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, - ); -}; + 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]; +; -useInfiniteAvailableGamesQuery.getKey = ( - variables?: AvailableGamesQueryVariables, -) => - variables === undefined - ? ["AvailableGames.infinite"] - : ["AvailableGames.infinite", variables]; export const GlobalScoresDocument = ` query GlobalScores($limit: Int) { playerComponents( @@ -954,47 +822,39 @@ 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, - ); -}; + 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]; +; -useInfiniteGlobalScoresQuery.getKey = ( - variables?: GlobalScoresQueryVariables, -) => - variables === undefined - ? ["GlobalScores.infinite"] - : ["GlobalScores.infinite", variables]; export const MarketPricesDocument = ` query MarketPrices($gameId: Int) { marketComponents(first: 36, where: {game_id: $gameId}) { @@ -1010,47 +870,39 @@ export const MarketPricesDocument = ` } `; export const useMarketPricesQuery = < - TData = MarketPricesQuery, - TError = unknown, ->( - variables?: MarketPricesQueryVariables, - options?: UseQueryOptions, -) => - useQuery( - variables === undefined ? ["MarketPrices"] : ["MarketPrices", variables], - useFetchData( - MarketPricesDocument, - ).bind(null, variables), - options, - ); - -useMarketPricesQuery.getKey = (variables?: MarketPricesQueryVariables) => - variables === undefined ? ["MarketPrices"] : ["MarketPrices", variables]; + TData = MarketPricesQuery, + TError = unknown + >( + variables?: MarketPricesQueryVariables, + options?: UseQueryOptions + ) => + useQuery( + variables === undefined ? ['MarketPrices'] : ['MarketPrices', variables], + useFetchData(MarketPricesDocument).bind(null, variables), + options + ); + +useMarketPricesQuery.getKey = (variables?: MarketPricesQueryVariables) => variables === undefined ? ['MarketPrices'] : ['MarketPrices', variables]; +; + export const useInfiniteMarketPricesQuery = < - TData = MarketPricesQuery, - TError = unknown, ->( - variables?: MarketPricesQueryVariables, - options?: UseInfiniteQueryOptions, -) => { - const query = useFetchData( - MarketPricesDocument, - ); - return useInfiniteQuery( - variables === undefined - ? ["MarketPrices.infinite"] - : ["MarketPrices.infinite", variables], - (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), - options, - ); -}; + TData = MarketPricesQuery, + TError = unknown + >( + variables?: MarketPricesQueryVariables, + options?: UseInfiniteQueryOptions + ) =>{ + const query = useFetchData(MarketPricesDocument) + return useInfiniteQuery( + variables === undefined ? ['MarketPrices.infinite'] : ['MarketPrices.infinite', variables], + (metaData) => query({...variables, ...(metaData.pageParam ?? {})}), + options + )}; + + +useInfiniteMarketPricesQuery.getKey = (variables?: MarketPricesQueryVariables) => variables === undefined ? ['MarketPrices.infinite'] : ['MarketPrices.infinite', variables]; +; -useInfiniteMarketPricesQuery.getKey = ( - variables?: MarketPricesQueryVariables, -) => - variables === undefined - ? ["MarketPrices.infinite"] - : ["MarketPrices.infinite", variables]; export const GameEntityDocument = ` query GameEntity($id: ID!) { entity(id: $id) { @@ -1068,43 +920,40 @@ export const GameEntityDocument = ` } } `; -export const useGameEntityQuery = ( - variables: GameEntityQueryVariables, - options?: UseQueryOptions, -) => - useQuery( - ["GameEntity", variables], - useFetchData( - GameEntityDocument, - ).bind(null, variables), - options, - ); - -useGameEntityQuery.getKey = (variables: GameEntityQueryVariables) => [ - "GameEntity", - variables, -]; +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 useInfiniteGameEntityQuery = < - TData = GameEntityQuery, - TError = unknown, ->( - variables: GameEntityQueryVariables, - options?: UseInfiniteQueryOptions, -) => { - const query = useFetchData( - GameEntityDocument, - ); - return useInfiniteQuery( - ["GameEntity.infinite", variables], - (metaData) => query({ ...variables, ...(metaData.pageParam ?? {}) }), - options, - ); -}; + 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]; +; -useInfiniteGameEntityQuery.getKey = (variables: GameEntityQueryVariables) => [ - "GameEntity.infinite", - variables, -]; export const PlayerEntityDocument = ` query PlayerEntity($gameId: String!, $playerId: String!) { entities(keys: [$gameId, $playerId]) { @@ -1122,6 +971,7 @@ export const PlayerEntityDocument = ` bag_limit location_id turns_remaining + turns_remaining_on_death } ... on Drug { drug_id @@ -1135,44 +985,39 @@ 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, - ); -}; + 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]; +; -useInfinitePlayerEntityQuery.getKey = ( - variables: PlayerEntityQueryVariables, -) => ["PlayerEntity.infinite", variables]; export const LocationEntitiesDocument = ` query LocationEntities($gameId: String!, $locationId: String!) { entities(keys: [$gameId, $locationId]) { @@ -1197,41 +1042,35 @@ 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]; -export const useInfiniteLocationEntitiesQuery = < - 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, - ); -}; + TData = LocationEntitiesQuery, + TError = unknown + >( + variables: LocationEntitiesQueryVariables, + options?: UseQueryOptions + ) => + useQuery( + ['LocationEntities', variables], + useFetchData(LocationEntitiesDocument).bind(null, variables), + options + ); + +useLocationEntitiesQuery.getKey = (variables: LocationEntitiesQueryVariables) => ['LocationEntities', variables]; +; -useInfiniteLocationEntitiesQuery.getKey = ( - variables: LocationEntitiesQueryVariables, -) => ["LocationEntities.infinite", 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]; +; diff --git a/web/src/generated/introspection.ts b/web/src/generated/introspection.ts index 69f089f8e..5cd553c8b 100644 --- a/web/src/generated/introspection.ts +++ b/web/src/generated/introspection.ts @@ -1,11 +1,20 @@ -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; + export default result; + \ No newline at end of file diff --git a/web/src/graphql/entities.graphql b/web/src/graphql/entities.graphql index 48fc5ce48..0112bef6c 100644 --- a/web/src/graphql/entities.graphql +++ b/web/src/graphql/entities.graphql @@ -30,6 +30,7 @@ query PlayerEntity($gameId: String!, $playerId: String!) { bag_limit location_id turns_remaining + turns_remaining_on_death } ... on Drug { drug_id diff --git a/web/src/hooks/sound.tsx b/web/src/hooks/sound.tsx index 11ef341a0..d6e8c9bc5 100644 --- a/web/src/hooks/sound.tsx +++ b/web/src/hooks/sound.tsx @@ -18,6 +18,7 @@ export enum Sounds { Trade = "Trade.mp3", Police = "Police.mp3", Gang = "Gang.mp3", + GameOver = "GameOver.mp3", } export interface SoundState { diff --git a/web/src/pages/[gameId]/end.tsx b/web/src/pages/[gameId]/end.tsx index 1f0a2b5e7..d3cce65ac 100644 --- a/web/src/pages/[gameId]/end.tsx +++ b/web/src/pages/[gameId]/end.tsx @@ -29,6 +29,11 @@ import { motion } from "framer-motion"; import { useRouter } from "next/router"; import Button from "@/components/Button"; import { ReactNode, useCallback, useState } from "react"; +import { usePlayerEntity } from "@/dojo/entities/usePlayerEntity"; +import { useGameEntity } from "@/dojo/entities/useGameEntity"; +import { Calendar } from "@/components/icons/archive"; +import { Skull, Heart } from "@/components/icons"; +import { formatCash } from "@/utils/ui"; export default function End() { const router = useRouter(); @@ -38,6 +43,24 @@ export default function End() { const [isSubmitting, setIsSubmitting] = useState(false); const [isCreditOpen, setIsCreditOpen] = useState(false); + const { account } = useDojo(); + + const { player: playerEntity } = usePlayerEntity({ + gameId, + address: account?.address, + }); + + const { game: gameEntity } = useGameEntity({ + gameId, + }); + + const isDead = playerEntity?.health === 0; + + const turnRemaining = isDead + ? playerEntity?.turnsRemainingOnDeath + : playerEntity?.turnsRemaining; + const day = (gameEntity?.maxTurns || 1_000) - (turnRemaining || 0); + const onSubmitName = useCallback(async () => { if (!name) return; @@ -64,6 +87,16 @@ export default function End() {
+ {isDead && ( + + You died ... + + )} + Game Over @@ -72,13 +105,24 @@ export default function End() { winner - } /> + {/* } /> + */} + } /> + + } + /> - } /> + : } + /> + {/* } /> - } /> + } /> */} @@ -90,7 +134,7 @@ export default function End() { > Credits - + */} + + + + diff --git a/web/src/pages/[gameId]/event/consequence.tsx b/web/src/pages/[gameId]/event/consequence.tsx index 6ce94c748..109af256c 100644 --- a/web/src/pages/[gameId]/event/consequence.tsx +++ b/web/src/pages/[gameId]/event/consequence.tsx @@ -5,10 +5,13 @@ import { getOutcomeInfo } from "@/dojo/helpers"; import { Heading, Text, VStack } from "@chakra-ui/react"; import { useRouter } from "next/router"; import Button from "@/components/Button"; -import { Outcome } from "@/dojo/types"; import { usePlayerEntity } from "@/dojo/entities/usePlayerEntity"; import { useDojo } from "@/dojo"; import { useMemo } from "react"; +import { PlayerStatus } from "@/dojo/types"; +import { Outcome } from "@/dojo/types"; +import { playSound, Sounds } from "@/hooks/sound"; +import { useEffect } from "react"; export default function Consequence() { const router = useRouter(); @@ -24,8 +27,15 @@ export default function Consequence() { address: account?.address, }); + const isDead = outcome.type == Outcome.Died; const response = useMemo(() => outcome.getResponse(true), [outcome]); + useEffect(() => { + if ( outcome.type == Outcome.Died) { + playSound(Sounds.GameOver); + } + }, [outcome]); + if (!router.isReady || !playerEntity) { return <>; } @@ -59,6 +69,7 @@ export default function Consequence() { diff --git a/web/src/pages/[gameId]/event/decision.tsx b/web/src/pages/[gameId]/event/decision.tsx index 28753ce3d..6dbf7fc19 100644 --- a/web/src/pages/[gameId]/event/decision.tsx +++ b/web/src/pages/[gameId]/event/decision.tsx @@ -74,7 +74,7 @@ export default function Decision() { playSound(Sounds.Police); } if (status == PlayerStatus.BeingMugged) { - playSound(Sounds.Gang, 0.69); + playSound(Sounds.Gang); } }, [status]);