setting up reducer/context structure
This commit is contained in:
@@ -1,38 +1,14 @@
|
||||
.App {
|
||||
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;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
.gameboard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 95vw;
|
||||
height: 75vh;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import './App.css';
|
||||
import { Routes, Route, BrowserRouter } from 'react-router-dom';
|
||||
|
||||
import Welcome from './components/Welcome';
|
||||
import GameBoard from './components/Game/GameBoard';
|
||||
import FulLGameView from './components/Game/FullGameView';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
@@ -10,7 +10,7 @@ function App() {
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Welcome />}/>
|
||||
<Route path="/gameboard" element={<GameBoard />}/>
|
||||
<Route path="/gameboard" element={<FulLGameView />}/>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</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 [tierOne, setTierOne] = useState(null);
|
||||
|
||||
const [content, setContent] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const AllDecks = [TierOneDeck, TierTwoDeck, TierThreeDeck];
|
||||
|
||||
useEffect(() => {
|
||||
// param limit sets limit on number of cards rendered
|
||||
// param tier filters by card tier
|
||||
const buildGameBoardRow = (limit, tier) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Card from "./Card";
|
||||
import Card from "../Cards/Card";
|
||||
|
||||
export default class Inventory {
|
||||
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
|
||||
}
|
||||
},
|
||||
]
|
||||
@@ -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 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user