Skip to content

Commit

Permalink
upd: context GameField
Browse files Browse the repository at this point in the history
| upd GameResult #190
  • Loading branch information
habdevs committed Sep 14, 2023
1 parent f28eb8d commit 6aa1c9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 11 additions & 7 deletions components/GameField/GameField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@ export const GameField: React.FC<GameFieldPropsI> = ({
const [isShowDispute, setShowDispute] = useState<boolean>(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 {
Expand Down
8 changes: 4 additions & 4 deletions components/GameResult/GameResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ export const GameResult = () => {
<div
className={classNames(styles.container, {
[styles.win]: winner,
[styles.lose]: !winner,
[styles.lose]: !winner && !isDraw,
[styles.draw]: isDraw,
})}>
<h2 className={styles.title}>
{winner === true && <span>Winner!</span>}
{!winner && <span>Better Luck Next Time</span>}
{!winner && !isDraw && <span>Better Luck Next Time</span>}
{isDraw === true && <span>Better Luck Next Time</span>}
</h2>
{winner && (
<img src={imgWin.src} alt='Win' width={640} height={510} className={styles.imageWin} />
)}
{winner === false && (
{!!winner && (
<h1 className={styles.titleResult}>
You lose <img src={loseImg.src} alt='lose' className={styles.imageSize} />
</h1>
)}
{isDraw === true && (
{isDraw && (
<h1 className={styles.titleResult}>
Draw <img src={drawImg.src} alt='draw' className={styles.imageSize} />
</h1>
Expand Down

0 comments on commit 6aa1c9c

Please sign in to comment.