From 6aa1c9cfb74a5358cabd39b65b1965297c460dd1 Mon Sep 17 00:00:00 2001 From: "Anton@habdevs" Date: Thu, 14 Sep 2023 14:51:17 +0500 Subject: [PATCH] upd: context GameField | upd GameResult #190 --- components/GameField/GameField.tsx | 18 +++++++++++------- components/GameResult/GameResult.tsx | 8 ++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/components/GameField/GameField.tsx b/components/GameField/GameField.tsx index dee59de..77a910b 100644 --- a/components/GameField/GameField.tsx +++ b/components/GameField/GameField.tsx @@ -33,19 +33,23 @@ export const GameField: React.FC = ({ const [isShowDispute, setShowDispute] = useState(false); const { t } = useTranslation(); const account = useAccount(); - const { setFinishResult } = useGameStateContext(); + const { setFinishResult, finishResult } = useGameStateContext(); const { data, error, loading } = useQuery(badgesQuery, { variables: { id: account.address?.toLowerCase() }, }); // TODO added context @habdevs #190 if (finishGameCheckResult) { - setFinishResult({ - winner: finishGameCheckResult.winner, - isDraw: finishGameCheckResult.isDraw, - cheatWin: finishGameCheckResult.cheatWin, - }); - console.log('CONTEXT GAMEFIELD', setFinishResult) + + const newFinishResult = { + winner: finishGameCheckResult?.winner || false, + isDraw: finishGameCheckResult?.isDraw || false, + cheatWin: finishGameCheckResult?.cheatWin || false, + }; + + setFinishResult(newFinishResult); + console.log('CONTEXT GAMEFIELD', newFinishResult) } + console.log('dispute mode', disputeMode, account.address); function isOpponentAddress(address: string): boolean { diff --git a/components/GameResult/GameResult.tsx b/components/GameResult/GameResult.tsx index 649dc45..a888fe3 100644 --- a/components/GameResult/GameResult.tsx +++ b/components/GameResult/GameResult.tsx @@ -32,23 +32,23 @@ export const GameResult = () => {

{winner === true && Winner!} - {!winner && Better Luck Next Time} + {!winner && !isDraw && Better Luck Next Time} {isDraw === true && Better Luck Next Time}

{winner && ( Win )} - {winner === false && ( + {!!winner && (

You lose lose

)} - {isDraw === true && ( + {isDraw && (

Draw draw