setting up reducer/context structure
This commit is contained in:
@@ -1,38 +1,14 @@
|
|||||||
.App {
|
.App {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
|
||||||
|
|
||||||
.App-logo {
|
|
||||||
height: 40vmin;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
|
||||||
.App-logo {
|
|
||||||
animation: App-logo-spin infinite 20s linear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.App-header {
|
|
||||||
background-color: #282c34;
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: calc(10px + 2vmin);
|
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.App-link {
|
.gameboard {
|
||||||
color: #61dafb;
|
display: flex;
|
||||||
}
|
flex-direction: column;
|
||||||
|
width: 95vw;
|
||||||
@keyframes App-logo-spin {
|
height: 75vh;
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ import './App.css';
|
|||||||
import { Routes, Route, BrowserRouter } from 'react-router-dom';
|
import { Routes, Route, BrowserRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import Welcome from './components/Welcome';
|
import Welcome from './components/Welcome';
|
||||||
import GameBoard from './components/Game/GameBoard';
|
import FulLGameView from './components/Game/FullGameView';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -10,7 +10,7 @@ function App() {
|
|||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Welcome />}/>
|
<Route path="/" element={<Welcome />}/>
|
||||||
<Route path="/gameboard" element={<GameBoard />}/>
|
<Route path="/gameboard" element={<FulLGameView />}/>
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
9
client/src/components/Game/FullGameView.js
Normal file
9
client/src/components/Game/FullGameView.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import GameBoard from "./GameBoard";
|
||||||
|
|
||||||
|
export default function FulLGameView() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GameBoard />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -12,11 +12,9 @@ export default function GameBoard() {
|
|||||||
const [tierTwo, setTierTwo] = useState(null);
|
const [tierTwo, setTierTwo] = useState(null);
|
||||||
const [tierOne, setTierOne] = useState(null);
|
const [tierOne, setTierOne] = useState(null);
|
||||||
|
|
||||||
const [content, setContent] = useState(null);
|
|
||||||
|
|
||||||
const AllDecks = [TierOneDeck, TierTwoDeck, TierThreeDeck];
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const AllDecks = [TierOneDeck, TierTwoDeck, TierThreeDeck];
|
||||||
|
|
||||||
// param limit sets limit on number of cards rendered
|
// param limit sets limit on number of cards rendered
|
||||||
// param tier filters by card tier
|
// param tier filters by card tier
|
||||||
const buildGameBoardRow = (limit, tier) => {
|
const buildGameBoardRow = (limit, tier) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Card from "./Card";
|
import Card from "../Cards/Card";
|
||||||
|
|
||||||
export default class Inventory {
|
export default class Inventory {
|
||||||
constructor(state) {
|
constructor(state) {
|
||||||
11
client/src/components/Game/PlayerInventory.js
Normal file
11
client/src/components/Game/PlayerInventory.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { useState } from "react"
|
||||||
|
|
||||||
|
export default function PlayerInventory({ name }) {
|
||||||
|
const [materials, setMaterials] = useState(null);
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
52
client/src/components/Game/Spirits.js
Normal file
52
client/src/components/Game/Spirits.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
export const Spirits = [
|
||||||
|
{
|
||||||
|
img: 'img src',
|
||||||
|
cost: {
|
||||||
|
cedar: 7,
|
||||||
|
birch: 0,
|
||||||
|
walnut: 0,
|
||||||
|
mahogany: 0,
|
||||||
|
cherry: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
img: 'img src',
|
||||||
|
cost: {
|
||||||
|
cedar: 7,
|
||||||
|
birch: 0,
|
||||||
|
walnut: 0,
|
||||||
|
mahogany: 0,
|
||||||
|
cherry: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
img: 'img src',
|
||||||
|
cost: {
|
||||||
|
cedar: 7,
|
||||||
|
birch: 0,
|
||||||
|
walnut: 0,
|
||||||
|
mahogany: 0,
|
||||||
|
cherry: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
img: 'img src',
|
||||||
|
cost: {
|
||||||
|
cedar: 7,
|
||||||
|
birch: 0,
|
||||||
|
walnut: 0,
|
||||||
|
mahogany: 0,
|
||||||
|
cherry: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
img: 'img src',
|
||||||
|
cost: {
|
||||||
|
cedar: 7,
|
||||||
|
birch: 0,
|
||||||
|
walnut: 0,
|
||||||
|
mahogany: 0,
|
||||||
|
cherry: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
@@ -50,7 +50,7 @@ export default function Welcome() {
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
{localMulti ? <LocalMultiForm /> : null}
|
{localMulti ? <LocalMultiForm /> : null}
|
||||||
{cpuMulti ? <CpuMultiForm /> : null}
|
{cpuMulti ? <CpuMultiForm /> : null}
|
||||||
|
|
||||||
<button onClick={handleClear}>Clear form input</button>
|
<button onClick={handleClear}>Clear form input</button>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { useReducer, createContext } from "react"
|
||||||
|
|
||||||
|
import { TierOneDeck } from "../../store/TierOneDeck"
|
||||||
|
import { TierTwoDeck } from "../../store/TierTwoDeck"
|
||||||
|
import { TierThreeDeck } from "../../store/TierThreeDeck"
|
||||||
|
import { Spirits } from "./Spirits"
|
||||||
|
|
||||||
|
const initialGameState = {
|
||||||
|
players: [],
|
||||||
|
materials: {
|
||||||
|
cards: {
|
||||||
|
tierOneRemaining: TierOneDeck,
|
||||||
|
tierTwoRemaining: TierTwoDeck,
|
||||||
|
tierThreeRemaining: TierThreeDeck,
|
||||||
|
},
|
||||||
|
tokens: {
|
||||||
|
cedar: 7,
|
||||||
|
birch: 7,
|
||||||
|
walnut: 7,
|
||||||
|
mahogany: 7,
|
||||||
|
cherry: 7,
|
||||||
|
resin: 5,
|
||||||
|
},
|
||||||
|
spirits: [...Spirits]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const reducer = (state, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case "ADD PLAYER":
|
||||||
|
state.players.push(action.payload);
|
||||||
|
break;
|
||||||
|
case "UPDATE PLAYER MATERIALS":
|
||||||
|
// find player in array of players and update their resources
|
||||||
|
// update list of available materials in state
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default function Store({ children }) {
|
||||||
|
const [state, dispatch] = useReducer(reducer, initialGameState);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Context.Provider value={[state, dispatch]}>
|
||||||
|
{ children }
|
||||||
|
</Context.Provider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Context = createContext(initialGameState);
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
.gameboard {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gameboard-title {
|
.gameboard-title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user