diff --git a/client/src/boxes/CompoundsBox.tsx b/client/src/boxes/CompoundsBox.tsx index 1397b36..9d16800 100755 --- a/client/src/boxes/CompoundsBox.tsx +++ b/client/src/boxes/CompoundsBox.tsx @@ -12,6 +12,7 @@ const CompoundsBox = ({ resourcesAvailable, colonyId, }: deps.CompoundsBoxProps) => { + console.log('level', level); const [quantity, setQuantity] = deps.useState(1); const [, setShowTooltip] = deps.useState(true); const [costUpdate, setCostUpdate] = deps.useState({ @@ -23,7 +24,6 @@ const CompoundsBox = ({ const { setup: { systemCalls: { upgradeCompound }, - // clientComponents: { GameOwnerPlanet }, }, account, } = useDojo(); @@ -148,13 +148,6 @@ const CompoundsBox = ({ /> - - ); + return boxContent; }; export default DefencesBox; diff --git a/client/src/boxes/DockyardBox.tsx b/client/src/boxes/DockyardBox.tsx index 6de213c..17a53a5 100755 --- a/client/src/boxes/DockyardBox.tsx +++ b/client/src/boxes/DockyardBox.tsx @@ -151,13 +151,6 @@ const DockyardBox = ({ /> - { - const [quantity, setQuantity] = useState(1); - const [showTooltip, setShowTooltip] = useState(true); + resources, +}: deps.LabBoxProps) => { + const [quantity, setQuantity] = deps.useState(1); + const [showTooltip, setShowTooltip] = deps.useState(true); + const { + setup: { + systemCalls: { upgradeTech }, + }, + account, + } = useDojo(); - const { tx, writeAsync: upgrade } = useTechUpgrade( - functionCallName, - quantity - ); + const upgrade = () => + upgradeTech(account.account, functionCallName, quantity); - const baseCosts = baseTechCost[functionCallName]; + const baseCosts = deps.baseTechCost[functionCallName as number]; const isExo = functionCallName === 18; // Calculate the cumulative cost of the upgrade - const upgradeCost = useMemo(() => { + const upgradeCost = deps.useMemo(() => { if (quantity > 0 && level != undefined) { - const cost = getCumulativeTechCost( + const cost = deps.getCumulativeTechCost( level, quantity, baseCosts.steel, @@ -53,12 +41,9 @@ const ResearchBox = ({ return { steel: 0, quartz: 0, tritium: 0 }; }, [level, quantity, baseCosts, isExo]); - const hasEnoughResources = calculEnoughResources( - upgradeCost, - resourcesAvailable - ); + const hasEnoughResources = deps.calculEnoughResources(upgradeCost, resources); - const buttonState = useMemo((): ButtonState => { + const buttonState = deps.useMemo((): deps.ButtonState => { if (!requirementsMet) { return 'noRequirements'; } else if (!hasEnoughResources) { @@ -81,9 +66,9 @@ const ResearchBox = ({ ].includes(title) && showTooltip; const boxContent = ( - - - + + { setShowTooltip(false); }} @@ -91,60 +76,60 @@ const ResearchBox = ({ title={title} description={description} /> - - - {title} + + + {title} - - STAGE - {level} - - - STEEL - + STAGE + {level} + + + STEEL + - {numberWithCommas(upgradeCost.steel)} - - - - QUARTZ - + + + QUARTZ + - {numberWithCommas(upgradeCost.quartz)} - - - - TRITIUM - + + + TRITIUM + - {numberWithCommas(upgradeCost.tritium)} - - + {deps.numberWithCommas(upgradeCost.tritium)} + + - - - + + { @@ -159,32 +144,29 @@ const ResearchBox = ({ variant="soft" style={{ width: '80px' }} /> - - - - - + + + - - - + + + ); return shouldShowTooltip ? ( - + {boxContent} - + ) : ( boxContent ); diff --git a/client/src/boxes/deps.ts b/client/src/boxes/deps.ts index cc872a1..c086cf3 100644 --- a/client/src/boxes/deps.ts +++ b/client/src/boxes/deps.ts @@ -9,12 +9,10 @@ import { convertPositionToNumbers, } from '../shared/utils'; import DescriptionModal from '../components/modals/Description'; -import AddTransactionIcon from '../../multicall/AddTransactionIcon'; import { Resources } from '../hooks/usePlanetResources'; export type { Resources } from '../hooks/usePlanetResources'; -import { Compounds } from '../hooks/usePlanetCompounds'; export type { Compounds } from '../hooks/usePlanetCompounds'; import { Techs } from '../hooks/usePlanetTechs'; @@ -40,11 +38,7 @@ export { ButtonUpgrade } from '../components/ui/Button'; export { ButtonBuild } from '../components/ui/Button'; export { getCumulativeTechCost } from '../shared/utils/Formulas'; export { baseTechCost } from '../constants/costs'; -export { - type TechLevels, - type ShipsLevels, - type DefenceLevels, -} from '../shared/types'; +export { type ShipsLevels, type DefenceLevels } from '../shared/types'; export { getCompoundCost, getCumulativeEnergyChange, @@ -57,7 +51,6 @@ export { useState, useEffect, DescriptionModal, - AddTransactionIcon, Tooltip, Input, Styled, @@ -84,7 +77,7 @@ export interface CompoundsBoxProps { export interface LabBoxProps { img: string; title: string; - functionCallName: number; + functionCallName: BigNumberish; level?: number; requirementsMet?: boolean; description: ReactNode; @@ -95,7 +88,7 @@ export interface LabBoxProps { export interface DockyardBoxProps { img: string; title: string; - functionCallName: number; + functionCallName: BigNumberish; level?: number; costUpdate?: { steel: number; quartz: number; tritium: number }; hasEnoughResources?: boolean; @@ -108,11 +101,11 @@ export interface DockyardBoxProps { export interface DefenceBoxProps { img: string; title: string; - functionCallName: number; + functionCallName: BigNumberish; level?: number; costUpdate?: { steel: number; quartz: number; tritium: number }; - hasEnoughResources?: boolean; - requirementsMet?: boolean; + hasEnoughResources: boolean | number; + requirementsMet?: boolean | number; description: React.ReactNode; resourcesAvailable: Resources; colonyId: number; diff --git a/client/src/colony/ColonyDashboard.tsx b/client/src/colony/ColonyDashboard.tsx index a6ad3e4..d2494f9 100644 --- a/client/src/colony/ColonyDashboard.tsx +++ b/client/src/colony/ColonyDashboard.tsx @@ -1,12 +1,15 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import styled from 'styled-components'; // import { PlanetSection } from '../components/ui/PlanetSection'; -import { - useGetColonyCompounds, - useGetColonyDefences, - useGetColonyResources, import { ColonyResourcesSection } from './ColonyResourcesSection'; import { getBaseShipsCost } from '../constants/costs'; +import { useColonyCompounds } from '../hooks/useColonyCompounds'; +import { SystemCalls } from '../dojo/createSystemCalls'; +import { useDojo } from '../dojo/useDojo'; +import { useColonyResources } from '../hooks/useColonyResources'; +import { useColonyDefences } from '../hooks/useColonyDefences'; +import { useColonyShips } from '../hooks/useColonyShips'; +import { Resources } from '../hooks/usePlanetResources'; export const GameContainer = styled.div` display: grid; @@ -45,25 +48,45 @@ interface Props { } export default function ColonyDashboard({ planetId, colonyId }: Props) { - const compoundLevels = useGetColonyCompounds(planetId, colonyId); - const spendableResources = useSpendableResources(planetId); - const collectibleResource = useGetColonyResources(planetId, colonyId); - const defencesLevels = useGetColonyDefences(planetId, colonyId); - const shipsLevels = useGetColonyShips(planetId, colonyId); - const shipsCost = getBaseShipsCost(); - const celestia = defencesLevels ? Number(defencesLevels.celestia) : 0; + const [resources, setResources] = useState({ + steel: undefined, + quartz: undefined, + tritium: undefined, + }); + const { + setup: { + systemCalls: { getColonyResources }, + }, + } = useDojo(); + useEffect(() => { + getColonyResources(planetId, colonyId) + .then((res) => { + if (res) { + setResources(res); + } + }) + .catch((error) => { + console.error(error); + // Handle the error appropriately + }); + }, [planetId, colonyId]); + const compoundLevels = useColonyCompounds(planetId, colonyId); + + const defences = useColonyDefences(planetId, colonyId); + + const ships = useColonyShips(planetId, colonyId); + + const celestia = defences.celestia || 0; return ( ); } diff --git a/client/src/colony/ColonyResourcesSection.tsx b/client/src/colony/ColonyResourcesSection.tsx index 3681ac5..602b4cf 100644 --- a/client/src/colony/ColonyResourcesSection.tsx +++ b/client/src/colony/ColonyResourcesSection.tsx @@ -7,57 +7,47 @@ import { ResourcesTabs, ResourcesTabList, } from '../shared/styled/Tabs'; -import { - type CompoundsLevels, - type Resources, - type TechLevels, - type DefenceCost, - type DefenceLevels, - type ShipsLevels, - type ShipsCost, -} from '../shared/types'; +import { ColonyCompounds } from '../hooks/useColonyCompounds'; +import { Techs } from '../hooks/usePlanetTechs'; +import { Resources } from '../hooks/usePlanetResources'; +import { Fleet } from '../hooks/usePlanetShips'; +import { Defences } from '../hooks/usePlanetDefences'; +import { type DefenceCost, type ShipsCost } from '../shared/types'; import { Typography } from '@mui/material'; -import { getBaseDefenceCost } from '../constants/costs'; +import { getBaseDefenceCost, getBaseShipsCost } from '../constants/costs'; import { DefenceTabPanel } from '../panels/DefencesTab'; import { ColonyCompoundTabPanel } from './ColonyTab'; import RocketIcon from '@mui/icons-material/Rocket'; import { DockyardTabPanel } from '../panels/DockyardTab'; import { UniverseViewTabPanel } from '../panels/UniverseViewTab'; import { Explore } from '@mui/icons-material'; +import { usePlanetTechs } from '../hooks/usePlanetTechs'; interface ResourcesSectionArgs { planetId: number; colonyId: number; - spendableResources: Resources; - collectibleResource: Resources; - compoundsLevels: CompoundsLevels; - defencesLevels: DefenceLevels; - shipsLevels: ShipsLevels; - shipsCost: ShipsCost; - celestiaAvailable: number; + resources: Resources; + compounds: ColonyCompounds; + defences: Defences; + ships: Fleet; + celestia: number; } export const ColonyResourcesSection = ({ planetId, colonyId, - spendableResources, - collectibleResource, - compoundsLevels, - defencesLevels, - shipsLevels, - shipsCost, - celestiaAvailable, + resources, + compounds, + defences, + ships, + celestia, }: ResourcesSectionArgs) => { const [activeTab, setActiveTab] = useState(1); - const techLevels = useTechLevels(planetId); + const techLevels = usePlanetTechs(planetId); + const shipsCost = getBaseShipsCost(); const defencesCost = getBaseDefenceCost(); - if ( - !compoundsLevels || - !techLevels || - !spendableResources || - !collectibleResource - ) { + if (!compounds || !techLevels || !resources) { // Centered CircularProgress return (
@@ -140,24 +124,23 @@ export const ColonyResourcesSection = ({ - {activeTab === 1 && - renderCompounds(colonyId, totalResources, compoundsLevels)} + {activeTab === 1 && renderCompounds(colonyId, resources, compounds)} {activeTab === 2 && renderDockyardTab( - totalResources, - shipsLevels, + resources, + ships, shipsCost, - compoundsLevels.dockyard, + compounds.dockyard || 0, techLevels, - celestiaAvailable, + celestia, colonyId )} {activeTab === 3 && renderDefencesPanel( - totalResources, - defencesLevels, + resources, + defences, defencesCost, - compoundsLevels.dockyard, + compounds.dockyard || 0, techLevels, colonyId )} @@ -169,23 +152,23 @@ export const ColonyResourcesSection = ({ function renderCompounds( colonyId: number, spendable: Resources, - compounds: CompoundsLevels + compounds: ColonyCompounds ) { return ( ); } function renderDockyardTab( spendable: Resources, - ships: ShipsLevels, + ships: Fleet, shipCost: ShipsCost, dockyard: number, - techs: TechLevels, + techs: Techs, celestia: number, colonyId: number ) { @@ -204,10 +187,10 @@ function renderDockyardTab( function renderDefencesPanel( spendable: Resources, - defences: DefenceLevels, + defences: Defences, defencesCost: DefenceCost, dockyard: number, - techs: TechLevels, + techs: Techs, colonyId: number ) { return ( @@ -224,7 +207,7 @@ function renderDefencesPanel( function renderUniversePanel( planetId: number, - techLevels: TechLevels, + techLevels: Techs, colonyId: number ) { return ( diff --git a/client/src/colony/ColonyTab.tsx b/client/src/colony/ColonyTab.tsx index b2ad087..b169b41 100644 --- a/client/src/colony/ColonyTab.tsx +++ b/client/src/colony/ColonyTab.tsx @@ -5,13 +5,10 @@ import quartzImg from '../assets/gameElements/compounds/quartz4.webp'; import tritiumImg from '../assets/gameElements/compounds/tritium4.webp'; import energyImg from '../assets/gameElements/compounds/energy4.webp'; import dockyardImg from '../assets/gameElements/compounds/dockyard4.webp'; -import { - type CompoundsLevels, - type EnergyCost, - type Resources, - ColonyUpgradeType, -} from '../shared/types'; +import { ColonyCompounds } from '../hooks/useColonyCompounds'; +import { type EnergyCost, ColonyUpgradeType } from '../shared/types'; import CompoundsBox from '../boxes/CompoundsBox'; +import { Resources } from '../hooks/usePlanetResources'; import { EnergyPlantDescription, QuartzMineDescription, @@ -25,27 +22,25 @@ interface CompoundConfigType { img: string; title: string; functionCallName: number; - compoundName: keyof CompoundsLevels; + compoundName: keyof ColonyCompounds; energyKey: keyof EnergyCost; } interface Props { - spendableResources?: Resources; - compoundsLevels: CompoundsLevels; + resources?: Resources; + compounds: ColonyCompounds; colonyId: number; } export const ColonyCompoundTabPanel = ({ - spendableResources, - compoundsLevels, + resources, + compounds, colonyId, ...rest }: Props) => { const compoundsConfig: CompoundConfigType[] = [ { - description: ( - - ), + description: , img: steelImg, title: 'Steel Mine', functionCallName: ColonyUpgradeType.SteelMine, @@ -53,9 +48,7 @@ export const ColonyCompoundTabPanel = ({ energyKey: 'steel', }, { - description: ( - - ), + description: , img: quartzImg, title: 'Quartz Mine', functionCallName: ColonyUpgradeType.QuartzMine, @@ -63,11 +56,7 @@ export const ColonyCompoundTabPanel = ({ energyKey: 'quartz', }, { - description: ( - - ), + description: , img: tritiumImg, title: 'Tritium Mine', functionCallName: ColonyUpgradeType.TritiumMine, @@ -75,11 +64,7 @@ export const ColonyCompoundTabPanel = ({ energyKey: 'tritium', }, { - description: ( - - ), + description: , img: energyImg, title: 'Energy Plant', functionCallName: ColonyUpgradeType.EnergyPlant, @@ -87,9 +72,7 @@ export const ColonyCompoundTabPanel = ({ energyKey: 'energy', }, { - description: ( - - ), + description: , img: dockyardImg, title: 'Dockyard', functionCallName: ColonyUpgradeType.Dockyard, @@ -101,7 +84,7 @@ export const ColonyCompoundTabPanel = ({ return ( {compoundsConfig.map((compound) => { - const level = Number(compoundsLevels?.[compound.compoundName]); + const level = compounds[compound.compoundName] || 0; return ( ); diff --git a/client/src/components/buttons/ButtonAttackPlanet.tsx b/client/src/components/buttons/ButtonAttackPlanet.tsx index c97a3c5..4b515a1 100644 --- a/client/src/components/buttons/ButtonAttackPlanet.tsx +++ b/client/src/components/buttons/ButtonAttackPlanet.tsx @@ -17,8 +17,6 @@ import { type Position, MissionCategory, } from '../../shared/types'; -import useSendFleet from '../../hooks/writeHooks/useSendFleet'; -import { useGetActiveMissions } from '../../hooks/FleetHooks'; import { calculateTotalCargoCapacity, getDistance, @@ -27,7 +25,6 @@ import { getFuelConsumption, } from '../../shared/utils/FleetUtils'; import { convertSecondsToTime } from '../../shared/utils'; -import { TransactionStatus } from '../ui/TransactionStatus'; import { numberWithCommas } from '../../shared/utils'; import Slider from '@mui/material/Slider'; import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp'; @@ -184,7 +181,7 @@ function ButtonAttackPlanet({ const [isButtotClicked, setisButtotClicked] = useState(false); const [speed, setSpeed] = useState(100); - const missions = useGetActiveMissions(planetId); + // const missions = useGetActiveMissions(planetId); const isMissionLimitReached = missions && techs && missions.length === Number(techs.digital) + 1; @@ -231,21 +228,21 @@ function ButtonAttackPlanet({ setCargoCapacity(calculateTotalCargoCapacity(fleet)); }, [distance, fleet, ownPosition, speed, techs]); - const { writeAsync: attack, data: attackData } = useSendFleet( - fleet, - destinationPosition, - MissionCategory['Attack'], - speed, - colonyId - ); - - const { writeAsync: transport, data: transportData } = useSendFleet( - fleet, - destinationPosition, - MissionCategory['Transport'], - speed, - colonyId - ); + // const { writeAsync: attack, data: attackData } = useSendFleet( + // fleet, + // destinationPosition, + // MissionCategory['Attack'], + // speed, + // colonyId + // ); + + // const { writeAsync: transport, data: transportData } = useSendFleet( + // fleet, + // destinationPosition, + // MissionCategory['Transport'], + // speed, + // colonyId + // ); const ships = ['carrier', 'scraper', 'sparrow', 'frigate', 'armade']; @@ -458,16 +455,6 @@ function ButtonAttackPlanet({ - {isButtotClicked && ( - - )} ) : noRequirements ? ( - {isButtotClicked && ( - - )} ); } diff --git a/client/src/components/buttons/CollectResources.tsx b/client/src/components/buttons/CollectResources.tsx deleted file mode 100644 index 3aed870..0000000 --- a/client/src/components/buttons/CollectResources.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import React, { useState } from 'react'; -import { Box } from '@mui/material'; -import { styled } from '@mui/system'; -import { TransactionStatus } from '../ui/TransactionStatus'; -import { GAMEADDRESS } from '../../constants/addresses'; -import game from '../../constants/nogame.json'; -import { useContractWrite, useContract } from '@starknet-react/core'; -import { StyledButton } from '../../shared/styled/Button'; - -const StyledBox = styled(Box)(() => ({ - position: 'relative', - display: 'flex', - justifyContent: 'center', // center horizontally - alignItems: 'center', // center vertically -})); - -interface Props { - selectedColonyId: number; -} - -export function UseCollectResources({ selectedColonyId }: Props) { - const [isClicked, setIsClicked] = useState(false); - - const { contract } = useContract({ - abi: game.abi, - address: GAMEADDRESS, - }); - const { writeAsync: motherCollect, data: motherData } = useContractWrite({ - calls: [contract?.populateTransaction.collect_resources?.()], - }); - - const { writeAsync: colonyCollect, data: colonyData } = useContractWrite({ - calls: [ - contract?.populateTransaction.collect_colony_resources?.( - selectedColonyId - ), - ], - }); - - const handleMotherOnClick = () => { - void motherCollect(); - setIsClicked(true); - }; - - const handleColonyOnClick = () => { - void colonyCollect(); - setIsClicked(true); - }; - - return ( - <> - - - Collect Resources - - - {isClicked ? ( - - ) : ( - <> - )} - - ); -} diff --git a/client/src/components/buttons/GenerateColony.tsx b/client/src/components/buttons/GenerateColony.tsx index fb93470..94ff458 100644 --- a/client/src/components/buttons/GenerateColony.tsx +++ b/client/src/components/buttons/GenerateColony.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react'; import { Box } from '@mui/material'; import { styled } from '@mui/system'; -import { TransactionStatus } from '../ui/TransactionStatus'; import { StyledButton } from '../../shared/styled/Button'; import { useDojo } from '../../dojo/useDojo'; @@ -55,14 +54,6 @@ export function GenerateColony({ isActivated }: Props) { )} - {/* {isClicked ? ( - - ) : ( - <> - )} */} ); } diff --git a/client/src/components/modals/PlanetOverview.tsx b/client/src/components/modals/PlanetOverview.tsx index f80cca5..b0c73b2 100644 --- a/client/src/components/modals/PlanetOverview.tsx +++ b/client/src/components/modals/PlanetOverview.tsx @@ -10,17 +10,8 @@ import { type Resources, type ShipsLevels, } from '../../shared/types'; -import { - useSpendableResources, - useCollectibleResources, -} from '../../hooks/ResourcesHooks'; -import { useShipsLevels, useDefencesLevels } from '../../hooks/LevelsHooks'; import { getPlanetAndColonyIds, numberWithCommas } from '../../shared/utils'; -import { - useGetColonyResources, - useGetColonyDefences, -} from '../../hooks/ColoniesHooks'; -import { useGetColonyShips } from '../../hooks/ColoniesHooks'; +import { usePlanetShips } from '../../hooks/usePlanetShips'; export const StyledBox = styled(Box)({ fontWeight: 400, @@ -127,7 +118,7 @@ export default function PlanetModal({ planetId, image, position }: Props) { const collectibleResources = useCollectibleResources(Number(planetId)); const [planet, colony] = getPlanetAndColonyIds(planetId); - const shipsLevels = useShipsLevels(Number(planetId)); + const shipsLevels = usePlanetShips(planetId); const colonyShips = useGetColonyShips(planet, colony); const actualShips = colonyShips && shipsLevels && colony === 0 ? shipsLevels : colonyShips; diff --git a/client/src/components/ui/Button.tsx b/client/src/components/ui/Button.tsx index 6ae61b1..5bb88b6 100644 --- a/client/src/components/ui/Button.tsx +++ b/client/src/components/ui/Button.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react'; import { StyledButton } from '../../shared/styled/Button'; -import { TransactionStatus } from './TransactionStatus'; -// import { InvokeFunctionResponse } from "starknet"; + interface Props { name: string; callback?: () => void; @@ -37,7 +36,6 @@ export function ButtonUpgrade({ Upgrade )} - {isClicked ? : <>} {!disabled && noRequirements && ( )} - {isClicked ? : <>} {!disabled && noRequirements && ( { - // Type guard to check if data is of the type with 'finality_status' - if (data && 'finality_status' in data) { - // Now TypeScript knows 'finality_status' is a valid property - if (data.finality_status === 'ACCEPTED_ON_L2') { - setTransactionSuccess(true); - } - } - }, [data]); - - const handleModalClose = () => { - setShowModal(false); - }; - - const loadingBody = ( -
- - - {name} Tx is being submitted - -
- -
-
-
- ); - - const successBody = ( -
- - - {name} Tx Accepted On L2 - -
- -
- {/* Additional message about potential delay in data update */} -
- Note: The displayed data might take several seconds to update. Try - refreshing the page in a few minutes. -
-
-
- ); - - return ( - <> - {showModal && ( - - {isLoading || !transactionSuccess ? loadingBody : successBody} - - )} - - ); -} diff --git a/client/src/dojo/createSystemCalls.ts b/client/src/dojo/createSystemCalls.ts index 9dc7891..b37992b 100644 --- a/client/src/dojo/createSystemCalls.ts +++ b/client/src/dojo/createSystemCalls.ts @@ -12,6 +12,7 @@ import { DojoProvider } from '@dojoengine/core'; import { GenerateColony } from '../components/buttons/GenerateColony'; import { getBaseDefenceCost } from '../constants/costs'; import { CompoundsCostUpgrade } from '../shared/types'; +import { Resources } from '../hooks/usePlanetResources'; export type SystemCalls = ReturnType; @@ -90,6 +91,32 @@ export function createSystemCalls( } }; + const upgradeTech = async ( + account: Account, + component: BigNumberish, + quantity: number + ) => { + try { + const { transaction_hash } = await provider.execute( + account, + 'techactions', + 'process_upgrade', + [component, quantity] + ); + + setComponentsFromEvents( + contractComponents, + getEvents( + await account.waitForTransaction(transaction_hash, { + retryInterval: 100, + }) + ) + ); + } catch (e) { + console.log(e); + } + }; + const buildShip = async ( account: Account, component: BigNumberish, @@ -142,11 +169,45 @@ export function createSystemCalls( } }; + const getPlanetResources = async (planetId: number) => { + try { + const tx = await provider.call( + 'planetactions', + 'get_resources_available', + [planetId] + ); + return tx.result[0]; + } catch (e) { + console.log(e); + } + }; + + const getColonyResources = async (planetId: number, colonyId: number) => { + try { + const tx = await provider.call( + 'colonyactions', + 'get_resources_available', + [planetId, colonyId] + ); + + return { + steel: parseInt(tx.result[0]), + quartz: parseInt(tx.result[1]), + tritium: parseInt(tx.result[2]), + }; + } catch (e) { + console.log(e); + } + }; + return { generatePlanet, generateColony, upgradeCompound, + upgradeTech, buildShip, buildDefence, + getPlanetResources, + getColonyResources, }; } diff --git a/client/src/generated/graphql.ts b/client/src/generated/graphql.ts index 9d71098..0870f2b 100644 --- a/client/src/generated/graphql.ts +++ b/client/src/generated/graphql.ts @@ -1,44 +1,31 @@ import { GraphQLClient, RequestOptions } from 'graphql-request'; -import { GraphQLError, print } from 'graphql'; +import { GraphQLError, print } from 'graphql' import gql from 'graphql-tag'; 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 MakeEmpty< - T extends { [key: string]: unknown }, - K extends keyof T -> = { [_ in K]?: never }; -export type Incremental = - | T - | { - [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never; - }; +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 MakeEmpty = { [_ in K]?: never }; +export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; type GraphQLClientRequestHeaders = RequestOptions['requestHeaders']; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: { input: string; output: string }; - String: { input: string; output: string }; - Boolean: { input: boolean; output: boolean }; - Int: { input: number; output: number }; - Float: { input: number; output: number }; - ContractAddress: { input: any; output: any }; - Cursor: { input: any; output: any }; - DateTime: { input: any; output: any }; - felt252: { input: any; output: any }; - u8: { input: any; output: any }; - u16: { input: any; output: any }; - u32: { input: any; output: any }; - u64: { input: any; output: any }; - u128: { input: any; output: any }; - usize: { input: any; output: any }; + ID: { input: string; output: string; } + String: { input: string; output: string; } + Boolean: { input: boolean; output: boolean; } + Int: { input: number; output: number; } + Float: { input: number; output: number; } + ContractAddress: { input: any; output: any; } + Cursor: { input: any; output: any; } + DateTime: { input: any; output: any; } + felt252: { input: any; output: any; } + u8: { input: any; output: any; } + u16: { input: any; output: any; } + u32: { input: any; output: any; } + u64: { input: any; output: any; } + u128: { input: any; output: any; } + usize: { input: any; output: any; } }; export type ActiveMission = { @@ -89,7 +76,7 @@ export type ActiveMissionLenOrder = { export enum ActiveMissionLenOrderField { Lenght = 'LENGHT', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ActiveMissionLenWhereInput = { @@ -117,7 +104,7 @@ export type ActiveMissionOrder = { export enum ActiveMissionOrderField { Mission = 'MISSION', MissionId = 'MISSION_ID', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ActiveMissionWhereInput = { @@ -188,7 +175,7 @@ export enum ColonyCompoundsOrderField { ColonyId = 'COLONY_ID', Level = 'LEVEL', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ColonyCompoundsWhereInput = { @@ -249,7 +236,7 @@ export type ColonyCountOrder = { export enum ColonyCountOrderField { Count = 'COUNT', - GameId = 'GAME_ID', + GameId = 'GAME_ID' } export type ColonyCountWhereInput = { @@ -300,7 +287,7 @@ export enum ColonyDefencesOrderField { ColonyId = 'COLONY_ID', Count = 'COUNT', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ColonyDefencesWhereInput = { @@ -361,7 +348,7 @@ export type ColonyOwnerOrder = { export enum ColonyOwnerOrderField { ColonyPlanetId = 'COLONY_PLANET_ID', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ColonyOwnerWhereInput = { @@ -410,7 +397,7 @@ export type ColonyPositionOrder = { export enum ColonyPositionOrderField { ColonyId = 'COLONY_ID', PlanetId = 'PLANET_ID', - Position = 'POSITION', + Position = 'POSITION' } export type ColonyPositionWhereInput = { @@ -467,7 +454,7 @@ export enum ColonyResourceOrderField { Amount = 'AMOUNT', ColonyId = 'COLONY_ID', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ColonyResourceTimer = { @@ -499,7 +486,7 @@ export type ColonyResourceTimerOrder = { export enum ColonyResourceTimerOrderField { ColonyId = 'COLONY_ID', LastCollection = 'LAST_COLLECTION', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ColonyResourceTimerWhereInput = { @@ -588,7 +575,7 @@ export enum ColonyShipsOrderField { ColonyId = 'COLONY_ID', Count = 'COUNT', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type ColonyShipsWhereInput = { @@ -649,7 +636,7 @@ export type GameOwnerPlanetOrder = { export enum GameOwnerPlanetOrderField { Owner = 'OWNER', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type GameOwnerPlanetWhereInput = { @@ -710,7 +697,7 @@ export type GamePlanetCountOrder = { export enum GamePlanetCountOrderField { Count = 'COUNT', - GameId = 'GAME_ID', + GameId = 'GAME_ID' } export type GamePlanetCountWhereInput = { @@ -743,7 +730,7 @@ export type GamePlanetOrder = { export enum GamePlanetOrderField { Owner = 'OWNER', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type GamePlanetOwner = { @@ -773,7 +760,7 @@ export type GamePlanetOwnerOrder = { export enum GamePlanetOwnerOrderField { Owner = 'OWNER', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type GamePlanetOwnerWhereInput = { @@ -839,7 +826,7 @@ export type GameSetupOrder = { export enum GameSetupOrderField { GameId = 'GAME_ID', Speed = 'SPEED', - StartTime = 'START_TIME', + StartTime = 'START_TIME' } export type GameSetupWhereInput = { @@ -893,7 +880,7 @@ export type IncomingMissionLenOrder = { export enum IncomingMissionLenOrderField { Lenght = 'LENGHT', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type IncomingMissionLenWhereInput = { @@ -942,7 +929,7 @@ export type IncomingMissionsOrder = { export enum IncomingMissionsOrderField { Mission = 'MISSION', MissionId = 'MISSION_ID', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type IncomingMissionsWhereInput = { @@ -998,7 +985,7 @@ export type LastActiveOrder = { export enum LastActiveOrderField { PlanetId = 'PLANET_ID', - Time = 'TIME', + Time = 'TIME' } export type LastActiveWhereInput = { @@ -1018,40 +1005,11 @@ export type LastActiveWhereInput = { timeNEQ?: InputMaybe; }; -export type ModelUnion = - | ActiveMission - | ActiveMissionLen - | ColonyCompounds - | ColonyCount - | ColonyDefences - | ColonyOwner - | ColonyPosition - | ColonyResource - | ColonyResourceTimer - | ColonyShips - | GameOwnerPlanet - | GamePlanet - | GamePlanetCount - | GamePlanetOwner - | GameSetup - | IncomingMissionLen - | IncomingMissions - | LastActive - | PlanetColoniesCount - | PlanetCompounds - | PlanetDebrisField - | PlanetDefences - | PlanetPosition - | PlanetResource - | PlanetResourceTimer - | PlanetResourcesSpent - | PlanetShips - | PlanetTechs - | PositionToPlanet; +export type ModelUnion = ActiveMission | ActiveMissionLen | ColonyCompounds | ColonyCount | ColonyDefences | ColonyOwner | ColonyPosition | ColonyResource | ColonyResourceTimer | ColonyShips | GameOwnerPlanet | GamePlanet | GamePlanetCount | GamePlanetOwner | GameSetup | IncomingMissionLen | IncomingMissions | LastActive | PlanetColoniesCount | PlanetCompounds | PlanetDebrisField | PlanetDefences | PlanetPosition | PlanetResource | PlanetResourceTimer | PlanetResourcesSpent | PlanetShips | PlanetTechs | PositionToPlanet; export enum OrderDirection { Asc = 'ASC', - Desc = 'DESC', + Desc = 'DESC' } export type PlanetColoniesCount = { @@ -1081,7 +1039,7 @@ export type PlanetColoniesCountOrder = { export enum PlanetColoniesCountOrderField { Count = 'COUNT', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetColoniesCountWhereInput = { @@ -1130,7 +1088,7 @@ export type PlanetCompoundsOrder = { export enum PlanetCompoundsOrderField { Level = 'LEVEL', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetCompoundsWhereInput = { @@ -1184,7 +1142,7 @@ export type PlanetDebrisFieldOrder = { export enum PlanetDebrisFieldOrderField { Debris = 'DEBRIS', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetDebrisFieldWhereInput = { @@ -1232,7 +1190,7 @@ export type PlanetDefencesOrder = { export enum PlanetDefencesOrderField { Count = 'COUNT', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetDefencesWhereInput = { @@ -1286,7 +1244,7 @@ export type PlanetPositionOrder = { export enum PlanetPositionOrderField { PlanetId = 'PLANET_ID', - Position = 'POSITION', + Position = 'POSITION' } export type PlanetPositionWhereInput = { @@ -1334,7 +1292,7 @@ export type PlanetResourceOrder = { export enum PlanetResourceOrderField { Amount = 'AMOUNT', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetResourceTimer = { @@ -1364,7 +1322,7 @@ export type PlanetResourceTimerOrder = { export enum PlanetResourceTimerOrderField { LastCollection = 'LAST_COLLECTION', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetResourceTimerWhereInput = { @@ -1435,7 +1393,7 @@ export type PlanetResourcesSpentOrder = { export enum PlanetResourcesSpentOrderField { PlanetId = 'PLANET_ID', - Spent = 'SPENT', + Spent = 'SPENT' } export type PlanetResourcesSpentWhereInput = { @@ -1484,7 +1442,7 @@ export type PlanetShipsOrder = { export enum PlanetShipsOrderField { Count = 'COUNT', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetShipsWhereInput = { @@ -1540,7 +1498,7 @@ export type PlanetTechsOrder = { export enum PlanetTechsOrderField { Level = 'LEVEL', Name = 'NAME', - PlanetId = 'PLANET_ID', + PlanetId = 'PLANET_ID' } export type PlanetTechsWhereInput = { @@ -1594,7 +1552,7 @@ export type PositionToPlanetOrder = { export enum PositionToPlanetOrderField { PlanetId = 'PLANET_ID', - Position = 'POSITION', + Position = 'POSITION' } export type PositionToPlanetWhereInput = { @@ -1722,7 +1680,7 @@ export type World__ModelOrder = { export enum World__ModelOrderField { ClassHash = 'CLASS_HASH', - Name = 'NAME', + Name = 'NAME' } export type World__PageInfo = { @@ -1774,6 +1732,7 @@ export type World__Query = { transactions?: Maybe; }; + export type World__QueryActiveMissionLenModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1785,6 +1744,7 @@ export type World__QueryActiveMissionLenModelsArgs = { where?: InputMaybe; }; + export type World__QueryActiveMissionModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1796,6 +1756,7 @@ export type World__QueryActiveMissionModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyCompoundsModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1807,6 +1768,7 @@ export type World__QueryColonyCompoundsModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyCountModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1818,6 +1780,7 @@ export type World__QueryColonyCountModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyDefencesModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1829,6 +1792,7 @@ export type World__QueryColonyDefencesModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyOwnerModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1840,6 +1804,7 @@ export type World__QueryColonyOwnerModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyPositionModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1851,6 +1816,7 @@ export type World__QueryColonyPositionModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyResourceModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1862,6 +1828,7 @@ export type World__QueryColonyResourceModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyResourceTimerModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1873,6 +1840,7 @@ export type World__QueryColonyResourceTimerModelsArgs = { where?: InputMaybe; }; + export type World__QueryColonyShipsModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1884,6 +1852,7 @@ export type World__QueryColonyShipsModelsArgs = { where?: InputMaybe; }; + export type World__QueryEntitiesArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1894,10 +1863,12 @@ export type World__QueryEntitiesArgs = { offset?: InputMaybe; }; + export type World__QueryEntityArgs = { id: Scalars['ID']['input']; }; + export type World__QueryEventsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1908,6 +1879,7 @@ export type World__QueryEventsArgs = { offset?: InputMaybe; }; + export type World__QueryGameOwnerPlanetModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1919,6 +1891,7 @@ export type World__QueryGameOwnerPlanetModelsArgs = { where?: InputMaybe; }; + export type World__QueryGamePlanetCountModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1930,6 +1903,7 @@ export type World__QueryGamePlanetCountModelsArgs = { where?: InputMaybe; }; + export type World__QueryGamePlanetModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1941,6 +1915,7 @@ export type World__QueryGamePlanetModelsArgs = { where?: InputMaybe; }; + export type World__QueryGamePlanetOwnerModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1952,6 +1927,7 @@ export type World__QueryGamePlanetOwnerModelsArgs = { where?: InputMaybe; }; + export type World__QueryGameSetupModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1963,6 +1939,7 @@ export type World__QueryGameSetupModelsArgs = { where?: InputMaybe; }; + export type World__QueryIncomingMissionLenModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1974,6 +1951,7 @@ export type World__QueryIncomingMissionLenModelsArgs = { where?: InputMaybe; }; + export type World__QueryIncomingMissionsModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1985,6 +1963,7 @@ export type World__QueryIncomingMissionsModelsArgs = { where?: InputMaybe; }; + export type World__QueryLastActiveModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -1996,6 +1975,7 @@ export type World__QueryLastActiveModelsArgs = { where?: InputMaybe; }; + export type World__QueryMetadatasArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2005,10 +1985,12 @@ export type World__QueryMetadatasArgs = { offset?: InputMaybe; }; + export type World__QueryModelArgs = { id: Scalars['ID']['input']; }; + export type World__QueryModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2019,6 +2001,7 @@ export type World__QueryModelsArgs = { order?: InputMaybe; }; + export type World__QueryPlanetColoniesCountModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2030,6 +2013,7 @@ export type World__QueryPlanetColoniesCountModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetCompoundsModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2041,6 +2025,7 @@ export type World__QueryPlanetCompoundsModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetDebrisFieldModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2052,6 +2037,7 @@ export type World__QueryPlanetDebrisFieldModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetDefencesModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2063,6 +2049,7 @@ export type World__QueryPlanetDefencesModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetPositionModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2074,6 +2061,7 @@ export type World__QueryPlanetPositionModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetResourceModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2085,6 +2073,7 @@ export type World__QueryPlanetResourceModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetResourceTimerModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2096,6 +2085,7 @@ export type World__QueryPlanetResourceTimerModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetResourcesSpentModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2107,6 +2097,7 @@ export type World__QueryPlanetResourcesSpentModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetShipsModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2118,6 +2109,7 @@ export type World__QueryPlanetShipsModelsArgs = { where?: InputMaybe; }; + export type World__QueryPlanetTechsModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2129,6 +2121,7 @@ export type World__QueryPlanetTechsModelsArgs = { where?: InputMaybe; }; + export type World__QueryPositionToPlanetModelsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2140,10 +2133,12 @@ export type World__QueryPositionToPlanetModelsArgs = { where?: InputMaybe; }; + export type World__QueryTransactionArgs = { transactionHash: Scalars['ID']['input']; }; + export type World__QueryTransactionsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -2166,14 +2161,17 @@ export type World__Subscription = { modelRegistered: World__Model; }; + export type World__SubscriptionEntityUpdatedArgs = { id?: InputMaybe; }; + export type World__SubscriptionEventEmittedArgs = { keys?: InputMaybe>>; }; + export type World__SubscriptionModelRegisteredArgs = { id?: InputMaybe; }; @@ -2208,356 +2206,47 @@ export type GetPlanetResourceQueryVariables = Exact<{ name: Scalars['u8']['input']; }>; -export type GetPlanetResourceQuery = { - __typename?: 'World__Query'; - planetResourceModels?: { - __typename?: 'PlanetResourceConnection'; - edges?: Array<{ - __typename?: 'PlanetResourceEdge'; - node?: { - __typename?: 'PlanetResource'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { - __typename: 'PlanetResource'; - planet_id?: any | null; - name?: any | null; - amount?: any | null; - } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetResourceQuery = { __typename?: 'World__Query', planetResourceModels?: { __typename?: 'PlanetResourceConnection', edges?: Array<{ __typename?: 'PlanetResourceEdge', node?: { __typename?: 'PlanetResource', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource', planet_id?: any | null, name?: any | null, amount?: any | null } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetPlanetCompoundQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; name: Scalars['u8']['input']; }>; -export type GetPlanetCompoundQuery = { - __typename?: 'World__Query'; - planetCompoundsModels?: { - __typename?: 'PlanetCompoundsConnection'; - edges?: Array<{ - __typename?: 'PlanetCompoundsEdge'; - node?: { - __typename?: 'PlanetCompounds'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { - __typename: 'PlanetCompounds'; - planet_id?: any | null; - name?: any | null; - level?: any | null; - } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetCompoundQuery = { __typename?: 'World__Query', planetCompoundsModels?: { __typename?: 'PlanetCompoundsConnection', edges?: Array<{ __typename?: 'PlanetCompoundsEdge', node?: { __typename?: 'PlanetCompounds', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds', planet_id?: any | null, name?: any | null, level?: any | null } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetPlanetTechQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; name: Scalars['u8']['input']; }>; -export type GetPlanetTechQuery = { - __typename?: 'World__Query'; - planetTechsModels?: { - __typename?: 'PlanetTechsConnection'; - edges?: Array<{ - __typename?: 'PlanetTechsEdge'; - node?: { - __typename?: 'PlanetTechs'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { - __typename: 'PlanetTechs'; - planet_id?: any | null; - name?: any | null; - level?: any | null; - } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetTechQuery = { __typename?: 'World__Query', planetTechsModels?: { __typename?: 'PlanetTechsConnection', edges?: Array<{ __typename?: 'PlanetTechsEdge', node?: { __typename?: 'PlanetTechs', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs', planet_id?: any | null, name?: any | null, level?: any | null } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetPlanetPositionQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; }>; -export type GetPlanetPositionQuery = { - __typename?: 'World__Query'; - planetPositionModels?: { - __typename?: 'PlanetPositionConnection'; - edges?: Array<{ - __typename?: 'PlanetPositionEdge'; - node?: { - __typename?: 'PlanetPosition'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { - __typename: 'PlanetPosition'; - planet_id?: any | null; - position?: { - __typename?: 'PlanetPosition_Position'; - system?: any | null; - orbit?: any | null; - } | null; - } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetPositionQuery = { __typename?: 'World__Query', planetPositionModels?: { __typename?: 'PlanetPositionConnection', edges?: Array<{ __typename?: 'PlanetPositionEdge', node?: { __typename?: 'PlanetPosition', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition', planet_id?: any | null, position?: { __typename?: 'PlanetPosition_Position', system?: any | null, orbit?: any | null } | null } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetPlanetShipQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; name: Scalars['u8']['input']; }>; -export type GetPlanetShipQuery = { - __typename?: 'World__Query'; - planetShipsModels?: { - __typename?: 'PlanetShipsConnection'; - edges?: Array<{ - __typename?: 'PlanetShipsEdge'; - node?: { - __typename?: 'PlanetShips'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { - __typename: 'PlanetShips'; - planet_id?: any | null; - name?: any | null; - count?: any | null; - } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetShipQuery = { __typename?: 'World__Query', planetShipsModels?: { __typename?: 'PlanetShipsConnection', edges?: Array<{ __typename?: 'PlanetShipsEdge', node?: { __typename?: 'PlanetShips', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips', planet_id?: any | null, name?: any | null, count?: any | null } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetPlanetDefenceQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; name: Scalars['u8']['input']; }>; -export type GetPlanetDefenceQuery = { - __typename?: 'World__Query'; - planetDefencesModels?: { - __typename?: 'PlanetDefencesConnection'; - edges?: Array<{ - __typename?: 'PlanetDefencesEdge'; - node?: { - __typename?: 'PlanetDefences'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { - __typename: 'PlanetDefences'; - planet_id?: any | null; - name?: any | null; - count?: any | null; - } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetDefenceQuery = { __typename?: 'World__Query', planetDefencesModels?: { __typename?: 'PlanetDefencesConnection', edges?: Array<{ __typename?: 'PlanetDefencesEdge', node?: { __typename?: 'PlanetDefences', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences', planet_id?: any | null, name?: any | null, count?: any | null } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetColonyResourceQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; @@ -2565,60 +2254,8 @@ export type GetColonyResourceQueryVariables = Exact<{ name: Scalars['u8']['input']; }>; -export type GetColonyResourceQuery = { - __typename?: 'World__Query'; - colonyResourceModels?: { - __typename?: 'ColonyResourceConnection'; - edges?: Array<{ - __typename?: 'ColonyResourceEdge'; - node?: { - __typename?: 'ColonyResource'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { - __typename: 'ColonyResource'; - planet_id?: any | null; - colony_id?: any | null; - name?: any | null; - amount?: any | null; - } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetColonyResourceQuery = { __typename?: 'World__Query', colonyResourceModels?: { __typename?: 'ColonyResourceConnection', edges?: Array<{ __typename?: 'ColonyResourceEdge', node?: { __typename?: 'ColonyResource', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource', planet_id?: any | null, colony_id?: any | null, name?: any | null, amount?: any | null } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetColonyCompoundQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; @@ -2626,60 +2263,17 @@ export type GetColonyCompoundQueryVariables = Exact<{ name: Scalars['u8']['input']; }>; -export type GetColonyCompoundQuery = { - __typename?: 'World__Query'; - colonyCompoundsModels?: { - __typename?: 'ColonyCompoundsConnection'; - edges?: Array<{ - __typename?: 'ColonyCompoundsEdge'; - node?: { - __typename?: 'ColonyCompounds'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { - __typename: 'ColonyCompounds'; - planet_id?: any | null; - colony_id?: any | null; - name?: any | null; - level?: any | null; - } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetColonyCompoundQuery = { __typename?: 'World__Query', colonyCompoundsModels?: { __typename?: 'ColonyCompoundsConnection', edges?: Array<{ __typename?: 'ColonyCompoundsEdge', node?: { __typename?: 'ColonyCompounds', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds', planet_id?: any | null, colony_id?: any | null, name?: any | null, level?: any | null } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; + +export type GetColonyShipQueryVariables = Exact<{ + planet_id: Scalars['u32']['input']; + colony_id: Scalars['u8']['input']; + name: Scalars['u8']['input']; +}>; + + +export type GetColonyShipQuery = { __typename?: 'World__Query', colonyShipsModels?: { __typename?: 'ColonyShipsConnection', edges?: Array<{ __typename?: 'ColonyShipsEdge', node?: { __typename?: 'ColonyShips', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips', planet_id?: any | null, colony_id?: any | null, name?: any | null, count?: any | null } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetColonyDefenceQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; @@ -2687,260 +2281,102 @@ export type GetColonyDefenceQueryVariables = Exact<{ name: Scalars['u8']['input']; }>; -export type GetColonyDefenceQuery = { - __typename?: 'World__Query'; - colonyDefencesModels?: { - __typename?: 'ColonyDefencesConnection'; - edges?: Array<{ - __typename?: 'ColonyDefencesEdge'; - node?: { - __typename?: 'ColonyDefences'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { - __typename: 'ColonyDefences'; - planet_id?: any | null; - colony_id?: any | null; - name?: any | null; - count?: any | null; - } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetColonyDefenceQuery = { __typename?: 'World__Query', colonyDefencesModels?: { __typename?: 'ColonyDefencesConnection', edges?: Array<{ __typename?: 'ColonyDefencesEdge', node?: { __typename?: 'ColonyDefences', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences', planet_id?: any | null, colony_id?: any | null, name?: any | null, count?: any | null } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetPlanetColoniesCountQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; }>; -export type GetPlanetColoniesCountQuery = { - data: any; - __typename?: 'World__Query'; - planetColoniesCountModels?: { - __typename?: 'PlanetColoniesCountConnection'; - edges?: Array<{ - __typename?: 'PlanetColoniesCountEdge'; - node?: { - __typename?: 'PlanetColoniesCount'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { __typename: 'ColonyPosition' } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { - __typename: 'PlanetColoniesCount'; - planet_id?: any | null; - count?: any | null; - } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetPlanetColoniesCountQuery = { __typename?: 'World__Query', planetColoniesCountModels?: { __typename?: 'PlanetColoniesCountConnection', edges?: Array<{ __typename?: 'PlanetColoniesCountEdge', node?: { __typename?: 'PlanetColoniesCount', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition' } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount', planet_id?: any | null, count?: any | null } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; export type GetColonyPositionQueryVariables = Exact<{ planet_id: Scalars['u32']['input']; colony_id: Scalars['u8']['input']; }>; -export type GetColonyPositionQuery = { - __typename?: 'World__Query'; - colonyPositionModels?: { - __typename?: 'ColonyPositionConnection'; - edges?: Array<{ - __typename?: 'ColonyPositionEdge'; - node?: { - __typename?: 'ColonyPosition'; - entity?: { - __typename?: 'World__Entity'; - keys?: Array | null; - models?: Array< - | { __typename: 'ActiveMission' } - | { __typename: 'ActiveMissionLen' } - | { __typename: 'ColonyCompounds' } - | { __typename: 'ColonyCount' } - | { __typename: 'ColonyDefences' } - | { __typename: 'ColonyOwner' } - | { - __typename: 'ColonyPosition'; - planet_id?: any | null; - colony_id?: any | null; - position?: { - __typename?: 'ColonyPosition_Position'; - system?: any | null; - orbit?: any | null; - } | null; - } - | { __typename: 'ColonyResource' } - | { __typename: 'ColonyResourceTimer' } - | { __typename: 'ColonyShips' } - | { __typename: 'GameOwnerPlanet' } - | { __typename: 'GamePlanet' } - | { __typename: 'GamePlanetCount' } - | { __typename: 'GamePlanetOwner' } - | { __typename: 'GameSetup' } - | { __typename: 'IncomingMissionLen' } - | { __typename: 'IncomingMissions' } - | { __typename: 'LastActive' } - | { __typename: 'PlanetColoniesCount' } - | { __typename: 'PlanetCompounds' } - | { __typename: 'PlanetDebrisField' } - | { __typename: 'PlanetDefences' } - | { __typename: 'PlanetPosition' } - | { __typename: 'PlanetResource' } - | { __typename: 'PlanetResourceTimer' } - | { __typename: 'PlanetResourcesSpent' } - | { __typename: 'PlanetShips' } - | { __typename: 'PlanetTechs' } - | { __typename: 'PositionToPlanet' } - | null - > | null; - } | null; - } | null; - } | null> | null; - } | null; -}; + +export type GetColonyPositionQuery = { __typename?: 'World__Query', colonyPositionModels?: { __typename?: 'ColonyPositionConnection', edges?: Array<{ __typename?: 'ColonyPositionEdge', node?: { __typename?: 'ColonyPosition', entity?: { __typename?: 'World__Entity', keys?: Array | null, models?: Array<{ __typename: 'ActiveMission' } | { __typename: 'ActiveMissionLen' } | { __typename: 'ColonyCompounds' } | { __typename: 'ColonyCount' } | { __typename: 'ColonyDefences' } | { __typename: 'ColonyOwner' } | { __typename: 'ColonyPosition', planet_id?: any | null, colony_id?: any | null, position?: { __typename?: 'ColonyPosition_Position', system?: any | null, orbit?: any | null } | null } | { __typename: 'ColonyResource' } | { __typename: 'ColonyResourceTimer' } | { __typename: 'ColonyShips' } | { __typename: 'GameOwnerPlanet' } | { __typename: 'GamePlanet' } | { __typename: 'GamePlanetCount' } | { __typename: 'GamePlanetOwner' } | { __typename: 'GameSetup' } | { __typename: 'IncomingMissionLen' } | { __typename: 'IncomingMissions' } | { __typename: 'LastActive' } | { __typename: 'PlanetColoniesCount' } | { __typename: 'PlanetCompounds' } | { __typename: 'PlanetDebrisField' } | { __typename: 'PlanetDefences' } | { __typename: 'PlanetPosition' } | { __typename: 'PlanetResource' } | { __typename: 'PlanetResourceTimer' } | { __typename: 'PlanetResourcesSpent' } | { __typename: 'PlanetShips' } | { __typename: 'PlanetTechs' } | { __typename: 'PositionToPlanet' } | null> | null } | null } | null } | null> | null } | null }; + export const GetPlanetResourceDocument = gql` - query getPlanetResource($planet_id: u32!, $name: u8!) { - planetResourceModels(where: { planet_id: $planet_id, name: $name }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetResource { - planet_id - name - amount - } + query getPlanetResource($planet_id: u32!, $name: u8!) { + planetResourceModels(where: {planet_id: $planet_id, name: $name}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetResource { + planet_id + name + amount } } } } } } -`; +} + `; export const GetPlanetCompoundDocument = gql` - query getPlanetCompound($planet_id: u32!, $name: u8!) { - planetCompoundsModels(where: { planet_id: $planet_id, name: $name }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetCompounds { - planet_id - name - level - } + query getPlanetCompound($planet_id: u32!, $name: u8!) { + planetCompoundsModels(where: {planet_id: $planet_id, name: $name}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetCompounds { + planet_id + name + level } } } } } } -`; +} + `; export const GetPlanetTechDocument = gql` - query getPlanetTech($planet_id: u32!, $name: u8!) { - planetTechsModels(where: { planet_id: $planet_id, name: $name }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetTechs { - planet_id - name - level - } + query getPlanetTech($planet_id: u32!, $name: u8!) { + planetTechsModels(where: {planet_id: $planet_id, name: $name}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetTechs { + planet_id + name + level } } } } } } -`; +} + `; export const GetPlanetPositionDocument = gql` - query getPlanetPosition($planet_id: u32!) { - planetPositionModels(where: { planet_id: $planet_id }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetPosition { - planet_id - position { - system - orbit - } + query getPlanetPosition($planet_id: u32!) { + planetPositionModels(where: {planet_id: $planet_id}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetPosition { + planet_id + position { + system + orbit } } } @@ -2948,159 +2384,181 @@ export const GetPlanetPositionDocument = gql` } } } -`; +} + `; export const GetPlanetShipDocument = gql` - query getPlanetShip($planet_id: u32!, $name: u8!) { - planetShipsModels(where: { planet_id: $planet_id, name: $name }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetShips { - planet_id - name - count - } + query getPlanetShip($planet_id: u32!, $name: u8!) { + planetShipsModels(where: {planet_id: $planet_id, name: $name}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetShips { + planet_id + name + count } } } } } } -`; +} + `; export const GetPlanetDefenceDocument = gql` - query getPlanetDefence($planet_id: u32!, $name: u8!) { - planetDefencesModels(where: { planet_id: $planet_id, name: $name }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetDefences { - planet_id - name - count - } + query getPlanetDefence($planet_id: u32!, $name: u8!) { + planetDefencesModels(where: {planet_id: $planet_id, name: $name}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetDefences { + planet_id + name + count } } } } } } -`; +} + `; export const GetColonyResourceDocument = gql` - query getColonyResource($planet_id: u32!, $colony_id: u8!, $name: u8!) { - colonyResourceModels( - where: { planet_id: $planet_id, colony_id: $colony_id, name: $name } - ) { - edges { - node { - entity { - keys - models { - __typename - ... on ColonyResource { - planet_id - colony_id - name - amount - } + query getColonyResource($planet_id: u32!, $colony_id: u8!, $name: u8!) { + colonyResourceModels( + where: {planet_id: $planet_id, colony_id: $colony_id, name: $name} + ) { + edges { + node { + entity { + keys + models { + __typename + ... on ColonyResource { + planet_id + colony_id + name + amount } } } } } } -`; +} + `; export const GetColonyCompoundDocument = gql` - query getColonyCompound($planet_id: u32!, $colony_id: u8!, $name: u8!) { - colonyCompoundsModels( - where: { planet_id: $planet_id, colony_id: $colony_id, name: $name } - ) { - edges { - node { - entity { - keys - models { - __typename - ... on ColonyCompounds { - planet_id - colony_id - name - level - } + query getColonyCompound($planet_id: u32!, $colony_id: u8!, $name: u8!) { + colonyCompoundsModels( + where: {planet_id: $planet_id, colony_id: $colony_id, name: $name} + ) { + edges { + node { + entity { + keys + models { + __typename + ... on ColonyCompounds { + planet_id + colony_id + name + level } } } } } } -`; +} + `; +export const GetColonyShipDocument = gql` + query getColonyShip($planet_id: u32!, $colony_id: u8!, $name: u8!) { + colonyShipsModels( + where: {planet_id: $planet_id, colony_id: $colony_id, name: $name} + ) { + edges { + node { + entity { + keys + models { + __typename + ... on ColonyShips { + planet_id + colony_id + name + count + } + } + } + } + } + } +} + `; export const GetColonyDefenceDocument = gql` - query getColonyDefence($planet_id: u32!, $colony_id: u8!, $name: u8!) { - colonyDefencesModels( - where: { planet_id: $planet_id, colony_id: $colony_id, name: $name } - ) { - edges { - node { - entity { - keys - models { - __typename - ... on ColonyDefences { - planet_id - colony_id - name - count - } + query getColonyDefence($planet_id: u32!, $colony_id: u8!, $name: u8!) { + colonyDefencesModels( + where: {planet_id: $planet_id, colony_id: $colony_id, name: $name} + ) { + edges { + node { + entity { + keys + models { + __typename + ... on ColonyDefences { + planet_id + colony_id + name + count } } } } } } -`; +} + `; export const GetPlanetColoniesCountDocument = gql` - query getPlanetColoniesCount($planet_id: u32!) { - planetColoniesCountModels(where: { planet_id: $planet_id }) { - edges { - node { - entity { - keys - models { - __typename - ... on PlanetColoniesCount { - planet_id - count - } + query getPlanetColoniesCount($planet_id: u32!) { + planetColoniesCountModels(where: {planet_id: $planet_id}) { + edges { + node { + entity { + keys + models { + __typename + ... on PlanetColoniesCount { + planet_id + count } } } } } } -`; +} + `; export const GetColonyPositionDocument = gql` - query getColonyPosition($planet_id: u32!, $colony_id: u8!) { - colonyPositionModels( - where: { planet_id: $planet_id, colony_id: $colony_id } - ) { - edges { - node { - entity { - keys - models { - __typename - ... on ColonyPosition { - planet_id - colony_id - position { - system - orbit - } + query getColonyPosition($planet_id: u32!, $colony_id: u8!) { + colonyPositionModels(where: {planet_id: $planet_id, colony_id: $colony_id}) { + edges { + node { + entity { + keys + models { + __typename + ... on ColonyPosition { + planet_id + colony_id + position { + system + orbit } } } @@ -3108,21 +2566,13 @@ export const GetColonyPositionDocument = gql` } } } -`; - -export type SdkFunctionWrapper = ( - action: (requestHeaders?: Record) => Promise, - operationName: string, - operationType?: string, - variables?: any -) => Promise; - -const defaultWrapper: SdkFunctionWrapper = ( - action, - _operationName, - _operationType, - _variables -) => action(); +} + `; + +export type SdkFunctionWrapper = (action: (requestHeaders?:Record) => Promise, operationName: string, operationType?: string, variables?: any) => Promise; + + +const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action(); const GetPlanetResourceDocumentString = print(GetPlanetResourceDocument); const GetPlanetCompoundDocumentString = print(GetPlanetCompoundDocument); const GetPlanetTechDocumentString = print(GetPlanetTechDocument); @@ -3131,258 +2581,48 @@ const GetPlanetShipDocumentString = print(GetPlanetShipDocument); const GetPlanetDefenceDocumentString = print(GetPlanetDefenceDocument); const GetColonyResourceDocumentString = print(GetColonyResourceDocument); const GetColonyCompoundDocumentString = print(GetColonyCompoundDocument); +const GetColonyShipDocumentString = print(GetColonyShipDocument); const GetColonyDefenceDocumentString = print(GetColonyDefenceDocument); -const GetPlanetColoniesCountDocumentString = print( - GetPlanetColoniesCountDocument -); +const GetPlanetColoniesCountDocumentString = print(GetPlanetColoniesCountDocument); const GetColonyPositionDocumentString = print(GetColonyPositionDocument); -export function getSdk( - client: GraphQLClient, - withWrapper: SdkFunctionWrapper = defaultWrapper -) { +export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) { return { - getPlanetResource( - variables: GetPlanetResourceQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetResourceQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetResourceDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetResource', - 'query', - variables - ); + getPlanetResource(variables: GetPlanetResourceQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetResourceQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetResourceDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetResource', 'query', variables); }, - getPlanetCompound( - variables: GetPlanetCompoundQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetCompoundQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetCompoundDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetCompound', - 'query', - variables - ); + getPlanetCompound(variables: GetPlanetCompoundQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetCompoundQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetCompoundDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetCompound', 'query', variables); }, - getPlanetTech( - variables: GetPlanetTechQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetTechQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetTechDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetTech', - 'query', - variables - ); + getPlanetTech(variables: GetPlanetTechQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetTechQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetTechDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetTech', 'query', variables); }, - getPlanetPosition( - variables: GetPlanetPositionQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetPositionQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetPositionDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetPosition', - 'query', - variables - ); + getPlanetPosition(variables: GetPlanetPositionQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetPositionQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetPositionDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetPosition', 'query', variables); }, - getPlanetShip( - variables: GetPlanetShipQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetShipQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetShipDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetShip', - 'query', - variables - ); + getPlanetShip(variables: GetPlanetShipQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetShipQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetShipDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetShip', 'query', variables); }, - getPlanetDefence( - variables: GetPlanetDefenceQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetDefenceQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetDefenceDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetDefence', - 'query', - variables - ); + getPlanetDefence(variables: GetPlanetDefenceQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetDefenceQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetDefenceDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetDefence', 'query', variables); }, - getColonyResource( - variables: GetColonyResourceQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetColonyResourceQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetColonyResourceDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getColonyResource', - 'query', - variables - ); + getColonyResource(variables: GetColonyResourceQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetColonyResourceQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetColonyResourceDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getColonyResource', 'query', variables); }, - getColonyCompound( - variables: GetColonyCompoundQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetColonyCompoundQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetColonyCompoundDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getColonyCompound', - 'query', - variables - ); + getColonyCompound(variables: GetColonyCompoundQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetColonyCompoundQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetColonyCompoundDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getColonyCompound', 'query', variables); }, - getColonyDefence( - variables: GetColonyDefenceQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetColonyDefenceQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetColonyDefenceDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getColonyDefence', - 'query', - variables - ); + getColonyShip(variables: GetColonyShipQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetColonyShipQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetColonyShipDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getColonyShip', 'query', variables); }, - getPlanetColoniesCount( - variables: GetPlanetColoniesCountQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetPlanetColoniesCountQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetPlanetColoniesCountDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getPlanetColoniesCount', - 'query', - variables - ); + getColonyDefence(variables: GetColonyDefenceQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetColonyDefenceQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetColonyDefenceDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getColonyDefence', 'query', variables); }, - getColonyPosition( - variables: GetColonyPositionQueryVariables, - requestHeaders?: GraphQLClientRequestHeaders - ): Promise<{ - data: GetColonyPositionQuery; - errors?: GraphQLError[]; - extensions?: any; - headers: Headers; - status: number; - }> { - return withWrapper( - (wrappedRequestHeaders) => - client.rawRequest( - GetColonyPositionDocumentString, - variables, - { ...requestHeaders, ...wrappedRequestHeaders } - ), - 'getColonyPosition', - 'query', - variables - ); + getPlanetColoniesCount(variables: GetPlanetColoniesCountQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetPlanetColoniesCountQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetPlanetColoniesCountDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getPlanetColoniesCount', 'query', variables); }, + getColonyPosition(variables: GetColonyPositionQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: GetColonyPositionQuery; errors?: GraphQLError[]; extensions?: any; headers: Headers; status: number; }> { + return withWrapper((wrappedRequestHeaders) => client.rawRequest(GetColonyPositionDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getColonyPosition', 'query', variables); + } }; } -export type Sdk = ReturnType; +export type Sdk = ReturnType; \ No newline at end of file diff --git a/client/src/graphql/schema.graphql b/client/src/graphql/schema.graphql index a8e0149..034b696 100644 --- a/client/src/graphql/schema.graphql +++ b/client/src/graphql/schema.graphql @@ -166,6 +166,29 @@ query getColonyCompound($planet_id: u32!, $colony_id: u8!, $name: u8!) { } } +query getColonyShip($planet_id: u32!, $colony_id: u8!, $name: u8!) { + colonyShipsModels( + where: { planet_id: $planet_id, colony_id: $colony_id, name: $name } + ) { + edges { + node { + entity { + keys + models { + __typename + ... on ColonyShips { + planet_id + colony_id + name + count + } + } + } + } + } + } +} + query getColonyDefence($planet_id: u32!, $colony_id: u8!, $name: u8!) { colonyDefencesModels( where: { planet_id: $planet_id, colony_id: $colony_id, name: $name } diff --git a/client/src/hooks/useColonyCompounds.ts b/client/src/hooks/useColonyCompounds.ts index c60f3ff..5c381c3 100644 --- a/client/src/hooks/useColonyCompounds.ts +++ b/client/src/hooks/useColonyCompounds.ts @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { useDojo } from '../dojo/useDojo'; import * as Names from '../constants/names/Names'; -type ColonyCompounds = { +export type ColonyCompounds = { steel: number | undefined; quartz: number | undefined; tritium: number | undefined; diff --git a/client/src/hooks/useColonyDefences.ts b/client/src/hooks/useColonyDefences.ts index ba3c393..557d37a 100644 --- a/client/src/hooks/useColonyDefences.ts +++ b/client/src/hooks/useColonyDefences.ts @@ -1,14 +1,7 @@ import { useState, useEffect } from 'react'; import { useDojo } from '../dojo/useDojo'; import * as Names from '../constants/names/Names'; - -type Defences = { - celestia: number | undefined; - blaster: number | undefined; - beam: number | undefined; - astral: number | undefined; - plasma: number | undefined; -}; +import { Defences } from './usePlanetDefences'; export function useColonyDefences( planetId: number, diff --git a/client/src/hooks/useColonyShips.ts b/client/src/hooks/useColonyShips.ts new file mode 100644 index 0000000..983930f --- /dev/null +++ b/client/src/hooks/useColonyShips.ts @@ -0,0 +1,50 @@ +import { useState, useEffect } from 'react'; +import { useDojo } from '../dojo/useDojo'; +import * as Names from '../constants/names/Names'; +import { Fleet } from './usePlanetShips'; + +export function useColonyShips(planetId: number, colonyId: number): Fleet { + const [carrier, setCarrier] = useState(); + const [scraper, setScraper] = useState(); + const [sparrow, setSparrow] = useState(); + const [frigate, setFrigate] = useState(); + const [armade, setArmade] = useState(); + + const { + setup: { graphSdk }, + } = useDojo(); + + useEffect(() => { + async function fetchShipLevel( + shipName: string, + setter: React.Dispatch> + ) { + const response = await graphSdk.getColonyShip({ + planet_id: planetId, + colony_id: colonyId, + name: Names.Fleet[shipName as keyof typeof Names.Fleet], + }); + + const edges = response.data.colonyShipsModels?.edges; + const models = edges?.[0]?.node?.entity?.models; + if (models) { + const planetShip = models.find( + (model) => model?.__typename === 'PlanetShips' + ); + if (planetShip && 'count' in planetShip) { + const amountHex = planetShip.count; + const amountNumber = parseInt(amountHex, 16); + setter(amountNumber); + } + } + } + + fetchShipLevel('Carrier', setCarrier); + fetchShipLevel('Scraper', setScraper); + fetchShipLevel('Sparrow', setSparrow); + fetchShipLevel('Frigate', setFrigate); + fetchShipLevel('Armade', setArmade); + }, [graphSdk, planetId]); + + return { carrier, scraper, sparrow, frigate, armade }; +} diff --git a/client/src/panels/CompoundsTab.tsx b/client/src/panels/CompoundsTab.tsx index be4341e..822321d 100755 --- a/client/src/panels/CompoundsTab.tsx +++ b/client/src/panels/CompoundsTab.tsx @@ -71,7 +71,7 @@ export const CompoundsTabPanel = ({ return ( {compoundsConfig.map((compound) => { - const level = Number(compounds?.[compound.compoundName]); + const level = compounds[compound.compoundName] || 0; return ( { +}: deps.DefenceProps) => { const defencesConfig = [ { - description: , - img: blasterImg, + description: , + img: deps.blasterImg, title: 'Blaster', - functionCallName: BuildType.Blaster, - level: defenceLevels?.blaster, + functionCallName: deps.DefenceBuildType.blaster, + level: defences?.blaster, cost: defenceCost?.blaster, - requirements: blasterRequirements(dockyardLevel), + requirements: deps.blasterRequirements(dockyard), }, { - description: , - img: beamImg, + description: , + img: deps.beamImg, title: 'Beam', - functionCallName: BuildType.Beam, - level: defenceLevels?.beam, + functionCallName: deps.DefenceBuildType.beam, + level: defences?.beam, cost: defenceCost?.beam, - requirements: beamRequirements(dockyardLevel, techLevels), + requirements: deps.beamRequirements(dockyard, techs), }, { - description: , - img: astralLauncherImg, + description: , + img: deps.astralLauncherImg, title: 'Astral Launcher', - functionCallName: BuildType.Astral, - level: defenceLevels?.astral, + functionCallName: deps.DefenceBuildType.astral, + level: defences?.astral, cost: defenceCost?.astral, - requirements: astralRequirements(dockyardLevel, techLevels), + requirements: deps.astralRequirements(dockyard, techs), }, { - description: , - img: plasmaImg, + description: , + img: deps.plasmaImg, title: 'Plasma Projector', - functionCallName: BuildType.Plasma, - level: defenceLevels?.plasma, + functionCallName: deps.DefenceBuildType.plasma, + level: defences?.plasma, cost: defenceCost?.plasma, - requirements: plasmaRequirements(dockyardLevel, techLevels), + requirements: deps.plasmaRequirements(dockyard, techs), }, ]; return ( - + {defencesConfig.map((defence) => ( ))} - + ); }; diff --git a/client/src/panels/DockyardTab.tsx b/client/src/panels/DockyardTab.tsx index f61001d..3b1bbc1 100755 --- a/client/src/panels/DockyardTab.tsx +++ b/client/src/panels/DockyardTab.tsx @@ -1,101 +1,75 @@ import React from 'react'; import DockyardBox from '../boxes/DockyardBox'; import { ColonyBuildType } from '../shared/types/index'; -import { - ArmadeDescription, - BuildType, - CarrierDescription, - CelestiaDescription, - DockyardProps, - FrigateDescription, - ScraperDescription, - ShipConfigType, - SparrowDescription, - StyledTabPanel, - armadeImg, - armadeRequirements, - calculEnoughResources, - carrierImg, - carrierRequirements, - celestiaImg, - celestiaRequirements, - frigateImg, - frigateRequirements, - scraperImg, - scraperRequirements, - sparrowImg, - sparrowRequirements, -} from '.'; +import * as deps from '.'; export const DockyardTabPanel = ({ - spendableResources, - shipsLevels, + resources, + ships, shipsCost, - dockyardLevel, - techLevels, + dockyard, + techs, celestia, colonyId, ...rest -}: DockyardProps) => { - const shipsConfig: ShipConfigType[] = [ +}: deps.DockyardProps) => { + const shipsConfig: deps.ShipConfigType[] = [ { - description: , - img: carrierImg, + description: , + img: deps.carrierImg, title: 'Carrier', - functionCallName: - colonyId == 0 ? BuildType.Carrier : ColonyBuildType.Carrier, + functionCallName: deps.ShipBuildType.carrier, shipName: 'carrier', - requirements: carrierRequirements(dockyardLevel, techLevels), + requirements: deps.carrierRequirements(dockyard, techs), }, { - description: , - img: celestiaImg, + description: , + img: deps.celestiaImg, title: 'Celestia', - functionCallName: - colonyId == 0 ? BuildType.Celestia : ColonyBuildType.Celestia, + functionCallName: deps.DefenceBuildType.celestia, shipName: 'celestia', - requirements: celestiaRequirements(dockyardLevel, techLevels), + requirements: deps.celestiaRequirements(dockyard, techs), }, { - description: , - img: scraperImg, + description: , + img: deps.scraperImg, title: 'Scraper', functionCallName: - colonyId == 0 ? BuildType.Scraper : ColonyBuildType.Scraper, + colonyId == 0 ? deps.ShipBuildType.scraper : ColonyBuildType.Scraper, shipName: 'scraper', - requirements: scraperRequirements(dockyardLevel, techLevels), + requirements: deps.scraperRequirements(dockyard, techs), }, { - description: , - img: sparrowImg, + description: , + img: deps.sparrowImg, title: 'Sparrow', functionCallName: - colonyId == 0 ? BuildType.Sparrow : ColonyBuildType.Sparrow, + colonyId == 0 ? deps.ShipBuildType.sparrow : ColonyBuildType.Sparrow, shipName: 'sparrow', - requirements: sparrowRequirements(dockyardLevel, techLevels), + requirements: deps.sparrowRequirements(dockyard, techs), }, { - description: , - img: frigateImg, + description: , + img: deps.frigateImg, title: 'Frigate', functionCallName: - colonyId == 0 ? BuildType.Frigate : ColonyBuildType.Frigate, + colonyId == 0 ? deps.ShipBuildType.frigate : ColonyBuildType.Frigate, shipName: 'frigate', - requirements: frigateRequirements(dockyardLevel, techLevels), + requirements: deps.frigateRequirements(dockyard, techs), }, { - description: , - img: armadeImg, + description: , + img: deps.armadeImg, title: 'Armade', functionCallName: - colonyId == 0 ? BuildType.Armade : ColonyBuildType.Armade, + colonyId == 0 ? deps.ShipBuildType.armade : ColonyBuildType.Armade, shipName: 'armade', - requirements: armadeRequirements(dockyardLevel, techLevels), + requirements: deps.armadeRequirements(dockyard, techs), }, ]; return ( - + {shipsConfig.map((ship) => ( ))} diff --git a/client/src/panels/MainTabPanel.tsx b/client/src/panels/MainTabPanel.tsx index 05ef169..9dd0819 100755 --- a/client/src/panels/MainTabPanel.tsx +++ b/client/src/panels/MainTabPanel.tsx @@ -28,7 +28,7 @@ export const ResourcesSection = ({ if (selectedDestination !== null) { setActiveTab(5); // Set to Universe tab } - }, [selectedDestination]); + }, [selectedDestination, setActiveTab]); if (!compoundsLevels || !techLevels || !resources || !shipsLevels) { // Centered CircularProgress @@ -140,7 +140,7 @@ export const ResourcesSection = ({ techLevels, colonyId )} - {activeTab === 5 && renderUniversePanel(planetId, techLevels, colonyId)} + {/* {activeTab === 5 && renderUniversePanel(planetId, techLevels, colonyId)} */} ); }; @@ -166,7 +166,7 @@ function renderLabPanel( ) { return ( @@ -184,11 +184,11 @@ function renderDockyardTab( ) { return ( @@ -205,26 +205,26 @@ function renderDefencesPanel( ) { return ( ); } -function renderUniversePanel( - planetId: number, - techLevels: deps.Techs, - colonyId: number -) { - return ( - - ); -} +// function renderUniversePanel( +// planetId: number, +// techLevels: deps.Techs, +// colonyId: number +// ) { +// return ( +// +// ); +// } diff --git a/client/src/panels/ResearchTab.tsx b/client/src/panels/ResearchTab.tsx index 2129947..51f71b4 100755 --- a/client/src/panels/ResearchTab.tsx +++ b/client/src/panels/ResearchTab.tsx @@ -1,166 +1,122 @@ import React from 'react'; -import { - EnergyDescription, - energyTechImg, - ArmourDescription, - BeamDescription, - CombustionDescription, - ComputerDescription, - IonDescription, - PlasmaDescription, - ShieldDescription, - SpacetimeDescription, - StyledTabPanel, - ThrustDescription, - UpgradeType, - WarpDescription, - WeaponsDescription, - armourImg, - armourRequirements, - beamImg, - beamTechRequirements, - combustionImg, - combustionRequirements, - digitalImg, - digitalRequirements, - energyRequirements, - ionImg, - ionRequirements, - plasmaImg, - plasmaTechRequirements, - shieldImg, - shieldRequirements, - spacetimeImg, - spacetimeRequirements, - thrustImg, - thrustRequirements, - warpEnginImg, - warpRequirements, - weaponsImg, - weaponsRequirements, - LabProps, - ResearchConfigType, - ExoDescription, - exoImg, - exoRequirements, -} from '.'; +import * as deps from '.'; import ResearchBox from '../boxes/ResearchBox'; export const ResearchTabPanel = ({ - spendableResources, + resources, techLevels, labLevel, ...rest -}: LabProps) => { - const researchConfig: ResearchConfigType[] = [ +}: deps.LabProps) => { + const researchConfig: deps.ResearchConfigType[] = [ { - description: , - img: energyTechImg, + description: , + img: deps.energyTechImg, title: 'Energy Innovation', - functionCallName: UpgradeType.EnergyTech, + functionCallName: deps.TechUpgradeType.energy, techName: 'energy', - requirements: energyRequirements(labLevel), + requirements: deps.energyRequirements(labLevel), }, { - description: , - img: digitalImg, + description: , + img: deps.digitalImg, title: 'Digital Systems', - functionCallName: UpgradeType.Digital, + functionCallName: deps.TechUpgradeType.digital, techName: 'digital', - requirements: digitalRequirements(labLevel), + requirements: deps.digitalRequirements(labLevel), }, { - description: , - img: beamImg, + description: , + img: deps.beamImg, title: 'Beam Technology', - functionCallName: UpgradeType.BeamTech, + functionCallName: deps.TechUpgradeType.beam, techName: 'beam', - requirements: beamTechRequirements(labLevel, techLevels), + requirements: deps.beamTechRequirements(labLevel, techLevels), }, { - description: , - img: ionImg, + description: , + img: deps.ionImg, title: 'Ion Systems', - functionCallName: UpgradeType.Ion, + functionCallName: deps.TechUpgradeType.ion, techName: 'ion', - requirements: ionRequirements(labLevel, techLevels), + requirements: deps.ionRequirements(labLevel, techLevels), }, { - description: , - img: exoImg, + description: , + img: deps.exoImg, title: 'Exocraft Technology', - functionCallName: UpgradeType.Exocraft, + functionCallName: deps.TechUpgradeType.exocraft, techName: 'exocraft', - requirements: exoRequirements(labLevel, techLevels), + requirements: deps.exoRequirements(labLevel, techLevels), }, { - description: , - img: plasmaImg, + description: , + img: deps.plasmaImg, title: 'Plasma Engineering', - functionCallName: UpgradeType.PlasmaTech, + functionCallName: deps.TechUpgradeType.plasma, techName: 'plasma', - requirements: plasmaTechRequirements(labLevel, techLevels), + requirements: deps.plasmaTechRequirements(labLevel, techLevels), }, { - description: , - img: spacetimeImg, + description: , + img: deps.spacetimeImg, title: 'Spacetime Technology', - functionCallName: UpgradeType.Warp, + functionCallName: deps.UpgradeType.Warp, techName: 'spacetime', - requirements: spacetimeRequirements(labLevel, techLevels), + requirements: deps.spacetimeRequirements(labLevel, techLevels), }, { - description: , - img: combustionImg, + description: , + img: deps.combustionImg, title: 'Combustion Drive', - functionCallName: UpgradeType.Combustion, + functionCallName: deps.TechUpgradeType.combustion, techName: 'combustion', - requirements: combustionRequirements(labLevel, techLevels), + requirements: deps.combustionRequirements(labLevel, techLevels), }, { - description: , - img: thrustImg, + description: , + img: deps.thrustImg, title: 'Thrust Propulsion', - functionCallName: UpgradeType.Thrust, + functionCallName: deps.TechUpgradeType.thrust, techName: 'thrust', - requirements: thrustRequirements(labLevel, techLevels), + requirements: deps.thrustRequirements(labLevel, techLevels), }, { - description: , - img: warpEnginImg, + description: , + img: deps.warpEnginImg, title: 'Warp Drive', - functionCallName: UpgradeType.Warp, + functionCallName: deps.TechUpgradeType.warp, techName: 'warp', - requirements: warpRequirements(labLevel, techLevels), + requirements: deps.warpRequirements(labLevel, techLevels), }, { - description: , - img: armourImg, + description: , + img: deps.armourImg, title: 'Armour Innovation', - functionCallName: UpgradeType.Armour, + functionCallName: deps.TechUpgradeType.armour, techName: 'armour', - requirements: armourRequirements(labLevel), + requirements: deps.armourRequirements(labLevel), }, { - description: , - img: weaponsImg, + description: , + img: deps.weaponsImg, title: 'Weapons Development', - functionCallName: UpgradeType.Weapons, + functionCallName: deps.TechUpgradeType.weapons, techName: 'weapons', - requirements: weaponsRequirements(labLevel), + requirements: deps.weaponsRequirements(labLevel), }, { - description: , - img: shieldImg, + description: , + img: deps.shieldImg, title: 'Shields Technology', - functionCallName: UpgradeType.Shield, + functionCallName: deps.TechUpgradeType.shield, techName: 'shield', - requirements: shieldRequirements(labLevel, techLevels), + requirements: deps.shieldRequirements(labLevel, techLevels), }, ]; return ( - + {researchConfig.map((research) => ( ))} - + ); }; diff --git a/client/src/panels/UniverseViewTab.tsx b/client/src/panels/UniverseViewTab.tsx index b2de526..e7c893b 100644 --- a/client/src/panels/UniverseViewTab.tsx +++ b/client/src/panels/UniverseViewTab.tsx @@ -1,29 +1,10 @@ import React, { useState, useEffect } from 'react'; -import { - UniverseProps, - useAccount, - useGetIsNoobProtected, - useGetPlanetRanking, - useCalculateWinsAndLosses, - useLastActive, - useShipsLevels, - ShipsLevels, - getPlanetImage, - ImageId, - UniverseViewBox, - Resources, - TechLevels, - DefenceLevels, - PlanetDetails, - fetchPlanetsData, - StyledTabPanel, - // Stack, - Pagination, -} from '.'; -import { useGetColonyShips } from '../hooks/ColoniesHooks'; +import * as deps from '.'; import { useDestination } from '../context/DestinationContext'; import TextField from '@mui/material/TextField'; import { styled as muiStyled } from '@mui/material/styles'; +import { usePlanetShips } from '../hooks/usePlanetShips'; +import { useColonyShips } from '../hooks/useColonyShips'; const PaginationContainer = muiStyled('div')({ display: 'flex', @@ -58,9 +39,7 @@ const UniverseBoxItem = ({ planet, ownTechs, colonyId, -}: UniverseProps) => { - const { address: address_data } = useAccount(); - const address = address_data || ''; +}: deps.UniverseProps) => { const highlighted = parseInt(address, 16) === parseInt(planet.account, 16); const motherPlanet = @@ -76,28 +55,26 @@ const UniverseBoxItem = ({ motherPlanet ); - const ownFleetData = useShipsLevels(Number(ownPlanetId)); - const ownFleet: ShipsLevels = ownFleetData || { + const ownFleetData = usePlanetShips(ownPlanetId); + const ownFleet: deps.Fleet = ownFleetData || { carrier: 0, scraper: 0, sparrow: 0, frigate: 0, armade: 0, - celestia: 0, }; - const colonyFleetData = useGetColonyShips(Number(ownPlanetId), colonyId); - const colonyFleet: ShipsLevels = colonyFleetData || { + const colonyFleetData = useColonyShips(ownPlanetId, colonyId); + const colonyFleet: deps.Fleet = colonyFleetData || { carrier: 0, scraper: 0, sparrow: 0, frigate: 0, armade: 0, - celestia: 0, }; - const img = getPlanetImage( - planet.position.orbit.toString() as unknown as ImageId + const img = deps.getPlanetImage( + planet.position.orbit.toString() as unknown as deps.ImageId ); const shortenedAddress = `${planet.account.slice( @@ -106,7 +83,7 @@ const UniverseBoxItem = ({ )}...${planet.account.slice(-4)}`; return ( - { - const [planetsData, setPlanetsData] = useState([]); + const [planetsData, setPlanetsData] = useState([]); const [currentPage, setCurrentPage] = useState(1); const [inputPage, setInputPage] = useState(''); const [pageError, setPageError] = useState(false); @@ -149,45 +125,6 @@ export const UniverseViewTabPanel = ({ const { selectedDestination } = useDestination(); - useEffect(() => { - fetchPlanetsData() - .then((data) => { - const sortedData = data.sort((a, b) => { - if (Number(a.position.system) === Number(b.position.system)) { - return Number(a.position.orbit) - Number(b.position.orbit); - } - return Number(a.position.system) - Number(b.position.system); - }); - - setPlanetsData(sortedData); - - if (selectedDestination !== null) { - const destinationIndex = sortedData.findIndex( - (planet) => Number(planet.planetId) === Number(selectedDestination) - ); - if (destinationIndex !== -1) { - // Check if index is valid - const destinationPage = Math.ceil( - (destinationIndex + 1) / itemsPerPage - ); - setCurrentPage(destinationPage); - } - } else { - // Default page setting logic - const ownPlanetIndex = sortedData.findIndex((planet) => - colonyId === 0 - ? Number(planet.planetId) === ownPlanetId - : Number(planet.planetId) === ownPlanetId * 1000 + colonyId - ); - const initialPage = Math.ceil((ownPlanetIndex + 1) / itemsPerPage); - setCurrentPage(initialPage); - } - }) - .catch((error) => { - console.error('Error fetching planets data:', error); - }); - }, [colonyId, ownPlanetId, selectedDestination]); - const startIndex = (currentPage - 1) * itemsPerPage; const selectedPlanets = planetsData.slice( startIndex, diff --git a/client/src/panels/index.ts b/client/src/panels/index.ts index 309d244..2e93780 100644 --- a/client/src/panels/index.ts +++ b/client/src/panels/index.ts @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { BigNumberish } from 'starknet'; import steelImg from '../assets/gameElements/compounds/steel4.webp'; import quartzImg from '../assets/gameElements/compounds/quartz4.webp'; @@ -38,11 +39,12 @@ export { type EnergyCost, UpgradeType, type ShipsCost, - BuildType, type DefenceCost, type PlanetDetails, } from '../shared/types'; +export { DefenceBuildType, ShipBuildType, TechUpgradeType } from '../types'; + export { armourRequirements, beamTechRequirements, @@ -138,7 +140,7 @@ export interface CompoundConfigType { description: React.ReactNode; img: string; title: string; - functionCallName: number; + functionCallName: BigNumberish; compoundName: keyof Compounds; energyKey: keyof EnergyCost; } @@ -153,13 +155,13 @@ export interface ResearchConfigType { description: React.ReactNode; img: string; title: string; - functionCallName: number; + functionCallName: BigNumberish; techName: TechEntities; // <-- make sure of this type requirements: boolean; } export interface LabProps { - spendableResources: Resources; + resources: Resources; techLevels?: Techs; labLevel?: number; } @@ -168,27 +170,27 @@ export interface ShipConfigType { description: React.ReactNode; img: string; title: string; - functionCallName: number; - shipName: keyof Fleet; + functionCallName: BigNumberish; + shipName: keyof Fleet | 'celestia'; requirements: boolean; } export interface DockyardProps { - spendableResources?: Resources; - shipsLevels?: Fleet; - shipsCost?: ShipsCost; - dockyardLevel?: number; - techLevels?: Techs; + resources: Resources; + ships?: Fleet; + shipsCost: ShipsCost; + dockyard: number; + techs: Techs; celestia?: number; colonyId: number; } export interface DefenceProps { - spendableResources?: Resources; - defenceLevels?: Defences; - defenceCost?: DefenceCost; - dockyardLevel?: number; - techLevels?: Techs; + resources: Resources; + defences: Defences; + defenceCost: DefenceCost; + dockyard: number; + techs: Techs; colonyId: number; } @@ -229,6 +231,7 @@ import { } from '@mui/icons-material'; import { Typography } from '@mui/material'; +import DefencesBox from '../boxes/DefencesBox'; export { getBaseShipsCost, getBaseDefenceCost } from '../constants/costs'; export { @@ -274,6 +277,7 @@ export { beamCannonImg, astralLauncherImg, plasmaCannonImg, + DefencesBox, }; export interface ResourcesSectionArgs { diff --git a/client/src/shared/types/index.ts b/client/src/shared/types/index.ts index 4dfeb43..dc5d4fc 100644 --- a/client/src/shared/types/index.ts +++ b/client/src/shared/types/index.ts @@ -230,19 +230,6 @@ export function getColonyBuildType(name: number): CairoCustomEnum | undefined { } } -export const BuildType = { - Carrier: 0, - Scraper: 1, - Celestia: 2, - Sparrow: 3, - Frigate: 4, - Armade: 5, - Blaster: 6, - Beam: 7, - Astral: 8, - Plasma: 9, -}; - export function getBuildType(name: number): CairoCustomEnum | undefined { switch (name) { case 0: @@ -308,20 +295,6 @@ export const callTypeOptions = { }; type UpgradeTypeKeys = keyof typeof UpgradeType; -type BuildTypeKeys = keyof typeof BuildType; - -export function getUpgradeNameById(id: number, isBuild: boolean) { - if (isBuild == false) { - const reversedMapping = ( - Object.keys(UpgradeType) as UpgradeTypeKeys[] - ).find((key) => UpgradeType[key] === id); - return reversedMapping; - } - const reversedMapping = (Object.keys(BuildType) as BuildTypeKeys[]).find( - (key) => BuildType[key] === id - ); - return reversedMapping; -} export type SimulationResult = { attacker_carrier: number; diff --git a/client/src/shared/utils/index.ts b/client/src/shared/utils/index.ts index 8f1bb40..701846f 100644 --- a/client/src/shared/utils/index.ts +++ b/client/src/shared/utils/index.ts @@ -1,7 +1,8 @@ /* eslint-disable no-unused-vars */ import BigNumber from 'bignumber.js'; -import { type Position, type TechLevels } from '../types'; +import { type Position } from '../types'; import { Resources } from '../../hooks/usePlanetResources'; +import { Techs } from '../../hooks/usePlanetTechs'; export const dataToNumber = (value: unknown[] | string | number | undefined) => new BigNumber(value as unknown as number).toNumber(); @@ -41,221 +42,177 @@ export const weaponsRequirements = (labLevel: number | undefined) => { export const exoRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 3 && techs - ? techs.thrust >= 3 - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 3 && (techs.thrust || 0) >= 3 : false; }; export const beamTechRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 1 && techs - ? techs.energy >= 2 - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 1 && (techs.energy || 0) >= 2 : false; }; export const shieldRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 6 && techs - ? techs.energy >= 3 - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 6 && (techs.energy || 0) >= 3 : false; }; export const combustionRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 1 && techs - ? techs.energy >= 1 - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 1 && (techs.energy || 0) >= 1 : false; }; export const thrustRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 2 && techs - ? techs.energy >= 1 - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 2 && (techs.energy || 0) >= 1 : false; }; export const ionRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 4 && techs - ? techs.energy >= 4 && techs - ? techs.beam >= 5 - : false - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 4 && (techs.energy || 0) >= 4 && (techs.beam || 0) >= 5 : false; }; export const spacetimeRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 7 && techs - ? techs.energy >= 5 && techs.shield >= 5 - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 7 && (techs.energy || 0) >= 5 && (techs.shield || 0) >= 5 : false; }; export const warpRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 7 && techs - ? techs.energy >= 5 && techs - ? techs.spacetime >= 3 - : false - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 7 && (techs.energy || 0) >= 5 && (techs.spacetime || 0) >= 3 : false; }; export const plasmaTechRequirements = ( labLevel: number | undefined, - techs: TechLevels | undefined -) => { - return labLevel - ? labLevel >= 4 && techs - ? techs.energy >= 8 && techs - ? techs.beam >= 10 && techs - ? techs.ion >= 5 - : false - : false - : false + techs: Techs | undefined +): boolean => { + return labLevel !== undefined && techs !== undefined + ? labLevel >= 4 && + (techs.energy || 0) >= 8 && + (techs.beam || 0) >= 10 && + (techs.ion || 0) >= 5 : false; }; export const carrierRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 2 && techs - ? techs.combustion >= 2 - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 2 && (techs.combustion || 0) >= 2 : false; }; export const celestiaRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 1 && techs - ? techs.combustion >= 1 - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 1 && (techs.combustion || 0) >= 1 : false; }; export const scraperRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 4 && techs - ? techs.combustion >= 6 && techs - ? techs.shield >= 2 - : false - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 4 && + (techs.combustion || 0) >= 6 && + (techs.shield || 0) >= 2 : false; }; export const sparrowRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 1 && techs - ? techs?.combustion >= 1 - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 1 && (techs.combustion || 0) >= 1 : false; }; export const frigateRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 5 && techs - ? techs.ion >= 2 && techs - ? techs.thrust >= 4 - : false - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 5 && (techs.ion || 0) >= 2 && (techs.thrust || 0) >= 4 : false; }; export const armadeRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 7 && techs - ? techs.warp >= 4 - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 7 && (techs.warp || 0) >= 4 : false; }; -export const blasterRequirements = (dockyardLevel: number | undefined) => { +export const blasterRequirements = ( + dockyardLevel: number | undefined +): boolean => { return dockyardLevel ? dockyardLevel >= 1 : false; }; export const beamRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 2 && techs - ? techs.energy >= 2 && techs - ? techs.beam >= 6 - : false - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 2 && (techs.energy || 0) >= 2 && (techs.beam || 0) >= 6 : false; }; export const astralRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 6 && techs - ? techs.energy >= 6 && techs - ? techs.weapons >= 3 && techs - ? techs.shield >= 1 - : false - : false - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 6 && + (techs.energy || 0) >= 6 && + (techs.weapons || 0) >= 3 && + (techs.shield || 0) >= 1 : false; }; export const plasmaRequirements = ( dockyardLevel: number | undefined, - techs: TechLevels | undefined -) => { - return dockyardLevel - ? dockyardLevel >= 8 && techs - ? techs.plasma >= 7 - : false + techs: Techs | undefined +): boolean => { + return dockyardLevel !== undefined && techs !== undefined + ? dockyardLevel >= 8 && (techs.plasma || 0) >= 7 : false; }; @@ -264,12 +221,12 @@ export const numberWithCommas = (num: number) => ? num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.') : num.toString(); -export function convertTechLevelsToNumbers(techLevels: TechLevels): { - [K in keyof TechLevels]: number; +export function convertTechsToNumbers(Techs: Techs): { + [K in keyof Techs]: number; } { - const converted = {} as { [K in keyof TechLevels]: number }; - for (const [key, value] of Object.entries(techLevels)) { - converted[key as keyof TechLevels] = Number(value); + const converted = {} as { [K in keyof Techs]: number }; + for (const [key, value] of Object.entries(Techs)) { + converted[key as keyof Techs] = Number(value); } return converted; } diff --git a/client/src/types/index.ts b/client/src/types/index.ts index a465d76..beaa6a3 100644 --- a/client/src/types/index.ts +++ b/client/src/types/index.ts @@ -1,5 +1,5 @@ import { BigNumberish, CairoCustomEnum } from 'starknet'; -import { astralRequirements } from '../shared/utils/index'; +import { astralRequirements, frigateRequirements } from '../shared/utils/index'; export const CompoundUpgradeType = { SteelMine: 0 as BigNumberish, @@ -9,6 +9,30 @@ export const CompoundUpgradeType = { Lab: 4 as BigNumberish, }; +export const TechUpgradeType = { + energy: 0 as BigNumberish, + digital: 1 as BigNumberish, + beam: 2 as BigNumberish, + armour: 3 as BigNumberish, + ion: 4 as BigNumberish, + plasma: 5 as BigNumberish, + weapons: 6 as BigNumberish, + shield: 7 as BigNumberish, + spacetime: 8 as BigNumberish, + combustion: 9 as BigNumberish, + thrust: 10 as BigNumberish, + warp: 11 as BigNumberish, + exocraft: 12 as BigNumberish, +}; + +export const ShipBuildType = { + carrier: 0 as BigNumberish, + scraper: 1 as BigNumberish, + sparrow: 2 as BigNumberish, + frigate: 3 as BigNumberish, + armade: 4 as BigNumberish, +}; + export const DefenceBuildType = { celestia: 0 as BigNumberish, blaster: 1 as BigNumberish, diff --git a/client/src/views/DashBoard.tsx b/client/src/views/DashBoard.tsx index 1ba5ddd..58f9812 100644 --- a/client/src/views/DashBoard.tsx +++ b/client/src/views/DashBoard.tsx @@ -2,9 +2,9 @@ import React, { useState } from 'react'; import styled from 'styled-components'; import SideBar from '../sidebar/SideBar'; import { PlanetSection } from '../planetSection/PlanetSection'; -// import { ResourcesSection } from '../panels/MainTabPanel'; +import { ResourcesSection } from '../panels/MainTabPanel'; import { SelectChangeEvent } from '@mui/material'; -// import ColonyDashboard from '../colony/ColonyDashboard'; +import ColonyDashboard from '../colony/ColonyDashboard'; import { useDojo } from '../dojo/useDojo'; import { useComponentValue } from '@dojoengine/react'; import { getEntityIdFromKeys } from '@dojoengine/utils'; @@ -85,7 +85,7 @@ export default function Dashboard({ planetId }: Props) { selctedColonyId={selectedColonyId} /> - {/* + {selectedColonyId !== 0 && selectedColonyId !== null ? ( ) : ( - )} */} - {/* */} + )} + );