Skip to content

Commit

Permalink
feat: add gameType to GameResult #190
Browse files Browse the repository at this point in the history
  • Loading branch information
Храмыцких Антон committed Aug 11, 2023
1 parent 8017c2e commit 80e8e17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
14 changes: 0 additions & 14 deletions components/GameResult/GameResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ import { TeamMemberBasic } from 'components/shared/ui/TeamMemberBasic';
import { OIcon, XIcon } from 'components/shared/ui/XOIcons';
export const GameResult = (props: IGameResultProps) => {
const { result, player1, player2, gameType } = props;
// const player1 = {
// playerName: '0xh20...7260',
// playerImg: playerImg,
// showWinText: result === 'win',
// gameType: 'tic-tac-toe',
// icon: gameType === 'tic-tac-toe' ? <XIcon /> : <PurpleIcon />,
// };
// const player2 = {
// playerName: '0xh07...6035',
// playerImg: playerImg2,
// showWinText: result === 'lose',
// gameType: 'tic-tac-toe',
// icon: gameType === 'tic-tac-toe' ? <OIcon /> : <WhiteIcon />,
// };
return (
<div
className={classNames(styles.container, {
Expand Down
4 changes: 2 additions & 2 deletions components/GameResult/ScoreCard/ScoreCardProps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TGameResult } from '../GameResultProps';
import { StaticImageData } from 'next/image';
import { ReactNode } from 'react';
import { TGameType } from 'types/game';
import { PlayerI, TGameType } from 'types/game';
export interface ScoreCardProps {
playerName: string;
playerName: PlayerI[];
avatarUrl: string | StaticImageData;
result: TGameResult;
showWinText: boolean;
Expand Down
14 changes: 8 additions & 6 deletions pages/game-result/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { useState } from 'react';
import { GameResult } from 'components/GameResult';
import { TGameResult } from 'components/GameResult/GameResultProps';
import { TGameType } from 'types/game';
import styles from './gameResult.module.scss';
import { FinishedGameState, finishGame } from 'gameApi/index';
import { FinishedGameState } from 'gameApi/index';
import { useRouter } from 'next/router';

const GameResultPage = () => {
const [finishedGameState, setFinishedGameState] = useState<FinishedGameState | null>(null);

const router = useRouter();
const dynamicGameType = router.query.gameType as TGameType;
return (
<div className={styles.wrapper}>
<div className={styles.container}>
{finishedGameState && (
<GameResult
result={finishedGameState.winner ? 'win' : finishedGameState.isDraw ? 'draw' : 'lose'}
gameType={gameType}
result={finishedGameState.winner ? 'winner' : finishedGameState.isDraw ? 'isDraw' : 'loser'}
gameType={dynamicGameType}
player1={{
playerName: finishedGameState.winner ? 'Your Name' : 'Opponent Name',
playerName: finishedGameState.winner ? 'playerName' : 'Opponent Name',
avatarUrl: '',
}}
player2={{
Expand Down

0 comments on commit 80e8e17

Please sign in to comment.