score adds to player data when purchasing a card:
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import { CardProps } from '../../util/propTypes';
|
import { CardProps } from '../../util/propTypes';
|
||||||
import { ResourceCost } from '../../util/types';
|
import { ResourceCost } from '../../util/types';
|
||||||
@@ -10,6 +9,8 @@ const { buyCard, tooExpensive } = buyCardActions;
|
|||||||
export default function Card({ data, state, setState }: CardProps) {
|
export default function Card({ data, state, setState }: CardProps) {
|
||||||
const currentPlayer = useCurrentPlayer(state);
|
const currentPlayer = useCurrentPlayer(state);
|
||||||
|
|
||||||
|
if (!data) return <div className="card"></div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="top-row">
|
<div className="top-row">
|
||||||
|
|||||||
@@ -57,12 +57,10 @@ export const buyCard = (state: AppState, setState: setStateType, card: CardData)
|
|||||||
newResourcePool[typedKey] = adjustedResourcePoolValue;
|
newResourcePool[typedKey] = adjustedResourcePoolValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(newResourcePool);
|
|
||||||
console.log(newPlayerInventory);
|
|
||||||
|
|
||||||
// connect modified player state to updated list of all players
|
// connect modified player state to updated list of all players
|
||||||
updatedPlayer.inventory = newPlayerInventory;
|
updatedPlayer.inventory = newPlayerInventory;
|
||||||
updatedPlayer.cards = [...updatedPlayer.cards, card];
|
updatedPlayer.cards = [...updatedPlayer.cards, card];
|
||||||
|
updatedPlayer.points = updatedPlayer.points + (card.points || 0);
|
||||||
newPlayers[idx] = updatedPlayer;
|
newPlayers[idx] = updatedPlayer;
|
||||||
|
|
||||||
// attempt to queue replacement card from full deck
|
// attempt to queue replacement card from full deck
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export default function Player({ player, state, setState }: PlayerProps) {
|
|||||||
|
|
||||||
{/* Dynamic data from state */}
|
{/* Dynamic data from state */}
|
||||||
<section className="turn-and-action-based">
|
<section className="turn-and-action-based">
|
||||||
<p>Score: {dynamic?.points}</p>
|
<p>Score: {dynamic && dynamic.points}</p>
|
||||||
<p>{dynamic?.turnActive ? "It's your turn!" : "..."}</p>
|
<p>{dynamic?.turnActive ? "It's your turn!" : "..."}</p>
|
||||||
<button disabled={dynamic && hasMaxChips(dynamic)} onClick={() => handleClick(0)}>Get Chips</button>
|
<button disabled={dynamic && hasMaxChips(dynamic)} onClick={() => handleClick(0)}>Get Chips</button>
|
||||||
<button onClick={() => handleClick(1)}>Buy Card</button>
|
<button onClick={() => handleClick(1)}>Buy Card</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user