diff --git a/config/game-config.json b/config/game-config.json index 172b293..baebc3c 100644 --- a/config/game-config.json +++ b/config/game-config.json @@ -11,57 +11,13 @@ }, "store": [ { - "id": "item1", - "name": "Drill A", - "description": "This is drill A", - "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, - "upgrades": [ - { "tier": 1, "price": 200, "claimBoost": 10 }, - { "tier": 2, "price": 300, "claimBoost": 20 }, - { "tier": 3, "price": 400, "claimBoost": 30 }, - { "tier": 4, "price": 500, "claimBoost": 40 }, - { "tier": 5, "price": 600, "claimBoost": 50 } - ] - }, - { - "id": "item2", - "name": "Drill B", - "description": "This is drill B", - "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, - "upgrades": [ - { "tier": 1, "price": 200, "claimBoost": 10 }, - { "tier": 2, "price": 300, "claimBoost": 20 }, - { "tier": 3, "price": 400, "claimBoost": 30 }, - { "tier": 4, "price": 500, "claimBoost": 40 }, - { "tier": 5, "price": 600, "claimBoost": 50 } - ] - }, - { - "id": "item3", - "name": "Drill C", - "description": "This is drill C", - "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, - "upgrades": [ - { "tier": 1, "price": 200, "claimBoost": 10 }, - { "tier": 2, "price": 300, "claimBoost": 20 }, - { "tier": 3, "price": 400, "claimBoost": 30 }, - { "tier": 4, "price": 500, "claimBoost": 40 }, - { "tier": 5, "price": 600, "claimBoost": 50 } - ] - }, - { - "id": "item4", - "name": "Drill D", - "description": "This is drill D", + "id": "item1", + "name": "LunarLite L100", + "description": "LunarLite L100 is a lightweight, entry-level drill designed for beginners. With its easy-to-use interface and moderate drilling speed, it's perfect for getting started with lunar resource extraction.", + "image": "/assets/drill_1.jpg", "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, + "claimAmount": 10, + "completionTimeInMins": 1, "upgrades": [ { "tier": 1, "price": 200, "claimBoost": 10 }, { "tier": 2, "price": 300, "claimBoost": 20 }, @@ -69,51 +25,54 @@ { "tier": 4, "price": 500, "claimBoost": 40 }, { "tier": 5, "price": 600, "claimBoost": 50 } ] - }, - { - "id": "item5", - "name": "Drill E", - "description": "This is drill E", - "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, - "upgrades": [ - { "tier": 1, "price": 200, "claimBoost": 10 }, - { "tier": 2, "price": 300, "claimBoost": 20 }, - { "tier": 3, "price": 400, "claimBoost": 30 }, - { "tier": 4, "price": 500, "claimBoost": 40 }, - { "tier": 5, "price": 600, "claimBoost": 50 } - ] -}, -{ - "id": "item6", - "name": "Drill F", - "description": "This is drill F", - "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, - "upgrades": [ - { "tier": 1, "price": 200, "claimBoost": 10 }, - { "tier": 2, "price": 300, "claimBoost": 20 }, - { "tier": 3, "price": 400, "claimBoost": 30 }, - { "tier": 4, "price": 500, "claimBoost": 40 }, - { "tier": 5, "price": 600, "claimBoost": 50 } - ] -}, -{ - "id": "item7", - "name": "Drill G", - "description": "This is drill G", - "price": 250, - "claimAmount": 50, - "completionTimeInMins": 5, - "upgrades": [ - { "tier": 1, "price": 200, "claimBoost": 10 }, - { "tier": 2, "price": 300, "claimBoost": 20 }, - { "tier": 3, "price": 400, "claimBoost": 30 }, - { "tier": 4, "price": 500, "claimBoost": 40 }, - { "tier": 5, "price": 600, "claimBoost": 50 } - ] -} + }, + { + "id": "item2", + "name": "Lunar Regolith Extractor LRE-3000", + "description": "The LRE-3000 is a high-efficiency drill designed for extracting regolith, the lunar soil composed of small rocks, dust, and other materials. This drill utilizes a unique auger system to bore into the moon's surface and collect regolith for further processing, ensuring minimal waste and maximum resource extraction.", + "image": "/assets/drill_2.jpg", + "price": 400, + "claimAmount": 75, + "completionTimeInMins": 5, + "upgrades": [ + { "tier": 1, "price": 200, "claimBoost": 10 }, + { "tier": 2, "price": 300, "claimBoost": 30 }, + { "tier": 3, "price": 400, "claimBoost": 40 }, + { "tier": 4, "price": 500, "claimBoost": 50 }, + { "tier": 5, "price": 600, "claimBoost": 60 } + ] + }, + { + "id": "item3", + "name": "Electrostatic Dust Excavator EDE-700", + "description": "The EDE-700 is a specialized excavator designed to collect fine lunar dust, which is rich in valuable elements such as helium-3, a potential fuel for future fusion reactors. The machine uses an electrostatic system to attract and capture dust particles, allowing for efficient collection and reduced risk of hazardous dust exposure for operators.", + "image": "/assets/drill_3.jpg", + "price": 1000, + "claimAmount": 100, + "completionTimeInMins": 30, + "upgrades": [ + { "tier": 1, "price": 200, "claimBoost": 25 }, + { "tier": 2, "price": 300, "claimBoost": 50 }, + { "tier": 3, "price": 400, "claimBoost": 75 }, + { "tier": 4, "price": 500, "claimBoost": 100 }, + { "tier": 5, "price": 600, "claimBoost": 150 } + ] + }, + { + "id": "item4", + "name": "Lunar Core Extractor LCE-360", + "description": "The LCE-360 is a sophisticated drill designed to extract core samples from the moon's surface and subsurface layers. With its adjustable coring system, this machine can retrieve samples of various depths and diameters, providing valuable information about the moon's geological history and enabling efficient extraction of embedded resources.", + "image": "/assets/drill_4.jpg", + "price": 5000, + "claimAmount": 500, + "completionTimeInMins": 120, + "upgrades": [ + { "tier": 1, "price": 200, "claimBoost": 10 }, + { "tier": 2, "price": 300, "claimBoost": 20 }, + { "tier": 3, "price": 400, "claimBoost": 30 }, + { "tier": 4, "price": 500, "claimBoost": 40 }, + { "tier": 5, "price": 600, "claimBoost": 50 } + ] + } ] } diff --git a/package-lock.json b/package-lock.json index 64501b8..380e6a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,12 +13,10 @@ "@types/node": "18.13.0", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", - "chart.js": "^4.2.1", "eslint": "8.33.0", "eslint-config-next": "13.1.6", "next": "13.1.6", "react": "18.2.0", - "react-chartjs-2": "^5.2.0", "react-dom": "18.2.0", "sqlite": "^4.1.2", "sqlite3": "^5.1.4", @@ -99,11 +97,6 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, - "node_modules/@kurkle/color": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", - "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==" - }, "node_modules/@mapbox/node-pre-gyp": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", @@ -1245,17 +1238,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/chart.js": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.2.1.tgz", - "integrity": "sha512-6YbpQ0nt3NovAgOzbkSSeeAQu/3za1319dPUQTXn9WcOpywM8rGKxJHrhS8V8xEkAlk8YhEfjbuAPfUyp6jIsw==", - "dependencies": { - "@kurkle/color": "^0.3.0" - }, - "engines": { - "pnpm": "^7.0.0" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -4248,15 +4230,6 @@ "node": ">=0.10.0" } }, - "node_modules/react-chartjs-2": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", - "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", - "peerDependencies": { - "chart.js": "^4.1.1", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -5317,11 +5290,6 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, - "@kurkle/color": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", - "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==" - }, "@mapbox/node-pre-gyp": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", @@ -6062,14 +6030,6 @@ "supports-color": "^7.1.0" } }, - "chart.js": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.2.1.tgz", - "integrity": "sha512-6YbpQ0nt3NovAgOzbkSSeeAQu/3za1319dPUQTXn9WcOpywM8rGKxJHrhS8V8xEkAlk8YhEfjbuAPfUyp6jIsw==", - "requires": { - "@kurkle/color": "^0.3.0" - } - }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -8184,12 +8144,6 @@ "loose-envify": "^1.1.0" } }, - "react-chartjs-2": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", - "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", - "requires": {} - }, "react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", diff --git a/package.json b/package.json index f428f7d..d6eb45d 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,10 @@ "@types/node": "18.13.0", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", - "chart.js": "^4.2.1", "eslint": "8.33.0", "eslint-config-next": "13.1.6", "next": "13.1.6", "react": "18.2.0", - "react-chartjs-2": "^5.2.0", "react-dom": "18.2.0", "sqlite": "^4.1.2", "sqlite3": "^5.1.4", diff --git a/public/assets/drill_1.jpg b/public/assets/drill_1.jpg new file mode 100644 index 0000000..056e904 Binary files /dev/null and b/public/assets/drill_1.jpg differ diff --git a/public/assets/drill_2.jpg b/public/assets/drill_2.jpg new file mode 100644 index 0000000..249e317 Binary files /dev/null and b/public/assets/drill_2.jpg differ diff --git a/public/assets/drill_3.jpg b/public/assets/drill_3.jpg new file mode 100644 index 0000000..229c6ff Binary files /dev/null and b/public/assets/drill_3.jpg differ diff --git a/public/assets/drill_4.jpg b/public/assets/drill_4.jpg new file mode 100644 index 0000000..0d82ec7 Binary files /dev/null and b/public/assets/drill_4.jpg differ diff --git a/src/app/Components/BankAccountsView.tsx b/src/app/Components/BankAccountsView.tsx index 265588c..27e258d 100644 --- a/src/app/Components/BankAccountsView.tsx +++ b/src/app/Components/BankAccountsView.tsx @@ -13,7 +13,9 @@ const BankAccountsView = (props: {
Moonbucks -

$5,342.23

+

+ ${props.bankAccount?.primaryBalance} +

- ) : ( - - )} +
+ {isInUse() ? ( + + ) : ( + + )} +
+
+ {props.inventoryItem.storeItem.name} +
); diff --git a/src/app/Components/ResourceStore.tsx b/src/app/Components/ResourceStore.tsx index 31d5ac4..50e5172 100644 --- a/src/app/Components/ResourceStore.tsx +++ b/src/app/Components/ResourceStore.tsx @@ -23,10 +23,7 @@ const ResourceStore = (props: { } }, []); - const handleAmountChange = ( - e: React.ChangeEvent, - resourceType: string - ) => { + const handleConversionPairs = (amount: number, resourceType: string) => { if (!conversionPairs) return; const existingObj = conversionPairs.find( @@ -37,8 +34,8 @@ const ResourceStore = (props: { if (pair.resourceType === existingObj?.resourceType) { return { ...pair, - resourceAmount: Number(e.target.value), - moneyAmount: Number(e.target.value) * conversionRate.valueOf(), + resourceAmount: amount, + moneyAmount: amount * conversionRate.valueOf(), }; } else { return pair; @@ -51,7 +48,11 @@ const ResourceStore = (props: { return conversionPairs?.find((obj) => obj.resourceType === resourceType); }; - console.log(conversionPairs); + const handleSellResources = () => { + // Do something.. + console.log(conversionPairs); + }; + return (

@@ -68,18 +69,16 @@ const ResourceStore = (props: { conversionPair={getConversionPair( resourceAccount.resourceType )} - handleAmountChange={handleAmountChange} + handleConversionPairs={handleConversionPairs} />

))} {conversionPairs && ( -
-

- Grand total -

-

+

+

Grand total

+

${" "} {sumValues(conversionPairs, "moneyAmount").toLocaleString( "en-US", @@ -89,7 +88,10 @@ const ResourceStore = (props: { } )}

-
diff --git a/src/app/Components/ResourceStoreItem.tsx b/src/app/Components/ResourceStoreItem.tsx index dbdebe5..bc8dffb 100644 --- a/src/app/Components/ResourceStoreItem.tsx +++ b/src/app/Components/ResourceStoreItem.tsx @@ -6,11 +6,22 @@ import { resourceToBg, resourceToFc } from "../../utils/helpers"; const ResourceStoreItem = (props: { resourceAccount: IResourceAccount; conversionPair: IConversionPair | undefined; - handleAmountChange: ( + handleConversionPairs: (amount: number, resourceType: string) => void; +}) => { + const [error, setError] = useState(""); + + const handleAmountChange = ( e: React.ChangeEvent, resourceType: string - ) => void; -}) => { + ) => { + const amount = Number(e.target.value); + if (amount <= props.resourceAccount.balance) { + props.handleConversionPairs(amount, resourceType); + if (error) setError(""); + } else { + setError("You don't have enough"); + } + }; return (
@@ -91,14 +102,19 @@ const ResourceStoreItem = (props: { ) : (
)} - - props.handleAmountChange(e, props.resourceAccount.resourceType) - } - /> +
+ {error && ( + {error} + )} + + handleAmountChange(e, props.resourceAccount.resourceType) + } + /> +
); }; diff --git a/src/app/Components/SelectDropdown.tsx b/src/app/Components/SelectDropdown.tsx index 1b25992..6dbb435 100644 --- a/src/app/Components/SelectDropdown.tsx +++ b/src/app/Components/SelectDropdown.tsx @@ -23,7 +23,7 @@ const SelectDropdown: React.FC = (props) => { onChange={handleChange} className="text-black flex-1 p-2 border border-gray-300 rounded-lg" > - + {props.options.map((option, index) => (