From 06f1c2eae807b6400e4784d6ee21a5850ae134f0 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Thu, 23 Nov 2023 07:51:23 +0100 Subject: [PATCH] Updated the Calculate.jsx state --- client/src/pages/Game/states/Calculate/Calculate.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/pages/Game/states/Calculate/Calculate.jsx b/client/src/pages/Game/states/Calculate/Calculate.jsx index c6b2a29..1f7e214 100644 --- a/client/src/pages/Game/states/Calculate/Calculate.jsx +++ b/client/src/pages/Game/states/Calculate/Calculate.jsx @@ -21,7 +21,7 @@ const localeOptions = { export const Calculate = ({setState, currentRound}) => { const {round, getGroupById, updateCapital, endRound, setRoundHistory} = useContext(GroupContext); - const {rounds, demandTable} = useContext(SettingsContext); + const {rounds, demandTable, costPerCake, costPerRound} = useContext(SettingsContext); const navigate = useNavigate(); @@ -35,15 +35,16 @@ export const Calculate = ({setState, currentRound}) => { const animateNext = () => { const current = round.shift(); if (!current) return; - let sold = current.amount < nachfrage ? current.amount : nachfrage; - setNachfrage(nachfrage => nachfrage - sold); - let profit = sold * current.price - (current.amount * 1000 + 4000); + setNachfrage(nachfrage => nachfrage - sold); + let profit = sold * current.price - (current.amount * costPerCake + costPerRound); let currentRound = {...current, profit, name: getGroupById(current.id).name, sold, newCapital: getGroupById(current.id).capital + profit}; + console.log(currentRound); + setAnimatedGroups(old => [...old, currentRound]); updateCapital(current.id, currentRound.newCapital);