From b2ac098fdb4afba33413a273bf4e7d13e9c4c1b3 Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:23:30 -0500 Subject: [PATCH 1/3] establishing layout for mern stack --- .gitignore | 24 +------- client/.gitignore | 23 +++++++ package-lock.json => client/package-lock.json | 58 ++++++++++++++++++ package.json => client/package.json | 1 + {public => client/public}/favicon.ico | Bin {public => client/public}/index.html | 0 {public => client/public}/logo192.png | Bin {public => client/public}/logo512.png | Bin {public => client/public}/manifest.json | 0 {public => client/public}/robots.txt | 0 {src => client/src}/App.css | 0 client/src/App.js | 18 ++++++ {src => client/src}/App.test.js | 0 client/src/components/Welcome.js | 13 ++++ {src => client/src}/index.css | 0 {src => client/src}/index.js | 0 {src => client/src}/logo.svg | 0 {src => client/src}/reportWebVitals.js | 0 {src => client/src}/setupTests.js | 0 src/App.js | 25 -------- 20 files changed, 114 insertions(+), 48 deletions(-) create mode 100644 client/.gitignore rename package-lock.json => client/package-lock.json (99%) rename package.json => client/package.json (95%) rename {public => client/public}/favicon.ico (100%) rename {public => client/public}/index.html (100%) rename {public => client/public}/logo192.png (100%) rename {public => client/public}/logo512.png (100%) rename {public => client/public}/manifest.json (100%) rename {public => client/public}/robots.txt (100%) rename {src => client/src}/App.css (100%) create mode 100644 client/src/App.js rename {src => client/src}/App.test.js (100%) create mode 100644 client/src/components/Welcome.js rename {src => client/src}/index.css (100%) rename {src => client/src}/index.js (100%) rename {src => client/src}/logo.svg (100%) rename {src => client/src}/reportWebVitals.js (100%) rename {src => client/src}/setupTests.js (100%) delete mode 100644 src/App.js 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/Welcome.js b/client/src/components/Welcome.js new file mode 100644 index 0000000..2b64060 --- /dev/null +++ b/client/src/components/Welcome.js @@ -0,0 +1,13 @@ +export default function Welcome() { + return ( + <> +

Welcome to Splinter

+

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

+ +

Choose from the options below:

+
+ +
+ + ) +} \ 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; From 93a3c47bcbab2ed38883e8922a59d2273c1f39ec Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Tue, 29 Mar 2022 13:21:55 -0500 Subject: [PATCH 2/3] formatting for localmulti form --- .../GameConfigForms/CpuMultiForm.js | 7 ++ .../GameConfigForms/LocalMultiForm.js | 76 +++++++++++++++++++ client/src/components/Welcome.js | 47 +++++++++++- 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 client/src/components/GameConfigForms/CpuMultiForm.js create mode 100644 client/src/components/GameConfigForms/LocalMultiForm.js 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..90c2594 --- /dev/null +++ b/client/src/components/GameConfigForms/LocalMultiForm.js @@ -0,0 +1,76 @@ +import { useState, useEffect } from "react"; + +const formVariants = [ + <> { /* Fragment, expects to be concatenated as necessary within a
element */ } + { /* Player one and two base; index 0 */ } + + console.log(e.target.value)}> + + console.log(e.target.value)}> + + , + <> { /* Player three add on */ } + + console.log(e.target.value)}> + + , + <> + + console.log(e.target.value)}> + +]; + + + +export default function LocalMultiForm() { + const [players, setPlayers] = useState(null); + const [formVariant, setFormVariant] = useState(null); + const [playerNames, setPlayerNames] = useState({ + playerOne: null, + playerTwo: null, + playerThree: null, + playerFour: null + }); + + 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/Welcome.js b/client/src/components/Welcome.js index 2b64060..5e5a9f0 100644 --- a/client/src/components/Welcome.js +++ b/client/src/components/Welcome.js @@ -1,4 +1,37 @@ +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

@@ -6,8 +39,20 @@ export default function Welcome() {

Choose from the options below:

- +
+ + handleChange(e)}> +
+
+ + handleChange(e)}> +
+ + {localMulti ? : null} + {cpuMulti ? : null} + + ) } \ No newline at end of file From 0b16b3c9637554005ceda201177f83635cf3011e Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Tue, 29 Mar 2022 13:36:37 -0500 Subject: [PATCH 3/3] laying out some game related objets --- client/src/components/Cards/Card.js | 16 ++++++ client/src/components/Cards/Deck.js | 0 client/src/components/Cards/Inventory.js | 40 ++++++++++++++ client/src/components/Cards/Materials.js | 0 .../GameConfigForms/LocalMultiForm.js | 54 +++++++++---------- client/src/components/InitialCards.json | 0 6 files changed, 82 insertions(+), 28 deletions(-) create mode 100644 client/src/components/Cards/Card.js create mode 100644 client/src/components/Cards/Deck.js create mode 100644 client/src/components/Cards/Inventory.js create mode 100644 client/src/components/Cards/Materials.js create mode 100644 client/src/components/InitialCards.json 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/LocalMultiForm.js b/client/src/components/GameConfigForms/LocalMultiForm.js index 90c2594..43ea700 100644 --- a/client/src/components/GameConfigForms/LocalMultiForm.js +++ b/client/src/components/GameConfigForms/LocalMultiForm.js @@ -1,36 +1,34 @@ import { useState, useEffect } from "react"; -const formVariants = [ - <> { /* Fragment, expects to be concatenated as necessary within a
element */ } - { /* Player one and two base; index 0 */ } - - console.log(e.target.value)}> - - console.log(e.target.value)}> - - , - <> { /* Player three add on */ } - - console.log(e.target.value)}> - - , - <> - - console.log(e.target.value)}> - -]; - - - export default function LocalMultiForm() { const [players, setPlayers] = useState(null); const [formVariant, setFormVariant] = useState(null); - const [playerNames, setPlayerNames] = useState({ - playerOne: null, - playerTwo: null, - playerThree: null, - playerFour: 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) { diff --git a/client/src/components/InitialCards.json b/client/src/components/InitialCards.json new file mode 100644 index 0000000..e69de29