diff --git a/.gitignore b/.gitignore index 4d29575..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* +node_modules diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 0000000..4d29575 --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/package-lock.json b/client/package-lock.json similarity index 99% rename from package-lock.json rename to client/package-lock.json index 55b52be..a8f47d0 100644 --- a/package-lock.json +++ b/client/package-lock.json @@ -13,6 +13,7 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.0.0", "react-dom": "^18.0.0", + "react-router-dom": "^6.2.2", "react-scripts": "5.0.0", "web-vitals": "^2.1.4" } @@ -7965,6 +7966,14 @@ "he": "bin/he" } }, + "node_modules/history": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", + "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", + "dependencies": { + "@babel/runtime": "^7.7.6" + } + }, "node_modules/hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -13243,6 +13252,30 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.2.tgz", + "integrity": "sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==", + "dependencies": { + "history": "^5.2.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.2.tgz", + "integrity": "sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==", + "dependencies": { + "history": "^5.2.0", + "react-router": "6.2.2" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/react-scripts": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.0.tgz", @@ -21781,6 +21814,14 @@ "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" }, + "history": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", + "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", + "requires": { + "@babel/runtime": "^7.7.6" + } + }, "hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -25453,6 +25494,23 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", "integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==" }, + "react-router": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.2.tgz", + "integrity": "sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==", + "requires": { + "history": "^5.2.0" + } + }, + "react-router-dom": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.2.tgz", + "integrity": "sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==", + "requires": { + "history": "^5.2.0", + "react-router": "6.2.2" + } + }, "react-scripts": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.0.tgz", diff --git a/package.json b/client/package.json similarity index 95% rename from package.json rename to client/package.json index f065883..59d524c 100644 --- a/package.json +++ b/client/package.json @@ -8,6 +8,7 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.0.0", "react-dom": "^18.0.0", + "react-router-dom": "^6.2.2", "react-scripts": "5.0.0", "web-vitals": "^2.1.4" }, diff --git a/public/favicon.ico b/client/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to client/public/favicon.ico diff --git a/public/index.html b/client/public/index.html similarity index 100% rename from public/index.html rename to client/public/index.html diff --git a/public/logo192.png b/client/public/logo192.png similarity index 100% rename from public/logo192.png rename to client/public/logo192.png diff --git a/public/logo512.png b/client/public/logo512.png similarity index 100% rename from public/logo512.png rename to client/public/logo512.png diff --git a/public/manifest.json b/client/public/manifest.json similarity index 100% rename from public/manifest.json rename to client/public/manifest.json diff --git a/public/robots.txt b/client/public/robots.txt similarity index 100% rename from public/robots.txt rename to client/public/robots.txt diff --git a/src/App.css b/client/src/App.css similarity index 100% rename from src/App.css rename to client/src/App.css diff --git a/client/src/App.js b/client/src/App.js new file mode 100644 index 0000000..93d5281 --- /dev/null +++ b/client/src/App.js @@ -0,0 +1,18 @@ +import './App.css'; +import { Routes, Route, BrowserRouter } from 'react-router-dom'; + +import Welcome from './components/Welcome'; + +function App() { + return ( +
+ + + }/> + + +
+ ); +} + +export default App; diff --git a/src/App.test.js b/client/src/App.test.js similarity index 100% rename from src/App.test.js rename to client/src/App.test.js diff --git a/client/src/components/Cards/Card.js b/client/src/components/Cards/Card.js new file mode 100644 index 0000000..378f9e5 --- /dev/null +++ b/client/src/components/Cards/Card.js @@ -0,0 +1,16 @@ +export default class Card { + constructor(state) { + this.state = { + tier: state.tier, + points: state.points, + isWorth: state.worth, + cost: { + acorns: state.cost.acorns, + pineCones: state.cost.pineCones, + walnuts: state.cost.walnuts, + apples: state.cost.apples, + twigs: state.cost.twigs + } + }; + } +} \ No newline at end of file diff --git a/client/src/components/Cards/Deck.js b/client/src/components/Cards/Deck.js new file mode 100644 index 0000000..e69de29 diff --git a/client/src/components/Cards/Inventory.js b/client/src/components/Cards/Inventory.js new file mode 100644 index 0000000..d7aeb9d --- /dev/null +++ b/client/src/components/Cards/Inventory.js @@ -0,0 +1,40 @@ +import Card from "./Card"; + +export default class Inventory { + constructor(state) { + this.state = { + materials: { + acorns: state.acorns, + pineCones: state.pineCones, + walnuts: state.walnuts, + apples: state.apples, + twigs: state.twigs, + resin: state.resin + }, + reservedCards: [], + cardsInInventory: [] + }; + } + + sortCards() { + for (let card of this.cardsInInventory) { + // sorting algorithm of some kind + return card; + } + } + + pickUpCard(card) { + if (!card instanceof Card) { + throw new Error("card is not card!"); + } + + this.state.cardsInInventory.push(card); + this.sortCards(); + } + + reserveCard(card) { + if (!this.state.materials.resin) { + return; + } + } +} \ No newline at end of file diff --git a/client/src/components/Cards/Materials.js b/client/src/components/Cards/Materials.js new file mode 100644 index 0000000..e69de29 diff --git a/client/src/components/GameConfigForms/CpuMultiForm.js b/client/src/components/GameConfigForms/CpuMultiForm.js new file mode 100644 index 0000000..03892ef --- /dev/null +++ b/client/src/components/GameConfigForms/CpuMultiForm.js @@ -0,0 +1,7 @@ +export default function CpuMultiForm() { + return ( +
+

AI and stuff?

+
+ ) +} \ No newline at end of file diff --git a/client/src/components/GameConfigForms/LocalMultiForm.js b/client/src/components/GameConfigForms/LocalMultiForm.js new file mode 100644 index 0000000..43ea700 --- /dev/null +++ b/client/src/components/GameConfigForms/LocalMultiForm.js @@ -0,0 +1,74 @@ +import { useState, useEffect } from "react"; + +export default function LocalMultiForm() { + const [players, setPlayers] = useState(null); + const [formVariant, setFormVariant] = useState(null); + const [playerOne, setPlayerOne] = useState(''); + const [playerTwo, setPlayerTwo] = useState(''); + const [playerThree, setPlayerThree] = useState(''); + const [playerFour, setPlayerFour] = useState(''); + + const formVariants = [ + <> { /* Fragment, expects to be concatenated as necessary within a
element */ } + { /* Player one and two base; index 0 */ } + + setPlayerOne(e.target.value)}> + + setPlayerTwo(e.target.value)}> + + , + <> { /* Player three add on */ } + + setPlayerThree(e.target.value)}> + + , + <> + + setPlayerFour(e.target.value)}> + + ]; + + // useEffect for player form logic + + useEffect(() => { + switch (players) { + case "2": + setFormVariant(formVariants[0]); + break; + case "3": + setFormVariant([formVariants[0], formVariants[1]]); + break; + case "4": + setFormVariant([...formVariants]); + break; + default: + console.log("none"); + break; + } + }, [players]); + + return ( + <> + +

