version maintenance
This commit is contained in:
@@ -12,6 +12,8 @@ import AvailableChips from '../Resources/AvailableChips';
|
|||||||
import AllPlayers from '../Player/AllPlayers';
|
import AllPlayers from '../Player/AllPlayers';
|
||||||
import CardRow from '../Card/CardRow';
|
import CardRow from '../Card/CardRow';
|
||||||
import SelectionView from '../Resources/SelectionView';
|
import SelectionView from '../Resources/SelectionView';
|
||||||
|
import { useCurrentPlayer } from '../../hooks/useCurrentPlayer';
|
||||||
|
import getTotalBuyingPower from '../../util/getTotalBuyingPower';
|
||||||
const { validateChips } = getChipsActions;
|
const { validateChips } = getChipsActions;
|
||||||
|
|
||||||
export default function Gameboard({ state, setState }: StateProps) {
|
export default function Gameboard({ state, setState }: StateProps) {
|
||||||
@@ -57,6 +59,13 @@ export default function Gameboard({ state, setState }: StateProps) {
|
|||||||
}
|
}
|
||||||
}, [state])
|
}, [state])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (state.actions.buyCard.active) {
|
||||||
|
const currentPlayer = useCurrentPlayer(state);
|
||||||
|
currentPlayer && console.log(getTotalBuyingPower(currentPlayer));
|
||||||
|
}
|
||||||
|
}, [state.actions])
|
||||||
|
|
||||||
// displays state of board if data is populated, otherwise points to game constructor
|
// displays state of board if data is populated, otherwise points to game constructor
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!state.players.length) {
|
if (!state.players.length) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { turnOrderUtil } from "../../../util/turnOrderUtil";
|
import { turnOrderUtil } from "../../../util/turnOrderUtil";
|
||||||
import { AppState, CardData, FullDeck, PlayerCards, ResourceCost, setStateType } from "../../../util/types";
|
|
||||||
import { useCurrentPlayer } from "../../../hooks/useCurrentPlayer";
|
|
||||||
import getTotalBuyingPower from "../../../util/getTotalBuyingPower";
|
import getTotalBuyingPower from "../../../util/getTotalBuyingPower";
|
||||||
import { initialActions, setStateGetNoble } from "../../../hooks/stateSetters";
|
import { AppState, CardData, PlayerCards, ResourceCost, setStateType } from "../../../util/types";
|
||||||
import { canPickUpNoble } from "../../Nobles/canPickUpNoble";
|
|
||||||
import usePreviousPlayer from "../../../hooks/usePreviousPlayer";
|
|
||||||
import cardTierToKey from "../../../util/cardTierToKey";
|
import cardTierToKey from "../../../util/cardTierToKey";
|
||||||
|
import { canPickUpNoble } from "../../Nobles/canPickUpNoble";
|
||||||
|
import { initialActions, setStateGetNoble } from "../../../hooks/stateSetters";
|
||||||
|
import { useCurrentPlayer } from "../../../hooks/useCurrentPlayer";
|
||||||
|
import usePreviousPlayer from "../../../hooks/usePreviousPlayer";
|
||||||
|
|
||||||
export const tooExpensive = (card: CardData, state: AppState): boolean => {
|
export const tooExpensive = (card: CardData, state: AppState): boolean => {
|
||||||
const currentPlayer = useCurrentPlayer(state);
|
const currentPlayer = useCurrentPlayer(state);
|
||||||
@@ -63,7 +63,7 @@ export const buyCard = (state: AppState, setState: setStateType, card: CardData)
|
|||||||
let goldToReturn = 0;
|
let goldToReturn = 0;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (cardCost[typedKey] > totalBuyingPower[typedKey]) {
|
while (cardCostPointer > tempPlayerInventory) {
|
||||||
availableGold--;
|
availableGold--;
|
||||||
goldToReturn++;
|
goldToReturn++;
|
||||||
tempPlayerInventory++;
|
tempPlayerInventory++;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import { render } from 'react-dom'
|
||||||
import ReactDOM from 'react-dom/client'
|
|
||||||
import App from './App'
|
import App from './App'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<App />)
|
const root = document.getElementById('root') as HTMLElement;
|
||||||
|
render(<App />, root);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function getTotalBuyingPower(currentPlayer: PlayerData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currentPlayer) return totalBuyingPower;
|
if (!currentPlayer) return totalBuyingPower;
|
||||||
|
|
||||||
for (let [key,quantity] of Object.entries(currentPlayer.inventory)) {
|
for (let [key,quantity] of Object.entries(currentPlayer.inventory)) {
|
||||||
totalBuyingPower[key as keyof ResourceCost] += quantity;
|
totalBuyingPower[key as keyof ResourceCost] += quantity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user