diff --git a/backend/.sqlx/query-155699a4a106a5e25556e344e78b1ad1eb51d5361e2b9668f400ef03e03b3473.json b/backend/.sqlx/query-155699a4a106a5e25556e344e78b1ad1eb51d5361e2b9668f400ef03e03b3473.json new file mode 100644 index 0000000..e3d4c76 --- /dev/null +++ b/backend/.sqlx/query-155699a4a106a5e25556e344e78b1ad1eb51d5361e2b9668f400ef03e03b3473.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT \n id,\n CAST(utxo_subject_amount(era, cbor, decode($2::varchar, 'hex')) AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS TEXT) AS ship_token_name,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS pilot_token_name,\n ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER)) + ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER)) AS distance\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($3::varchar)\n AND utxo_has_policy_id(era, cbor, decode($1::varchar, 'hex'))\n AND spent_slot IS NULL\n ORDER BY distance ASC\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "fuel", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "ship_token_name", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "pilot_token_name", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "distance", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Varchar", + "Varchar" + ] + }, + "nullable": [ + false, + null, + null, + null, + null + ] + }, + "hash": "155699a4a106a5e25556e344e78b1ad1eb51d5361e2b9668f400ef03e03b3473" +} diff --git a/backend/.sqlx/query-cef6f482bf0223cda6b62ee76a80cc2ef9235d9f45dac9cea0b6c560a049b68d.json b/backend/.sqlx/query-cef6f482bf0223cda6b62ee76a80cc2ef9235d9f45dac9cea0b6c560a049b68d.json new file mode 100644 index 0000000..fc3aac7 --- /dev/null +++ b/backend/.sqlx/query-cef6f482bf0223cda6b62ee76a80cc2ef9235d9f45dac9cea0b6c560a049b68d.json @@ -0,0 +1,77 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH data AS (\n SELECT \n id,\n 'Ship' as class,\n CAST(utxo_subject_amount(era, cbor, decode($5::varchar, 'hex')) AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS position_x,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_y,\n $4::varchar AS shipyard_policy,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS TEXT) AS ship_token_name,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS pilot_token_name,\n 0 AS total_rewards\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($6::varchar)\n AND utxo_has_policy_id(era, cbor, decode($4::varchar, 'hex'))\n AND spent_slot IS NULL\n \n UNION ALL\n \n SELECT \n id,\n 'Fuel' as class,\n CAST(utxo_subject_amount(era, cbor, decode($5::varchar, 'hex')) AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS position_x,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_y,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS VARCHAR(56)) AS shipyard_policy,\n NULL AS ship_token_name,\n NULL AS pilot_token_name,\n 0 AS total_rewards\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($7::varchar)\n AND spent_slot IS NULL\n\n UNION ALL\n \n SELECT \n id,\n 'Asteria' as class,\n 0 AS fuel,\n 0 AS position_x,\n 0 AS position_y,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'bytes' AS VARCHAR(56)) AS shipyard_policy,\n NULL AS ship_token_name,\n NULL AS pilot_token_name,\n utxo_lovelace(era, cbor) as total_rewards\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($8::varchar)\n AND spent_slot IS NULL\n )\n SELECT\n id,\n fuel,\n position_x,\n position_y,\n shipyard_policy,\n ship_token_name,\n pilot_token_name,\n class,\n total_rewards\n FROM\n data\n WHERE\n ABS(position_x - $1::int) + ABS(position_y - $2::int) < $3::int\n AND shipyard_policy = $4::text\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "fuel", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "position_x", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "position_y", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "shipyard_policy", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "ship_token_name", + "type_info": "Text" + }, + { + "ordinal": 6, + "name": "pilot_token_name", + "type_info": "Text" + }, + { + "ordinal": 7, + "name": "class", + "type_info": "Text" + }, + { + "ordinal": 8, + "name": "total_rewards", + "type_info": "Numeric" + } + ], + "parameters": { + "Left": [ + "Int4", + "Int4", + "Int4", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar" + ] + }, + "nullable": [ + null, + null, + null, + null, + null, + null, + null, + null, + null + ] + }, + "hash": "cef6f482bf0223cda6b62ee76a80cc2ef9235d9f45dac9cea0b6c560a049b68d" +} diff --git a/backend/.sqlx/query-da28879f691d4bea965a00ca5bfac5cb972068c8cd2624e493b6810dd9cdca89.json b/backend/.sqlx/query-da28879f691d4bea965a00ca5bfac5cb972068c8cd2624e493b6810dd9cdca89.json deleted file mode 100644 index e649087..0000000 --- a/backend/.sqlx/query-da28879f691d4bea965a00ca5bfac5cb972068c8cd2624e493b6810dd9cdca89.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n WITH data AS (\n SELECT \n id,\n 'Ship' as class,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_x,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'int' AS INTEGER) AS position_y,\n $4::varchar AS shipyard_policy,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS ship_token_name,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 4 ->> 'bytes' AS TEXT) AS pilot_token_name,\n 0 AS total_rewards\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($5::varchar)\n AND utxo_has_policy_id(era, cbor, decode($4::varchar, 'hex'))\n AND spent_slot IS NULL\n \n UNION ALL\n \n SELECT \n id,\n 'Fuel' as class,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_x,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'int' AS INTEGER) AS position_y,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS VARCHAR(56)) AS shipyard_policy,\n NULL AS ship_token_name,\n NULL AS pilot_token_name,\n 0 AS total_rewards\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($6::varchar)\n AND spent_slot IS NULL\n\n UNION ALL\n \n SELECT \n id,\n 'Asteria' as class,\n 0 AS fuel,\n 0 AS position_x,\n 0 AS position_y,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'bytes' AS VARCHAR(56)) AS shipyard_policy,\n NULL AS ship_token_name,\n NULL AS pilot_token_name,\n utxo_lovelace(era, cbor) as total_rewards\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($7::varchar)\n AND spent_slot IS NULL\n )\n SELECT\n id,\n fuel,\n position_x,\n position_y,\n shipyard_policy,\n ship_token_name,\n pilot_token_name,\n class,\n total_rewards\n FROM\n data\n WHERE\n ABS(position_x - $1::int) + ABS(position_y - $2::int) < $3::int\n AND shipyard_policy = $4::text\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Varchar" - }, - { - "ordinal": 1, - "name": "fuel", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "position_x", - "type_info": "Int4" - }, - { - "ordinal": 3, - "name": "position_y", - "type_info": "Int4" - }, - { - "ordinal": 4, - "name": "shipyard_policy", - "type_info": "Varchar" - }, - { - "ordinal": 5, - "name": "ship_token_name", - "type_info": "Text" - }, - { - "ordinal": 6, - "name": "pilot_token_name", - "type_info": "Text" - }, - { - "ordinal": 7, - "name": "class", - "type_info": "Text" - }, - { - "ordinal": 8, - "name": "total_rewards", - "type_info": "Numeric" - } - ], - "parameters": { - "Left": [ - "Int4", - "Int4", - "Int4", - "Varchar", - "Varchar", - "Varchar", - "Varchar" - ] - }, - "nullable": [ - null, - null, - null, - null, - null, - null, - null, - null, - null - ] - }, - "hash": "da28879f691d4bea965a00ca5bfac5cb972068c8cd2624e493b6810dd9cdca89" -} diff --git a/backend/.sqlx/query-e3bd369d305dfe16329071c55cc53a06473e9aa23b5bb52f00384e5da4542464.json b/backend/.sqlx/query-e3bd369d305dfe16329071c55cc53a06473e9aa23b5bb52f00384e5da4542464.json deleted file mode 100644 index c6a1861..0000000 --- a/backend/.sqlx/query-e3bd369d305dfe16329071c55cc53a06473e9aa23b5bb52f00384e5da4542464.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT \n id,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS fuel,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS ship_token_name,\n CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 4 ->> 'bytes' AS TEXT) AS pilot_token_name,\n ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER)) + ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'int' AS INTEGER)) AS distance\n FROM \n utxos\n WHERE \n utxo_address(era, cbor) = from_bech32($2::varchar)\n AND utxo_has_policy_id(era, cbor, decode($1::varchar, 'hex'))\n AND spent_slot IS NULL\n ORDER BY distance ASC\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Varchar" - }, - { - "ordinal": 1, - "name": "fuel", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "ship_token_name", - "type_info": "Text" - }, - { - "ordinal": 3, - "name": "pilot_token_name", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "distance", - "type_info": "Int4" - } - ], - "parameters": { - "Left": [ - "Varchar", - "Varchar" - ] - }, - "nullable": [ - false, - null, - null, - null, - null - ] - }, - "hash": "e3bd369d305dfe16329071c55cc53a06473e9aa23b5bb52f00384e5da4542464" -} diff --git a/backend/src/main.rs b/backend/src/main.rs index 89f2847..12ddd89 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -305,6 +305,7 @@ impl QueryRoot { center: PositionInput, radius: i32, shipyard_policy_id: String, + fuel_policy_id: String, ship_address: String, fuel_address: String, asteria_address: String, @@ -321,17 +322,17 @@ impl QueryRoot { SELECT id, 'Ship' as class, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS fuel, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_x, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'int' AS INTEGER) AS position_y, + CAST(utxo_subject_amount(era, cbor, decode($5::varchar, 'hex')) AS INTEGER) AS fuel, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS position_x, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_y, $4::varchar AS shipyard_policy, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS ship_token_name, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 4 ->> 'bytes' AS TEXT) AS pilot_token_name, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS TEXT) AS ship_token_name, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS pilot_token_name, 0 AS total_rewards FROM utxos WHERE - utxo_address(era, cbor) = from_bech32($5::varchar) + utxo_address(era, cbor) = from_bech32($6::varchar) AND utxo_has_policy_id(era, cbor, decode($4::varchar, 'hex')) AND spent_slot IS NULL @@ -340,17 +341,17 @@ impl QueryRoot { SELECT id, 'Fuel' as class, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS fuel, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_x, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'int' AS INTEGER) AS position_y, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS VARCHAR(56)) AS shipyard_policy, + CAST(utxo_subject_amount(era, cbor, decode($5::varchar, 'hex')) AS INTEGER) AS fuel, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS position_x, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER) AS position_y, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS VARCHAR(56)) AS shipyard_policy, NULL AS ship_token_name, NULL AS pilot_token_name, 0 AS total_rewards FROM utxos WHERE - utxo_address(era, cbor) = from_bech32($6::varchar) + utxo_address(era, cbor) = from_bech32($7::varchar) AND spent_slot IS NULL UNION ALL @@ -368,7 +369,7 @@ impl QueryRoot { FROM utxos WHERE - utxo_address(era, cbor) = from_bech32($7::varchar) + utxo_address(era, cbor) = from_bech32($8::varchar) AND spent_slot IS NULL ) SELECT @@ -391,6 +392,7 @@ impl QueryRoot { center.y, radius, shipyard_policy_id, + fuel_policy_id, ship_address, fuel_address, asteria_address, @@ -515,6 +517,7 @@ impl QueryRoot { &self, ctx: &Context<'_>, shipyard_policy_id: String, + fuel_policy_id: String, ship_address: String, ) -> Result, Error> { let pool = ctx @@ -525,19 +528,20 @@ impl QueryRoot { " SELECT id, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER) AS fuel, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS ship_token_name, - CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 4 ->> 'bytes' AS TEXT) AS pilot_token_name, - ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER)) + ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'int' AS INTEGER)) AS distance + CAST(utxo_subject_amount(era, cbor, decode($2::varchar, 'hex')) AS INTEGER) AS fuel, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 2 ->> 'bytes' AS TEXT) AS ship_token_name, + CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 3 ->> 'bytes' AS TEXT) AS pilot_token_name, + ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 0 ->> 'int' AS INTEGER)) + ABS(CAST(utxo_plutus_data(era, cbor) -> 'fields' -> 1 ->> 'int' AS INTEGER)) AS distance FROM utxos WHERE - utxo_address(era, cbor) = from_bech32($2::varchar) + utxo_address(era, cbor) = from_bech32($3::varchar) AND utxo_has_policy_id(era, cbor, decode($1::varchar, 'hex')) AND spent_slot IS NULL ORDER BY distance ASC ", shipyard_policy_id, + fuel_policy_id, ship_address, ) .fetch_all(pool) diff --git a/docker/Dockerfile.frontend b/docker/Dockerfile.frontend index 1a2260d..db3a5fb 100644 --- a/docker/Dockerfile.frontend +++ b/docker/Dockerfile.frontend @@ -50,6 +50,9 @@ COPY ./frontend/package*.json ./ RUN npm install COPY ./frontend ./ + +COPY ./frontend/public/godot.png ./public/visualizer/index.png + RUN npm run build CMD ["npm", "start"] \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index 069d276..da8951a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "build-godot": "mkdir public/visualizer; godot --path ../godot-visualizer --headless --export-release \"Web\" ../frontend/public/visualizer/index.html", + "build-godot": "mkdir public/visualizer; godot --path ../godot-visualizer --headless --export-release \"Web\" ../frontend/public/visualizer/index.html; cp public/godot.png public/visualizer/index.png", "dev": "npm run build-godot; next dev", "build": "next build", "start": "next start" diff --git a/frontend/public/godot.png b/frontend/public/godot.png new file mode 100644 index 0000000..b3a691c Binary files /dev/null and b/frontend/public/godot.png differ diff --git a/frontend/public/txs/build-ship.png b/frontend/public/txs/build-ship.png index 070160a..1a2a1e5 100644 Binary files a/frontend/public/txs/build-ship.png and b/frontend/public/txs/build-ship.png differ diff --git a/frontend/public/txs/gather-fuel.png b/frontend/public/txs/gather-fuel.png index 611cd70..a88a0df 100644 Binary files a/frontend/public/txs/gather-fuel.png and b/frontend/public/txs/gather-fuel.png differ diff --git a/frontend/public/txs/mine-asteria.png b/frontend/public/txs/mine-asteria.png index 821ad54..f4af218 100644 Binary files a/frontend/public/txs/mine-asteria.png and b/frontend/public/txs/mine-asteria.png differ diff --git a/frontend/public/txs/move-ship.png b/frontend/public/txs/move-ship.png index 3bd0736..8c1370a 100644 Binary files a/frontend/public/txs/move-ship.png and b/frontend/public/txs/move-ship.png differ diff --git a/frontend/public/txs/quit.png b/frontend/public/txs/quit.png deleted file mode 100644 index 8f7a48f..0000000 Binary files a/frontend/public/txs/quit.png and /dev/null differ diff --git a/frontend/src/components/CodeBlock.tsx b/frontend/src/components/CodeBlock.tsx index 5a74479..5e5d4b1 100644 --- a/frontend/src/components/CodeBlock.tsx +++ b/frontend/src/components/CodeBlock.tsx @@ -5,13 +5,15 @@ import { codeToHtml } from "shiki"; const CodeBlock = ({ content, + lang }: { + lang?: string; content: string; }) => { const [code, setCode] = useState('
'); useEffect(() => { - codeToHtml(content, { lang: 'typescript', theme: 'dark-plus' }).then(setCode); + codeToHtml(content, { lang: lang ? lang : 'typescript', theme: 'dark-plus' }).then(setCode); }, [content]); return
; diff --git a/frontend/src/components/NavBar.tsx b/frontend/src/components/NavBar.tsx index 72f2b03..07244f8 100644 --- a/frontend/src/components/NavBar.tsx +++ b/frontend/src/components/NavBar.tsx @@ -38,7 +38,7 @@ const NavBar: React.FunctionComponent = () => { diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index e32ddb9..9d312d9 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -31,22 +31,28 @@ const Sidebar: React.FunctionComponent = () => { return (
+

INTRODUCTION

- Introduction Gameplay Glossary - +

GUIDES

- Build Ship Move Ship Gather Fuel Mine Asteria + Backend API + +

+ CHALLENGES +

+ Preview Challenge +
); diff --git a/frontend/src/pages/how-to-play/backend-api.mdx b/frontend/src/pages/how-to-play/backend-api.mdx new file mode 100644 index 0000000..997127e --- /dev/null +++ b/frontend/src/pages/how-to-play/backend-api.mdx @@ -0,0 +1,108 @@ +import Layout from "./layout"; +import CodeBlock from "@/components/CodeBlock"; +export default ({ children }) => {children}; + +# Querying the Backend API + +Project Asteria provides a `GraphQL` API to query the state of the game. The primary query used is `objectsInRadius`, which retrieves objects within a specified radius around a given point. + +## Example Query + +Below is an example of a query to get objects around the center point (0,0) with a radius of 10: + + + +## Example Response + + + +A preview testnet `GraphQL` endpoint is available at [https://dmtr_scrolls_v0_preview_1t9nhgnmxtpzrzm2gwv0723cu.scrolls-m0.demeter.run/graphql](https://dmtr_scrolls_v0_preview_1t9nhgnmxtpzrzm2gwv0723cu.scrolls-m0.demeter.run/graphql). + +## Implementation Details + +The backend uses a SQL query with a Manhattan distance calculation to find objects within the specified radius. The query ensures that the objects are within the bounds defined by the radius and the center point. + + + +## Database and Projection + +The database consists of UTXOs in the smart contract validators. These UTXOs are projected into a materialized view using [Mumak](https://github.com/txpipe/mumak), a PostgreSQL extension that allows developers to project or filter CBOR data within PostgreSQL. The generated materialized view is queried by the backend API as if it were a regular table. This enables efficient distance queries over CBOR data directly within PostgreSQL. \ No newline at end of file diff --git a/frontend/src/pages/how-to-play/build-ship.mdx b/frontend/src/pages/how-to-play/build-ship.mdx index 8163d58..31286ac 100644 --- a/frontend/src/pages/how-to-play/build-ship.mdx +++ b/frontend/src/pages/how-to-play/build-ship.mdx @@ -12,151 +12,58 @@ Creates a `ShipState` UTxO locking min ada and a `ShipToken` (minted in this tx) You can use the following Lucid script to build your ship. The supporting files are available [here](https://github.com/txpipe/asteria/tree/main/offchain). - { - const lucid = await lucidBase(); - const seed = Deno.env.get("SEED"); - if (!seed) { - throw Error("Unable to read wallet's seed from env"); - } - lucid.selectWalletFromSeed(seed); - - const asteriaRefTxHash: { txHash: string } = JSON.parse( - await Deno.readTextFile("./script-refs/asteria-ref.json") - ); - const asteriaRef = await fetchReferenceScript(lucid, asteriaRefTxHash.txHash); - const asteriaValidator = asteriaRef.scriptRef as Script; - const asteriaAddressBech32 = lucid.utils.validatorToAddress(asteriaValidator); +( - asteria.datum as string, - AsteriaDatum as unknown as AsteriaDatumT - ); + const pos_x = 20n; + const pos_y = 20n; - const asteriaInfo = { - ship_counter: asteriaInputDatum.ship_counter + 1n, - shipyard_policy: asteriaInputDatum.shipyard_policy, + const gameIdentifier: GameIdentifier = { + asteria_utxo, + spacetime_script_reference, + pellet_script_reference, + asteria_script_reference, }; - const asteriaOutputDatum = Data.to( - asteriaInfo, - AsteriaDatum as unknown as AsteriaDatumT - ); - const fuelTokenName = fromText("FUEL"); - const shipTokenName = fromText("SHIP" + asteriaInputDatum.ship_counter); - const pilotTokenName = fromText("PILOT" + asteriaInputDatum.ship_counter); - const shipInfo = { - pos_x: pos_x, - pos_y: pos_y, - ship_token_name: shipTokenName, - pilot_token_name: pilotTokenName, - last_move_latest_time: tx_latest_posix_time, - }; - const shipDatum = Data.to( - shipInfo, - ShipDatum as unknown as ShipDatumT + const tx = await createShip( + address, + gameIdentifier, + pos_x, + pos_y, ); - const adminTokenUnit = toUnit(admin_token.policy, admin_token.name); - const fuelTokenUnit = toUnit(fuelPolicyId, fuelTokenName); - const shipTokenUnit = toUnit(shipyardPolicyId, shipTokenName); - const pilotTokenUnit = toUnit(shipyardPolicyId, pilotTokenName); - - const addNewShipRedeemer = Data.to(new Constr(0, [])); - const mintFuelRedeemer = Data.to(new Constr(0, [])); - const mintShipRedeemer = Data.to(new Constr(0, [])); - const tx = await lucid - .newTx() - .validTo(Number(tx_latest_posix_time)) - .readFrom([asteriaRef, spacetimeRef, pelletRef]) - .mintAssets( - { - [shipTokenUnit]: BigInt(1), - [pilotTokenUnit]: BigInt(1), - }, - mintShipRedeemer - ) - .mintAssets( - { - [fuelTokenUnit]: initial_fuel, - }, - mintFuelRedeemer - ) - .collectFrom([asteria], addNewShipRedeemer) - .payToContract( - spacetimeAddressBech32, - { inline: shipDatum }, - { - [shipTokenUnit]: BigInt(1), - [fuelTokenUnit]: initial_fuel, - } - ) - .payToContract( - asteriaAddressBech32, - { inline: asteriaOutputDatum }, - { - [adminTokenUnit]: BigInt(1), - lovelace: asteriaInputAda + ship_mint_lovelace_fee, - } - ) - .complete(); + return tx; +} - const signedTx = await tx.sign().complete(); - return signedTx.submit(); - } +main().then((tx) => { + console.log(tx.toCbor()); +}); `} /> \ No newline at end of file diff --git a/frontend/src/pages/how-to-play/gather-fuel.mdx b/frontend/src/pages/how-to-play/gather-fuel.mdx index 92b80cf..6703fea 100644 --- a/frontend/src/pages/how-to-play/gather-fuel.mdx +++ b/frontend/src/pages/how-to-play/gather-fuel.mdx @@ -12,165 +12,54 @@ Updates the `fuel` datum field of the `ShipState` UTxO by adding the amount of f You can use the following Lucid script to gather fuel for your ship. The supporting files are available [here](https://github.com/txpipe/asteria/tree/main/offchain). - { - const lucid = await lucidBase(); - const seed = Deno.env.get("SEED"); - if (!seed) { - throw Error("Unable to read wallet's seed from env"); - } - lucid.selectWalletFromSeed(seed); - - const spacetimeRefTxHash: { txHash: string } = JSON.parse( - await Deno.readTextFile("./script-refs/spacetime-ref.json") - ); - const spacetimeRef = await fetchReferenceScript( - lucid, - spacetimeRefTxHash.txHash - ); - const spacetimeValidator = spacetimeRef.scriptRef as Script; - const spacetimeAddressBech32 = - lucid.utils.validatorToAddress(spacetimeValidator); - const shipyardPolicyId = lucid.utils.mintingPolicyToId(spacetimeValidator); - - const pelletRefTxHash: { txHash: string } = JSON.parse( - await Deno.readTextFile("./script-refs/pellet-ref.json") - ); - const pelletRef = await fetchReferenceScript(lucid, pelletRefTxHash.txHash); - const pelletValidator = pelletRef.scriptRef as Script; - const pelletAddressBech32 = lucid.utils.validatorToAddress(pelletValidator); - const fuelPolicyId = lucid.utils.mintingPolicyToId(pelletValidator); - - const ship: UTxO = ( - await lucid.utxosByOutRef([ - { - txHash: ship_tx_hash, - outputIndex: 0, - }, - ]) - )[0]; - if (!ship.datum) { - throw Error("Ship datum not found"); - } - const shipAda = ship.assets.lovelace; - - const pellet: UTxO = ( - await lucid.utxosByOutRef([ - { - txHash: pellet_tx_hash, - outputIndex: pellet_tx_index, - }, - ]) - )[0]; - if (!pellet.datum) { - throw Error("Pellet datum not found"); - } - const pelletAda = pellet.assets.lovelace; +( - ship.datum as string, - ShipDatum as unknown as ShipDatumT - ); - const shipInfo = { - pos_x: shipInputDatum.pos_x, - pos_y: shipInputDatum.pos_y, - ship_token_name: shipInputDatum.ship_token_name, - pilot_token_name: shipInputDatum.pilot_token_name, - last_move_latest_time: shipInputDatum.last_move_latest_time, + const spacetime_script_reference: OutRef = { + tx_hash: + "41e5881cd3bdc3f08bcf341796347e9027e3bcd8d58608b4fcfca5c16cbf5921", + tx_index: 0n, }; - const shipOutputDatum = Data.to( - shipInfo, - ShipDatum as unknown as ShipDatumT - ); - const pelletInputDatum = Data.from( - pellet.datum as string, - PelletDatum as unknown as PelletDatumT - ); - const pelletInfo = { - pos_x: pelletInputDatum.pos_x, - pos_y: pelletInputDatum.pos_y, - shipyard_policy: shipyardPolicyId, + const pellet_script_reference: OutRef = { + tx_hash: + "ba6fab625d70a81f5d1b699e7efde4b74922d06224bef1f6b84f3adf0a61f3f3", + tx_index: 0n, }; - const pelletOutputDatum = Data.to( - pelletInfo, - PelletDatum as unknown as PelletDatumT - ); - const shipTokenUnit = toUnit( - shipyardPolicyId, - shipInputDatum.ship_token_name - ); - const pilotTokenUnit = toUnit( - shipyardPolicyId, - shipInputDatum.pilot_token_name - ); - const adminTokenUnit = toUnit(admin_token.policy, admin_token.name); - const fuelTokenUnit = toUnit(fuelPolicyId, fromText("FUEL")); - const shipFuel = ship.assets[fuelTokenUnit]; - const pelletFuel = pellet.assets[fuelTokenUnit]; + const gather_fuel_identifier: GameIdentifier = { + ship_utxo, + pellet_utxo, + spacetime_script_reference, + pellet_script_reference, + }; - const shipRedeemer = Data.to(new Constr(1, [new Constr(1, [gather_amount])])); - const pelletRedeemer = Data.to( - new Constr(1, [new Constr(0, [gather_amount])]) + const tx = await gatherFuel( + address, + gather_fuel_identifier, ); - const tx = await lucid - .newTx() - .validFrom(Number(tx_earliest_posix_time)) - .collectFrom([ship], shipRedeemer) - .collectFrom([pellet], pelletRedeemer) - .readFrom([spacetimeRef, pelletRef]) - .payToContract( - spacetimeAddressBech32, - { inline: shipOutputDatum }, - { - [shipTokenUnit]: BigInt(1), - [fuelTokenUnit]: shipFuel + gather_amount, - lovelace: shipAda, - } - ) - .payToContract( - pelletAddressBech32, - { inline: pelletOutputDatum }, - { - [adminTokenUnit]: BigInt(1), - [fuelTokenUnit]: pelletFuel - gather_amount, - lovelace: pelletAda, - } - ) - .payToAddress(await lucid.wallet.address(), { - [pilotTokenUnit]: BigInt(1), - }) - .complete(); - const signedTx = await tx.sign().complete(); - return signedTx.submit(); - } + return tx; +} - export { gatherFuel }; +main().then((tx) => { + console.log(tx.toCbor()); +}); `} /> diff --git a/frontend/src/pages/how-to-play/mine-asteria.mdx b/frontend/src/pages/how-to-play/mine-asteria.mdx index 6cc70ff..4b6f967 100644 --- a/frontend/src/pages/how-to-play/mine-asteria.mdx +++ b/frontend/src/pages/how-to-play/mine-asteria.mdx @@ -12,155 +12,62 @@ Updates the `AsteriaUtxo` by transferring its value to the ship owner's address. You can use the following Lucid script to mine Asteria with your ship. The supporting files are available [here](https://github.com/txpipe/asteria/tree/main/offchain). - { - const lucid = await lucidBase(); - const seed = Deno.env.get("SEED"); - if (!seed) { - throw Error("Unable to read wallet's seed from env"); - } - lucid.selectWalletFromSeed(seed); - - const spacetimeRefTxHash: { txHash: string } = JSON.parse( - await Deno.readTextFile("./script-refs/spacetime-ref.json") - ); - const spacetimeRef = await fetchReferenceScript( - lucid, - spacetimeRefTxHash.txHash - ); - const spacetimeValidator = spacetimeRef.scriptRef as Script; - const shipyardPolicyId = lucid.utils.mintingPolicyToId(spacetimeValidator); +( - ship.datum as string, - ShipDatum as unknown as ShipDatumT - ); - const shipFuel = ship.assets[fuelTokenUnit]; - - const asterias: UTxO[] = await lucid.utxosAt(asteriaAddressBech32); - if (asterias.length != 1) { - throw Error( - "Expected only one Asteria UTxO, but found: " + asterias.length - ); - } - const asteria = asterias[0]; - if (!asteria.datum) { - throw Error("Asteria datum not found"); - } - const rewards = asteria.assets.lovelace; - const minedRewards = BigInt( - Math.floor((Number(rewards) * Number(max_asteria_mining)) / 100) - ); + const asteria_script_reference: OutRef = { + tx_hash: + "39871aab15b7c5ab1075ba431d7475f3977fe40fbb8d654b6bdf6f6726659277", + tx_index: 0n, + }; + const asteria_utxo: OutRef = { + tx_hash: + "bbcdff5ed1c0dd78c58c42dab8356c161f865d0c3efc1ea281026140a0d38516", + tx_index: 1n, + }; - const asteriaInputDatum = Data.from( - asteria.datum as string, - AsteriaDatum as unknown as AsteriaDatumT - ); - const asteriaInfo = { - ship_counter: asteriaInputDatum.ship_counter, - shipyard_policy: shipyardPolicyId, + const ship_utxo: OutRef = { + tx_hash: + "594fb0c4baff88873d15d5973103efc667052deec3315ba4bc89aeaaf53dd407", + tx_index: 0n, }; - const asteriaOutputDatum = Data.to( - asteriaInfo, - AsteriaDatum as unknown as AsteriaDatumT - ); - const adminTokenUnit = toUnit(admin_token.policy, admin_token.name); - const shipTokenUnit = toUnit( - shipyardPolicyId, - shipInputDatum.ship_token_name - ); - const pilotTokenUnit = toUnit( - shipyardPolicyId, - shipInputDatum.pilot_token_name + const gameIdentifier: GameIdentifier = { + asteria_utxo, + ship_utxo, + spacetime_script_reference, + pellet_script_reference, + asteria_script_reference, + }; + + const tx = await mineAsteria( + address, + gameIdentifier, ); - const shipRedeemer = Data.to(new Constr(1, [new Constr(2, [])])); - const asteriaRedeemer = Data.to(new Constr(1, [])); - const burnShipRedeemer = Data.to(new Constr(1, [])); - const burnFuelRedeemer = Data.to(new Constr(1, [])); - const tx = await lucid - .newTx() - .validFrom(Number(tx_earliest_posix_time)) - .mintAssets( - { - [shipTokenUnit]: BigInt(-1), - }, - burnShipRedeemer - ) - .mintAssets( - { - [fuelTokenUnit]: -shipFuel, - }, - burnFuelRedeemer - ) - .collectFrom([ship], shipRedeemer) - .collectFrom([asteria], asteriaRedeemer) - .readFrom([spacetimeRef, asteriaRef, pelletRef]) - .payToContract( - asteriaAddressBech32, - { inline: asteriaOutputDatum }, - { - [adminTokenUnit]: BigInt(1), - lovelace: rewards - minedRewards, - } - ) - .payToAddress(await lucid.wallet.address(), { - [pilotTokenUnit]: BigInt(1), - lovelace: 1_500_000n, - }) - .complete(); - - const signedTx = await tx.sign().complete(); - return signedTx.submit(); - } + return tx; +} + +main().then((tx) => { + console.log(tx.toCbor()); +}); `} /> diff --git a/frontend/src/pages/how-to-play/move-ship.mdx b/frontend/src/pages/how-to-play/move-ship.mdx index 9194602..54afba9 100644 --- a/frontend/src/pages/how-to-play/move-ship.mdx +++ b/frontend/src/pages/how-to-play/move-ship.mdx @@ -12,100 +12,51 @@ Updates the `pos_x`, `pos_y` and `fuel` datum fields of the `ShipState` UTxO by You can use the following Lucid script to move your ship. The supporting files are available [here](https://github.com/txpipe/asteria/tree/main/offchain). - { - const lucid = await lucidBase(); - - const spacetimeRefTxHash: { txHash: string } = JSON.parse( - await Deno.readTextFile("./spacetime-ref.json") - ); - const spacetimeRef = await lucid.utxosByOutRef([ - { - txHash: spacetimeRefTxHash.txHash, - outputIndex: 0, - }, - ]); - const spacetimeValidator = spacetimeRef[0].scriptRef; - if (!spacetimeValidator) { - throw Error("Could not read spacetime validator from ref UTxO"); - } - const spacetimeAddressBech32 = - lucid.utils.validatorToAddress(spacetimeValidator); + const ship_utxo: OutRef = { + tx_hash: + "41f2a593e131a3c5db878bbe7753b89c8c6de555b7127e812c0f488d1a898368", + tx_index: 0n, + }; - const shipyardPolicyId = lucid.utils.mintingPolicyToId(spacetimeValidator); - const shipTokenUnit = toUnit(shipyardPolicyId, ship_token_name); - const pilotTokenUnit = toUnit(shipyardPolicyId, pilot_token_name); + const spacetime_script_reference: OutRef = { + tx_hash: + "41e5881cd3bdc3f08bcf341796347e9027e3bcd8d58608b4fcfca5c16cbf5921", + tx_index: 0n, + }; - const ship: UTxO = ( - await lucid.utxosByOutRef([ - { - txHash: shipTxHash, - outputIndex: 0, - }, - ]) - )[0]; - if (!ship.datum) { - throw Error("Ship datum not found"); - } - const shipAda = ship.assets.lovelace; + const pellet_script_reference: OutRef = { + tx_hash: + "ba6fab625d70a81f5d1b699e7efde4b74922d06224bef1f6b84f3adf0a61f3f3", + tx_index: 0n, + }; - const shipInputDatum = Data.from( - ship.datum as string, - ShipDatum as unknown as ShipDatumT - ); + const delta_x = -1n; + const delta_y = -1n - const moved_distance = distance(delta_x, delta_y); - const spent_fuel = required_fuel(moved_distance, fuel_per_step); - const shipInfo = { - fuel: shipInputDatum.fuel - spent_fuel, - pos_x: shipInputDatum.pos_x + delta_x, - pos_y: shipInputDatum.pos_y + delta_y, - ship_token_name: shipInputDatum.ship_token_name, - pilot_token_name: shipInputDatum.pilot_token_name, + const move_ship_identifier: GameIdentifier = { + ship_utxo, + spacetime_script_reference, + pellet_script_reference, }; - const shipOutputDatum = Data.to( - shipInfo, - ShipDatum as unknown as ShipDatumT - ); - const moveShipRedeemer = Data.to( - new Constr(1, [new Constr(0, [delta_x, delta_y])]) + const tx = await moveShip( + address, + move_ship_identifier, + delta_x, + delta_y, ); - const tx = await lucid - .newTx() - .collectFrom([ship], moveShipRedeemer) - .readFrom(spacetimeRef) - .payToContract( - spacetimeAddressBech32, - { inline: shipOutputDatum }, - { - [shipTokenUnit]: BigInt(1), - lovelace: shipAda, - } - ) - .payToAddress(await lucid.wallet.address(), { - [pilotTokenUnit]: BigInt(1), - }) - .complete(); - } + return tx; +} + +main().then((tx) => { + console.log(tx.toCbor()); +}); `} /> \ No newline at end of file diff --git a/frontend/src/pages/how-to-play/preview-challenge.mdx b/frontend/src/pages/how-to-play/preview-challenge.mdx new file mode 100644 index 0000000..c56cfc1 --- /dev/null +++ b/frontend/src/pages/how-to-play/preview-challenge.mdx @@ -0,0 +1,67 @@ +import Layout from "./layout"; +export default ({ children }) => {children}; + + +# Preview Challenge + +## Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterValue
`max_ship_fuel`1500
`fuel_per_step`60
`initial_fuel`480
`ship_mint_lovelace_fee`1 ADA
`max_asteria_mining`50%
`max_speed`1 step / minute
+ +## Validators + + + + + + + + + + + + + + + + + + + + + + +
ValidatorAddress
Spacetime`addr_test1wqr27cm4w35gzwragtsfja7wsfk5n393gp8vzn98t2j92wclzmt4v`
Pellet`addr_test1wrwy0q8xtcngksdxk7nxd8kxwxvssmha5kl62nyxk7dmuqsf3slrx`
Asteria`addr_test1wr44k7mvy2aznjn5qk69xa5gax0fsxmv4q8n9xv9040kqjs9kcchd`
\ No newline at end of file diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index b6abf3f..3fc09e3 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -93,7 +93,7 @@ export default function Landing() { Network | { challenge.network }

- Shipyard Policy | { challenge.policyId } + Shipyard Policy | { challenge.shipyardPolicyId }

{ challenge.label } @@ -104,10 +104,7 @@ export default function Landing() { disabled={selected === index} className="font-monocraft-regular text-[#07F3E6] border border-[#07F3E6] bg-transparent py-4 px-6 rounded-full text-lg flex-initial disabled:opacity-50" > - Play - -

diff --git a/frontend/src/pages/leaderboard/index.tsx b/frontend/src/pages/leaderboard/index.tsx index 3972ab7..5a12874 100644 --- a/frontend/src/pages/leaderboard/index.tsx +++ b/frontend/src/pages/leaderboard/index.tsx @@ -5,8 +5,8 @@ import { useChallengeStore } from '@/stores/challenge'; const PAGE_SIZE = 10; const GET_LEADERBOARD_RECORDS = gql` - query Leaderboard($shipyardPolicyId: String, $shipAddress: String) { - leaderboard(shipyardPolicyId: $shipyardPolicyId, shipAddress: $shipAddress) { + query Leaderboard($shipyardPolicyId: String, $fuelPolicyId: String, $shipAddress: String) { + leaderboard(shipyardPolicyId: $shipyardPolicyId, fuelPolicyId: $fuelPolicyId, shipAddress: $shipAddress) { ranking, address, shipName, @@ -89,6 +89,7 @@ export default function Leaderboard() { const { data } = useQuery(GET_LEADERBOARD_RECORDS, { variables: { shipyardPolicyId: current().shipyardPolicyId, + fuelPolicyId: current().fuelPolicyId, shipAddress: current().shipAddress, }, }); diff --git a/frontend/src/pages/map/index.tsx b/frontend/src/pages/map/index.tsx index f9beba6..08aec8b 100644 --- a/frontend/src/pages/map/index.tsx +++ b/frontend/src/pages/map/index.tsx @@ -7,6 +7,7 @@ export default function Map() { const params = new URLSearchParams([ ['apiUrl', `${process.env.API_URL}/graphql`], ['shipyardPolicyId', current().shipyardPolicyId], + ['fuelPolicyId', current().fuelPolicyId], ['shipAddress', current().shipAddress], ['fuelAddress', current().fuelAddress], ['asteriaAddress', current().asteriaAddress] diff --git a/frontend/src/stores/challenge.ts b/frontend/src/stores/challenge.ts index f73664c..1d82dd4 100644 --- a/frontend/src/stores/challenge.ts +++ b/frontend/src/stores/challenge.ts @@ -3,6 +3,7 @@ import { create } from 'zustand'; export interface Challenge { label: string; shipyardPolicyId: string; + fuelPolicyId: string; shipAddress: string; fuelAddress: string; asteriaAddress: string; @@ -19,18 +20,12 @@ export interface ChallengeStoreState { export const useChallengeStore = create((set, get) => ({ selected: 0, challenges: [{ - label: 'New challenge', - shipyardPolicyId: '06af6375746881387d42e09977ce826d49c4b1404ec14ca75aa4553b', - shipAddress: 'addr_test1wqr27cm4w35gzwragtsfja7wsfk5n393gp8vzn98t2j92wclzmt4v', - fuelAddress: 'addr_test1wrwy0q8xtcngksdxk7nxd8kxwxvssmha5kl62nyxk7dmuqsf3slrx', - asteriaAddress: 'addr_test1wr44k7mvy2aznjn5qk69xa5gax0fsxmv4q8n9xv9040kqjs9kcchd', - network: 'preview', - }, { - label: 'Builder fest workshop', - shipyardPolicyId: 'ecb96725c35e957f96be46bc1873cc8ae5b134f1b00f457675700511', - shipAddress: 'addr_test1wrktjee9cd0f2lukhertcxrnej9wtvf57xcq73tkw4cq2ygnz27xu', - fuelAddress: 'addr_test1wr37gywvcn3284cuxy4jke2w7np75jfm9apej7ns8d7n5ws3ecjrt', - asteriaAddress: 'addr_test1wzup673azpl4s09hckcxr496xpx6cghnhfhlj4ydsxwpf5qygteap', + label: 'Preview Challenge', + shipyardPolicyId: 'f9497fc64e87c4da4ec6d2bd1a839b6af10a77c10817db7143ac3d20', + fuelPolicyId: 'fc8ad4f84181b85dc04f7b8c2984b129284c4e272ef45cd6440575fd4655454c', + shipAddress: 'addr_test1wru5jl7xf6rufkjwcmft6x5rnd40zznhcyyp0km3gwkr6gq6sxzm6', + fuelAddress: 'addr_test1wr7g448cgxqmshwqfaacc2vyky5jsnzwyuh0ghxkgszhtlgzrxj63', + asteriaAddress: 'addr_test1wqdsuy97njefz53rkhd4v6a2kuqk0md5mrn996ygwekrdyq369wjg', network: 'preview', }], current: () => get().challenges[get().selected], diff --git a/godot-visualizer/resources/icons/icon_zoom_in.svg b/godot-visualizer/resources/icons/icon_zoom_in.svg new file mode 100644 index 0000000..d25c0cb --- /dev/null +++ b/godot-visualizer/resources/icons/icon_zoom_in.svg @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/godot-visualizer/resources/icons/icon_zoom_in.svg.import b/godot-visualizer/resources/icons/icon_zoom_in.svg.import new file mode 100644 index 0000000..36bd368 --- /dev/null +++ b/godot-visualizer/resources/icons/icon_zoom_in.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bwjppc04feraa" +path="res://.godot/imported/icon_zoom_in.svg-c0a53e4ecf202b16d23b304744ba265f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/icons/icon_zoom_in.svg" +dest_files=["res://.godot/imported/icon_zoom_in.svg-c0a53e4ecf202b16d23b304744ba265f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/godot-visualizer/resources/icons/icon_zoom_out.svg b/godot-visualizer/resources/icons/icon_zoom_out.svg new file mode 100644 index 0000000..a456bcd --- /dev/null +++ b/godot-visualizer/resources/icons/icon_zoom_out.svg @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/godot-visualizer/resources/icons/icon_zoom_out.svg.import b/godot-visualizer/resources/icons/icon_zoom_out.svg.import new file mode 100644 index 0000000..e679e74 --- /dev/null +++ b/godot-visualizer/resources/icons/icon_zoom_out.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://j1rgnsv8l1ne" +path="res://.godot/imported/icon_zoom_out.svg-5bfda24aaec1231dd5530623a02c2623.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/icons/icon_zoom_out.svg" +dest_files=["res://.godot/imported/icon_zoom_out.svg-5bfda24aaec1231dd5530623a02c2623.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/godot-visualizer/resources/textures/zoom_button.tres b/godot-visualizer/resources/textures/zoom_button.tres deleted file mode 100644 index 5814cf8..0000000 --- a/godot-visualizer/resources/textures/zoom_button.tres +++ /dev/null @@ -1,13 +0,0 @@ -[gd_resource type="StyleBoxFlat" format=3 uid="uid://dtipuahe6umv4"] - -[resource] -bg_color = Color(0.027451, 0.952941, 0.901961, 0.0980392) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -border_color = Color(0.027451, 0.952941, 0.901961, 1) -corner_radius_top_left = 20 -corner_radius_top_right = 20 -corner_radius_bottom_right = 20 -corner_radius_bottom_left = 20 diff --git a/godot-visualizer/scenes/main.tscn b/godot-visualizer/scenes/main.tscn index 31d55af..b82409b 100644 --- a/godot-visualizer/scenes/main.tscn +++ b/godot-visualizer/scenes/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=37 format=3 uid="uid://b5ypw8og4vdle"] +[gd_scene load_steps=38 format=3 uid="uid://b5ypw8og4vdle"] [ext_resource type="Script" path="res://scripts/main.gd" id="1_4dsde"] [ext_resource type="PackedScene" uid="uid://ch6xqejnd1rqf" path="res://scenes/map.tscn" id="1_quhpi"] @@ -23,20 +23,16 @@ [ext_resource type="Texture2D" uid="uid://3idp7n15cwd1" path="res://resources/icons/icon_token_inactive.svg" id="8_vjqgv"] [ext_resource type="Texture2D" uid="uid://c2u6fpdbxqbrt" path="res://resources/icons/icon_fuel_active.svg" id="10_ycgkw"] [ext_resource type="Texture2D" uid="uid://d28tctb3snsau" path="res://resources/icons/icon_token_active.svg" id="12_dpchl"] -[ext_resource type="StyleBox" uid="uid://dtipuahe6umv4" path="res://resources/textures/zoom_button.tres" id="24_0x7f7"] [ext_resource type="StyleBox" uid="uid://cuqtwls2gtt0v" path="res://resources/textures/tooltip.tres" id="25_q05r4"] [ext_resource type="FontFile" uid="uid://2ctrem352y4" path="res://resources/fonts/JetBrainsMono.ttf" id="26_btrf2"] +[ext_resource type="Texture2D" uid="uid://bwjppc04feraa" path="res://resources/icons/icon_zoom_in.svg" id="27_evo6j"] [ext_resource type="FontFile" uid="uid://b7vayqoopjyv" path="res://resources/fonts/DMSans.ttf" id="27_u6i6b"] +[ext_resource type="Texture2D" uid="uid://j1rgnsv8l1ne" path="res://resources/icons/icon_zoom_out.svg" id="28_kl1su"] [ext_resource type="Texture2D" uid="uid://dqpu7ll4k1fs1" path="res://resources/loader.png" id="28_wxhmh"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gt7hn"] bg_color = Color(1, 1, 1, 1) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_aclu6"] -bg_color = Color(0, 0, 0, 0) - -[sub_resource type="ButtonGroup" id="ButtonGroup_1ar33"] - [sub_resource type="LabelSettings" id="LabelSettings_jrdxu"] font = ExtResource("4_r2c3r") font_size = 64 @@ -49,6 +45,11 @@ base_font = ExtResource("4_r2c3r") [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ltxx7"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_aclu6"] +bg_color = Color(0, 0, 0, 0) + +[sub_resource type="ButtonGroup" id="ButtonGroup_1ar33"] + [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_iitb5"] [node name="Main" type="Node"] @@ -143,105 +144,6 @@ size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 2 -[node name="VBoxContainerStart" type="VBoxContainer" parent="GUICanvasLayer/HBoxContainer"] -layout_mode = 2 -alignment = 2 - -[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart"] -layout_mode = 2 -theme_override_constants/margin_left = 40 -theme_override_constants/margin_top = 40 -theme_override_constants/margin_right = 40 -theme_override_constants/margin_bottom = 40 - -[node name="VBoxContainer" type="VBoxContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer"] -layout_mode = 2 -size_flags_horizontal = 8 - -[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer"] -layout_mode = 2 - -[node name="MinimapBackground" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer"] -clip_contents = true -layout_mode = 2 -theme_override_styles/panel = ExtResource("3_n4qh8") -script = ExtResource("3_46wls") - -[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer"] -clip_contents = true -layout_mode = 2 -theme_override_constants/margin_left = 24 -theme_override_constants/margin_top = 24 -theme_override_constants/margin_right = 24 -theme_override_constants/margin_bottom = 24 - -[node name="Minimap" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer"] -custom_minimum_size = Vector2(800, 400) -layout_mode = 2 -size_flags_vertical = 10 -theme_override_styles/panel = SubResource("StyleBoxFlat_aclu6") -script = ExtResource("3_n1hxv") - -[node name="CenterContainer" type="CenterContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer"] -layout_mode = 2 - -[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer"] -layout_mode = 2 -theme_override_constants/margin_top = 40 - -[node name="MinimapControlPanel" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer"] -custom_minimum_size = Vector2(320, 120) -layout_mode = 2 -theme_override_styles/panel = ExtResource("6_fqp1o") - -[node name="CenterContainer" type="CenterContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 - -[node name="HBoxContainer" type="HBoxContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer"] -layout_mode = 2 -mouse_filter = 2 - -[node name="ShipButton" type="TextureButton" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer"] -custom_minimum_size = Vector2(88, 88) -layout_mode = 2 -mouse_filter = 1 -toggle_mode = true -action_mode = 0 -button_group = SubResource("ButtonGroup_1ar33") -texture_normal = ExtResource("6_0e6fi") -texture_pressed = ExtResource("8_8e8w0") -ignore_texture_size = true -stretch_mode = 0 - -[node name="FuelButton" type="TextureButton" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer"] -custom_minimum_size = Vector2(88, 88) -layout_mode = 2 -mouse_filter = 1 -toggle_mode = true -button_pressed = true -button_group = SubResource("ButtonGroup_1ar33") -texture_normal = ExtResource("7_wdsf5") -texture_pressed = ExtResource("10_ycgkw") -ignore_texture_size = true -stretch_mode = 0 - -[node name="TokenButton" type="TextureButton" parent="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer"] -custom_minimum_size = Vector2(88, 88) -layout_mode = 2 -mouse_filter = 1 -toggle_mode = true -button_group = SubResource("ButtonGroup_1ar33") -texture_normal = ExtResource("8_vjqgv") -texture_pressed = ExtResource("12_dpchl") -ignore_texture_size = true -stretch_mode = 0 - [node name="VBoxContainerEnd" type="VBoxContainer" parent="GUICanvasLayer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 10 @@ -426,47 +328,140 @@ theme_override_constants/margin_bottom = 40 [node name="HBoxContainer" type="HBoxContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom"] layout_mode = 2 +theme_override_constants/separation = 40 alignment = 2 [node name="VBoxContainer" type="VBoxContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer"] layout_mode = 2 -theme_override_constants/separation = 20 +size_flags_horizontal = 8 + +[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer"] +layout_mode = 2 + +[node name="MinimapBackground" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer"] +clip_contents = true +layout_mode = 2 +theme_override_styles/panel = ExtResource("3_n4qh8") +script = ExtResource("3_46wls") + +[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer"] +clip_contents = true +layout_mode = 2 +theme_override_constants/margin_left = 24 +theme_override_constants/margin_top = 24 +theme_override_constants/margin_right = 24 +theme_override_constants/margin_bottom = 24 + +[node name="Minimap" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer"] +custom_minimum_size = Vector2(800, 400) +layout_mode = 2 +size_flags_vertical = 10 +theme_override_styles/panel = SubResource("StyleBoxFlat_aclu6") +script = ExtResource("3_n1hxv") + +[node name="CenterContainer" type="CenterContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 40 + +[node name="MinimapControlPanel" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer"] +custom_minimum_size = Vector2(320, 120) +layout_mode = 2 +theme_override_styles/panel = ExtResource("6_fqp1o") + +[node name="CenterContainer" type="CenterContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer"] +layout_mode = 2 +mouse_filter = 2 + +[node name="ShipButton" type="TextureButton" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer"] +custom_minimum_size = Vector2(88, 88) +layout_mode = 2 +mouse_filter = 1 +toggle_mode = true +action_mode = 0 +button_group = SubResource("ButtonGroup_1ar33") +texture_normal = ExtResource("6_0e6fi") +texture_pressed = ExtResource("8_8e8w0") +ignore_texture_size = true +stretch_mode = 0 + +[node name="FuelButton" type="TextureButton" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer"] +custom_minimum_size = Vector2(88, 88) +layout_mode = 2 +mouse_filter = 1 +toggle_mode = true +button_pressed = true +button_group = SubResource("ButtonGroup_1ar33") +texture_normal = ExtResource("7_wdsf5") +texture_pressed = ExtResource("10_ycgkw") +ignore_texture_size = true +stretch_mode = 0 + +[node name="TokenButton" type="TextureButton" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer"] +custom_minimum_size = Vector2(88, 88) +layout_mode = 2 +mouse_filter = 1 +toggle_mode = true +button_group = SubResource("ButtonGroup_1ar33") +texture_normal = ExtResource("8_vjqgv") +texture_pressed = ExtResource("12_dpchl") +ignore_texture_size = true +stretch_mode = 0 + +[node name="MarginContainer" type="MarginContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 90 -[node name="PanelZoomPlus" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 40 + +[node name="PanelZoomPlus" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(120, 120) layout_mode = 2 -theme_override_styles/panel = ExtResource("24_0x7f7") +theme_override_styles/panel = ExtResource("6_fqp1o") -[node name="ZoomPlusButton" type="Button" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/PanelZoomPlus"] +[node name="ZoomPlusButton" type="Button" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer/VBoxContainer/PanelZoomPlus"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_fonts/font = ExtResource("7_nw756") -theme_override_font_sizes/font_size = 80 theme_override_styles/focus = SubResource("StyleBoxEmpty_iitb5") -text = "+" +icon = ExtResource("27_evo6j") flat = true +icon_alignment = 1 +expand_icon = true -[node name="PanelZoomLess" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer"] +[node name="PanelZoomLess" type="Panel" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(120, 120) layout_mode = 2 -theme_override_styles/panel = ExtResource("24_0x7f7") +theme_override_styles/panel = ExtResource("6_fqp1o") -[node name="ZoomLessButton" type="Button" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/PanelZoomLess"] +[node name="ZoomLessButton" type="Button" parent="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer/VBoxContainer/PanelZoomLess"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_fonts/font = ExtResource("7_nw756") -theme_override_font_sizes/font_size = 80 theme_override_styles/focus = SubResource("StyleBoxEmpty_iitb5") -text = "-" +icon = ExtResource("28_kl1su") flat = true +icon_alignment = 1 +expand_icon = true [node name="CenterContainer" type="CenterContainer" parent="GUICanvasLayer"] anchors_preset = 15 @@ -484,21 +479,13 @@ expand_mode = 1 stretch_mode = 3 [connection signal="dataset_updated" from="." to="MapCanvasLayer/Map" method="_on_main_dataset_updated"] -[connection signal="dataset_updated" from="." to="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_main_dataset_updated"] -[connection signal="camera_position_changed" from="MapCanvasLayer/Map" to="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_map_camera_position_changed"] -[connection signal="camera_zoom_changed" from="MapCanvasLayer/Map" to="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_map_camera_zoom_changed"] +[connection signal="dataset_updated" from="." to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_main_dataset_updated"] +[connection signal="camera_position_changed" from="MapCanvasLayer/Map" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_map_camera_position_changed"] +[connection signal="camera_zoom_changed" from="MapCanvasLayer/Map" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_map_camera_zoom_changed"] [connection signal="hide_tooltip" from="MapCanvasLayer/Map" to="." method="_on_map_hide_tooltip"] [connection signal="show_asteria_tooltip" from="MapCanvasLayer/Map" to="." method="_on_map_show_asteria_tooltip"] [connection signal="show_fuel_tooltip" from="MapCanvasLayer/Map" to="." method="_on_map_show_fuel_tooltip"] [connection signal="show_ship_tooltip" from="MapCanvasLayer/Map" to="." method="_on_map_show_ship_tooltip"] -[connection signal="minimap_position_changed" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" to="MapCanvasLayer/Map" method="_on_minimap_minimap_position_changed"] -[connection signal="mouse_entered" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" to="MapCanvasLayer/Map" method="_on_minimap_mouse_entered"] -[connection signal="mouse_exited" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" to="MapCanvasLayer/Map" method="_on_minimap_mouse_exited"] -[connection signal="mouse_entered" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel" to="MapCanvasLayer/Map" method="_on_minimap_control_panel_mouse_entered"] -[connection signal="mouse_exited" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel" to="MapCanvasLayer/Map" method="_on_minimap_control_panel_mouse_exited"] -[connection signal="toggled" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer/ShipButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_ship_button_toggled"] -[connection signal="toggled" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer/FuelButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_fuel_button_toggled"] -[connection signal="toggled" from="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer/TokenButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerStart/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_token_button_toggled"] [connection signal="mouse_entered" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel" to="MapCanvasLayer/Map" method="_on_modal_panel_mouse_entered"] [connection signal="mouse_exited" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel" to="MapCanvasLayer/Map" method="_on_modal_panel_mouse_exited"] [connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/CloseButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel" method="_on_close_button_pressed"] @@ -508,5 +495,13 @@ stretch_mode = 3 [connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/SidebarPanel/CenterContainer/VBoxContainer/MoveButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel" method="_on_move_button_pressed"] [connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/SidebarPanel/CenterContainer/VBoxContainer/GatherFuelButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel" method="_on_gather_fuel_button_pressed"] [connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/SidebarPanel/CenterContainer/VBoxContainer/MineTokenButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerTop/HBoxContainer/ModalPanel" method="_on_mine_token_button_pressed"] -[connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/PanelZoomPlus/ZoomPlusButton" to="MapCanvasLayer/Map" method="_on_zoom_plus_button_pressed"] -[connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/PanelZoomLess/ZoomLessButton" to="MapCanvasLayer/Map" method="_on_zoom_less_button_pressed"] +[connection signal="minimap_position_changed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" to="MapCanvasLayer/Map" method="_on_minimap_minimap_position_changed"] +[connection signal="mouse_entered" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" to="MapCanvasLayer/Map" method="_on_minimap_mouse_entered"] +[connection signal="mouse_exited" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" to="MapCanvasLayer/Map" method="_on_minimap_mouse_exited"] +[connection signal="mouse_entered" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel" to="MapCanvasLayer/Map" method="_on_minimap_control_panel_mouse_entered"] +[connection signal="mouse_exited" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel" to="MapCanvasLayer/Map" method="_on_minimap_control_panel_mouse_exited"] +[connection signal="toggled" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer/ShipButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_ship_button_toggled"] +[connection signal="toggled" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer/FuelButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_fuel_button_toggled"] +[connection signal="toggled" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/CenterContainer/MarginContainer/MinimapControlPanel/CenterContainer/HBoxContainer/TokenButton" to="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/VBoxContainer/MarginContainer/MarginContainer/Minimap" method="_on_token_button_toggled"] +[connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer/VBoxContainer/PanelZoomPlus/ZoomPlusButton" to="MapCanvasLayer/Map" method="_on_zoom_plus_button_pressed"] +[connection signal="pressed" from="GUICanvasLayer/HBoxContainer/VBoxContainerEnd/MarginContainerBottom/HBoxContainer/MarginContainer/VBoxContainer/PanelZoomLess/ZoomLessButton" to="MapCanvasLayer/Map" method="_on_zoom_less_button_pressed"] diff --git a/godot-visualizer/scripts/global.gd b/godot-visualizer/scripts/global.gd index c3713ba..f4658a9 100644 --- a/godot-visualizer/scripts/global.gd +++ b/godot-visualizer/scripts/global.gd @@ -1,6 +1,6 @@ extends Node -const grid_size = 200 +const grid_size = 80 const cell_size = 128 var ships: Array[ShipData] = [] diff --git a/godot-visualizer/scripts/main.gd b/godot-visualizer/scripts/main.gd index 4c6a866..1ca2f8f 100644 --- a/godot-visualizer/scripts/main.gd +++ b/godot-visualizer/scripts/main.gd @@ -6,6 +6,7 @@ const radius = 1000 var api_url = "" var shipyard_policy_id = "" +var fuel_policy_id = "" var ship_address = "" var fuel_address = "" var asteria_address = "" @@ -17,6 +18,7 @@ const query = """ center: { x: 0, y: 0 }, radius: %s, shipyardPolicyId: "%s", + fuelPolicyId: "%s", shipAddress: "%s", fuelAddress: "%s", asteriaAddress: "%s" @@ -51,6 +53,7 @@ func fetch_data(): "query": query % [ radius, shipyard_policy_id, + fuel_policy_id, ship_address, fuel_address, asteria_address @@ -65,6 +68,7 @@ func _process(delta: float) -> void: func _ready(): api_url = JavaScriptBridge.eval("new URL(window.location.href).searchParams.get('apiUrl')") shipyard_policy_id = JavaScriptBridge.eval("new URL(window.location.href).searchParams.get('shipyardPolicyId')") + fuel_policy_id = JavaScriptBridge.eval("new URL(window.location.href).searchParams.get('fuelPolicyId')") ship_address = JavaScriptBridge.eval("new URL(window.location.href).searchParams.get('shipAddress')") fuel_address = JavaScriptBridge.eval("new URL(window.location.href).searchParams.get('fuelAddress')") asteria_address = JavaScriptBridge.eval("new URL(window.location.href).searchParams.get('asteriaAddress')") diff --git a/godot-visualizer/scripts/orbits.gd b/godot-visualizer/scripts/orbits.gd index 54e8210..d06006d 100644 --- a/godot-visualizer/scripts/orbits.gd +++ b/godot-visualizer/scripts/orbits.gd @@ -5,10 +5,10 @@ func _draw(): var grid_size = Global.get_grid_size() var cell_size = Global.get_cell_size() - for i in range(4, grid_size/2, 2): + for i in range(4, grid_size/2, 4): draw_circle(Vector2(0, 0), i * cell_size + (cell_size/2), Color("#FFF75D", .15), false, 2, true) # TODO: Improve this - for i in range(grid_size/2, grid_size/(PI/2)+PI, 2): + for i in range(grid_size/2+2, grid_size/(PI/2)+PI, 4): var opacity = (round(grid_size/(PI/2)+PI)-i-2)/(round(grid_size/(PI/2)+PI)-grid_size/2-2) * .15 draw_circle(Vector2(0, 0), i * cell_size + (cell_size/2), Color("#FFF75D", opacity), false, 2, true)