Number of players:

+ +
+ + setPlayers(e.target.id)}> +
+
+ + setPlayers(e.target.id)}> +
+
+ + setPlayers(e.target.id)}> +
+
+ +
+ {formVariant} +
+ + ) +} \ No newline at end of file diff --git a/client/src/components/InitialCards.json b/client/src/components/InitialCards.json new file mode 100644 index 0000000..e69de29 diff --git a/client/src/components/Welcome.js b/client/src/components/Welcome.js new file mode 100644 index 0000000..5e5a9f0 --- /dev/null +++ b/client/src/components/Welcome.js @@ -0,0 +1,58 @@ +import { useState, useRef } from "react" +import LocalMultiForm from "./GameConfigForms/LocalMultiForm"; +import CpuMultiForm from "./GameConfigForms/CpuMultiForm"; + +export default function Welcome() { + const [localMulti, setLocalMulti] = useState(false); + const [cpuMulti, setCpuMulti] = useState(false); + + const [value, setValue] = useState(''); + + const localMultiRadio = useRef(); + const cpuRadio = useRef(); + + const handleChange = (e) => { + setValue(e.target.id); + + if (e.target.id === 'local-multi') { + setLocalMulti(true); + setCpuMulti(false); + } else { + setLocalMulti(false); + setCpuMulti(true); + } + } + + const handleClear = () => { + localMultiRadio.current.checked = false; + cpuRadio.current.checked = false; + + setLocalMulti(false); + setCpuMulti(false); + setValue(''); + } + + return ( + <> +

Welcome to Splinter

+

Compete with your friends to have the lowest
possible amount of resources to your name!

+ +

Choose from the options below:

+
+
+ + handleChange(e)}> +
+
+ + handleChange(e)}> +
+
+ + {localMulti ? : null} + {cpuMulti ? : null} + + + + ) +} \ No newline at end of file diff --git a/src/index.css b/client/src/index.css similarity index 100% rename from src/index.css rename to client/src/index.css diff --git a/src/index.js b/client/src/index.js similarity index 100% rename from src/index.js rename to client/src/index.js diff --git a/src/logo.svg b/client/src/logo.svg similarity index 100% rename from src/logo.svg rename to client/src/logo.svg diff --git a/src/reportWebVitals.js b/client/src/reportWebVitals.js similarity index 100% rename from src/reportWebVitals.js rename to client/src/reportWebVitals.js diff --git a/src/setupTests.js b/client/src/setupTests.js similarity index 100% rename from src/setupTests.js rename to client/src/setupTests.js diff --git a/src/App.js b/src/App.js deleted file mode 100644 index 3784575..0000000 --- a/src/App.js +++ /dev/null @@ -1,25 +0,0 @@ -import logo from './logo.svg'; -import './App.css'; - -function App() { - return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
- ); -} - -export default App;