From 945b165e639215d12d18a66330a140f34183d8c4 Mon Sep 17 00:00:00 2001 From: notV4l Date: Mon, 18 Sep 2023 14:41:28 +0200 Subject: [PATCH 1/4] feat: death screen --- src/components/player.cairo | 1 + src/components/risks.cairo | 8 +- src/constants.cairo | 3 + src/systems/create.cairo | 3 +- src/systems/decide.cairo | 10 +- src/systems/join.cairo | 3 +- src/systems/travel.cairo | 4 +- web/public/sounds/GameOver.mp3 | Bin 0 -> 14232 bytes web/src/components/icons/Skull.tsx | 9 + web/src/components/icons/index.tsx | 1 + web/src/dojo/entities/usePlayerEntity.tsx | 2 + web/src/dojo/events.ts | 4 +- web/src/dojo/helpers.ts | 28 +- web/src/dojo/systems/useSystems.tsx | 36 +- web/src/generated/graphql.ts | 1395 ++++++++---------- web/src/generated/introspection.ts | 29 +- web/src/graphql/entities.graphql | 1 + web/src/hooks/sound.tsx | 1 + web/src/pages/[gameId]/end.tsx | 48 +- web/src/pages/[gameId]/event/consequence.tsx | 23 +- web/src/pages/[gameId]/event/decision.tsx | 2 +- 21 files changed, 785 insertions(+), 826 deletions(-) create mode 100644 web/public/sounds/GameOver.mp3 create mode 100644 web/src/components/icons/Skull.tsx 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/constants.cairo b/src/constants.cairo index 3b64e52bb..383566b0b 100644 --- a/src/constants.cairo +++ b/src/constants.cairo @@ -9,6 +9,9 @@ const COPS_DRUG_THRESHOLD: usize = 5; // cops encounter threshold const HEALTH_IMPACT: u8 = 10; const GANGS_PAYMENT: usize = 20; +// consequences +const BASE_PAYMENT: u128 = 400_0000; // base payment is $400 + // starting stats const STARTING_CASH: u128 = 2000_0000; // $2000 const STARTING_BAG_LIMIT: usize = 100; // inventory size diff --git a/src/systems/create.cairo b/src/systems/create.cairo index c04e9f535..3b4bea39d 100644 --- a/src/systems/create.cairo +++ b/src/systems/create.cairo @@ -19,7 +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, + TRAVEL_RISK, CAPTURE_RISK, STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT }; use rollyourown::utils::random; @@ -65,6 +65,7 @@ mod create_game { drug_count: 0, bag_limit: STARTING_BAG_LIMIT, turns_remaining: max_turns, + turns_remaining_on_death: 0 }; let game = Game { diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 4365c5b1d..1318ae1ac 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,BASE_PAYMENT}; use rollyourown::components::game::{Game, GameTrait}; use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; @@ -53,7 +53,7 @@ mod decide { cash_loss: u128 } - fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) { + fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) { let player_id = ctx.origin; let mut player = get!(ctx.world, (game_id, player_id).into(), Player); assert(player.status != PlayerStatus::Normal, 'player response not needed'); @@ -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 @@ -113,8 +114,10 @@ mod decide { Consequence { game_id, player_id, outcome, health_loss, drug_loss, cash_loss } ); } + - fn cops_payment(drug_count: u32) -> u128 { + + fn cops_payment(drug_count: u32) -> u128 { if drug_count < COPS_DRUG_THRESHOLD + 20 { 1000_0000 // $1000 } else if drug_count < COPS_DRUG_THRESHOLD + 50 { @@ -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..320e901ea 100644 --- a/src/systems/join.cairo +++ b/src/systems/join.cairo @@ -12,7 +12,7 @@ mod join_game { use rollyourown::components::player::Player; use rollyourown::components::location::{Location, LocationTrait}; use rollyourown::constants::{ - SCALING_FACTOR, STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT + STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT }; #[event] @@ -52,6 +52,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/travel.cairo b/src/systems/travel.cairo index aa1d432a1..c82f37f67 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 { diff --git a/web/public/sounds/GameOver.mp3 b/web/public/sounds/GameOver.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..4b83826d2abedf1faf35ee080273993f1c141eb8 GIT binary patch literal 14232 zcmZ8|1yCGa)aBsr?rwv-2ODgV;O-3W?!n#N6WlGhI|K_Z0RkkryMzd{@cp}0yZfqU zYO1HJ`t&>Jp1$w)yU@D`2;l!8dUnn>ug9=nKOg`=Fb4oYL`B8I#U&yorJ$jqXJP_! zaB%bS35rNafaK+s)YLR}bq!5TEv&8WoSa-eJbVIzgTtevTd2LSNp z=;7v70RXu-9L8Q)6mNh0UjurF|Arq18Bp|g6czv@2>@Wn;X&_OA#miW(Ud#0wg7_o zS#p$6Yybul+|Z4!YY2dJ=-$Tqo82eEwYkjiJjZ5J)TocU$wMija&+k5w!QE4WIBu- z)JsS#y-%qAR@2-)+s>iz@2dv%N;Jn#-zxMZC0i$;{b(S>l@VtBl;u+PdQliD+;_Y% zc~(*DuFWF_O?tqd5v&BgON?CMC1qT4SiY_(bmXRc@{EuK-c`(L7U4>M8^;(54$Y7iTC>q!M>WB?2?juW7=chF^@5S7tn&GM6Yk_gBt z*EnQdAXW}QOBrT#1Glk7T6x#`DRUgj;}z9#k%OXH>b~FW8#g3XB`v0n3#%_`vUlI+ zEn-Lb^bV8JcCYKt>4J(USu!!1C(4Kt!qQgEBZ6-?(Ai-Ge zVa>3_#qWix(&W?4(PRtxK^>(khh-e}$d})nZh=|aj>M@Y7rAXq89S(tkO%#IT5aWb zk`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(6OIMOnBn`c z=o0iInlIqX*H=ipxR&{un1{BJH>f?`XcS-ZrEJw|bHDFITk50UDMKoJ6r5&%e*Q$fZAXNJ-);HBErZu9PZ1Ow z*g1|(#up|VhFfg$Gw@`8(eV2j_~l6OcQ3rF5gXL%6ZEY!=C+2u@PsV)hc)RkdNe@J z2XJz4X~1atc@J|>^w1j7nlt^aZ-|<-dH@%Gb{>Y z8jnYA#NMUnErU<}x1!SgQB~Xk1Ei{O6T$=G>ZeF2#&!{w_vjgKw6!i8dc*p)THFmVt+jFAk7T zPg|JX>@_tp@ruiHx-A;96({!99Z9!eAEAOzqi*NH-IdWnR#g}SWK~z7E0o_?k3NUN zm1BgH9k7&uJY_+yYV3*Kg!bwgbVRNyb3?B~L^wnkO5M%B2yPX_-EaG^=*d>j;NfQ_ z0T}C9%*G)?03uY3m0coq9qQ{%B<65o%$q@5IaB}y0iFs6gSvbthLIQYypT<6g_B88 z%_ke%I5sGR7HMHtKqL~=bc9E*71#LdAk|&3M08xuC_?fRN2*3DA?-vio}9#^1&8D` zL@Eg%xfq@nGD)Dgz{42xIS$ATy*nXP5H^aV;Nzi#d_bM8lMr;&gE7wxhzU1GNvpa-uZe~tt$iG^l;ofqwIo__UhInt z^swL%HyBFK&-RXA3Jbb7nkeS#xe&f{YfdPp2|ek9e4K;+!_q+dPWyj4+c@~N|KIV} Zzee)fzg7nL@z%cvrvNhu0KA^^zW~}&u { + 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..302f5619d 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,15 @@ 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); + debugger + const receipt = await executeAndReceipt("set_name", [gameId, name]); const hash = "transaction_hash" in receipt ? receipt.transaction_hash : ""; @@ -170,18 +174,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 +193,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..81e00ba17 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,22 @@ 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 +85,16 @@ export default function End() {
+ {isDead && ( + + You died ... + + )} + Game Over @@ -72,13 +103,24 @@ export default function End() { winner - } /> + {/* } /> + */} + } /> + + } + /> - } /> + : } + /> + {/* } /> - } /> + } /> */} 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() {
+ {!isDead ? ( + ) : ( + + )}
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]); From 681a11ae029f1a77e0a743a5083e8a89fc25b8bd Mon Sep 17 00:00:00 2001 From: notV4l Date: Tue, 19 Sep 2023 00:39:29 +0200 Subject: [PATCH 2/4] add feedback button --- web/src/pages/[gameId]/end.tsx | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/web/src/pages/[gameId]/end.tsx b/web/src/pages/[gameId]/end.tsx index 81e00ba17..d3cce65ac 100644 --- a/web/src/pages/[gameId]/end.tsx +++ b/web/src/pages/[gameId]/end.tsx @@ -56,7 +56,9 @@ export default function End() { const isDead = playerEntity?.health === 0; - const turnRemaining = isDead ? playerEntity?.turnsRemainingOnDeath: playerEntity?.turnsRemaining + const turnRemaining = isDead + ? playerEntity?.turnsRemainingOnDeath + : playerEntity?.turnsRemaining; const day = (gameEntity?.maxTurns || 1_000) - (turnRemaining || 0); const onSubmitName = useCallback(async () => { @@ -132,7 +134,7 @@ export default function End() { > Credits - + */} + + + + From 770bbbbe79521c47afb7887e27a1c8ad190591a4 Mon Sep 17 00:00:00 2001 From: broody Date: Mon, 18 Sep 2023 16:16:25 -0700 Subject: [PATCH 3/4] remove debugger and unused constant --- src/constants.cairo | 3 --- src/systems/decide.cairo | 2 +- web/src/dojo/systems/useSystems.tsx | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/constants.cairo b/src/constants.cairo index 383566b0b..3b64e52bb 100644 --- a/src/constants.cairo +++ b/src/constants.cairo @@ -9,9 +9,6 @@ const COPS_DRUG_THRESHOLD: usize = 5; // cops encounter threshold const HEALTH_IMPACT: u8 = 10; const GANGS_PAYMENT: usize = 20; -// consequences -const BASE_PAYMENT: u128 = 400_0000; // base payment is $400 - // starting stats const STARTING_CASH: u128 = 2000_0000; // $2000 const STARTING_BAG_LIMIT: usize = 100; // inventory size diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 1318ae1ac..9a447409d 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::{ COPS_DRUG_THRESHOLD,HEALTH_IMPACT,GANGS_PAYMENT,BASE_PAYMENT}; + use rollyourown::constants::{ COPS_DRUG_THRESHOLD,HEALTH_IMPACT,GANGS_PAYMENT}; use rollyourown::components::game::{Game, GameTrait}; use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; diff --git a/web/src/dojo/systems/useSystems.tsx b/web/src/dojo/systems/useSystems.tsx index 302f5619d..2fbf621d2 100644 --- a/web/src/dojo/systems/useSystems.tsx +++ b/web/src/dojo/systems/useSystems.tsx @@ -164,8 +164,7 @@ export const useSystems = (): SystemsInterface => { const setName = useCallback( async (gameId: string, playerName: string) => { // not working if name is number only - const name = shortString.encodeShortString(playerName); - debugger + const name = shortString.encodeShortString(playerName); const receipt = await executeAndReceipt("set_name", [gameId, name]); const hash = "transaction_hash" in receipt ? receipt.transaction_hash : ""; From f6034ff2dba1a8d094bdf6a4ae3cbf99c743899a Mon Sep 17 00:00:00 2001 From: broody Date: Mon, 18 Sep 2023 16:16:42 -0700 Subject: [PATCH 4/4] cairo format --- src/components/market.cairo | 4 ++-- src/systems/create.cairo | 8 ++++---- src/systems/decide.cairo | 12 ++++++------ src/systems/join.cairo | 4 +--- src/systems/set_name.cairo | 2 +- src/systems/travel.cairo | 3 +-- 6 files changed, 15 insertions(+), 18 deletions(-) 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/systems/create.cairo b/src/systems/create.cairo index 3b4bea39d..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::{ - 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; @@ -144,8 +143,9 @@ mod create_game { // emit game created emit!( - ctx.world, - GameCreated { game_id, creator: ctx.origin, start_time, max_players, max_turns } + ctx.world, GameCreated { + game_id, creator: ctx.origin, start_time, max_players, max_turns + } ); (game_id, ctx.origin) diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 9a447409d..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::{ COPS_DRUG_THRESHOLD,HEALTH_IMPACT,GANGS_PAYMENT}; + use rollyourown::constants::{COPS_DRUG_THRESHOLD, HEALTH_IMPACT, GANGS_PAYMENT}; use rollyourown::components::game::{Game, GameTrait}; use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; @@ -53,7 +53,7 @@ mod decide { cash_loss: u128 } - fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) { + fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) { let player_id = ctx.origin; let mut player = get!(ctx.world, (game_id, player_id).into(), Player); assert(player.status != PlayerStatus::Normal, 'player response not needed'); @@ -110,14 +110,14 @@ mod decide { emit!(ctx.world, Decision { game_id, player_id, action }); emit!( - ctx.world, - Consequence { game_id, player_id, outcome, health_loss, drug_loss, cash_loss } + ctx.world, Consequence { + game_id, player_id, outcome, health_loss, drug_loss, cash_loss + } ); } - - fn cops_payment(drug_count: u32) -> u128 { + fn cops_payment(drug_count: u32) -> u128 { if drug_count < COPS_DRUG_THRESHOLD + 20 { 1000_0000 // $1000 } else if drug_count < COPS_DRUG_THRESHOLD + 50 { diff --git a/src/systems/join.cairo b/src/systems/join.cairo index 320e901ea..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::{ - STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT - }; + use rollyourown::constants::{STARTING_CASH, STARTING_HEALTH, STARTING_BAG_LIMIT}; #[event] #[derive(Drop, starknet::Event)] 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 c82f37f67..1a39b9aa8 100644 --- a/src/systems/travel.cairo +++ b/src/systems/travel.cairo @@ -69,8 +69,7 @@ mod travel { set!(ctx.world, (player)); emit!( - ctx.world, - Traveled { + ctx.world, Traveled { game_id, player_id, from_location: player.location_id, to_location: next_location_id } );