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] 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