This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d72dd95
commit 8b70817
Showing
6 changed files
with
202 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import type { EncodedTemplate } from '@/components/mahjong/field-template.ts' | ||
import { TEMPLATE_1, TEMPLATE_2 } from '@/components/mahjong/field-template.ts' | ||
|
||
const allChoices = [ | ||
'alfa-romeo', | ||
'aston-martin', | ||
'atom', | ||
'audi', | ||
'bentley', | ||
'bmw', | ||
'bugatti', | ||
'byd', | ||
'chevrolet', | ||
'ferrari', | ||
'fiat', | ||
'ford', | ||
'honda', | ||
'hyundai', | ||
'jeep', | ||
'kia', | ||
'lamborghini', | ||
'land-rover', | ||
'lexus', | ||
'lucid-motors', | ||
'mclaren', | ||
'mercedes-benz', | ||
'mini', | ||
'morgan-motor-company', | ||
'nio', | ||
'porsche', | ||
'rivian', | ||
'rolls-royce', | ||
'subaru', | ||
'tesla', | ||
'toyota', | ||
'volkswagen', | ||
'volvo', | ||
] | ||
type Choice = typeof allChoices[number] | ||
|
||
export type LevelInfo = { | ||
id: string | ||
title: string | ||
description: string | ||
template: EncodedTemplate | ||
choices: Choice[] | ||
} | ||
|
||
export const levels: LevelInfo[] = [ | ||
{ | ||
id: '1', | ||
title: 'Уровень 1', | ||
description: 'Самый простой уровень', | ||
template: TEMPLATE_1, | ||
choices: allChoices, | ||
}, | ||
{ | ||
id: '2', | ||
title: 'Уровень 2', | ||
description: 'Чуть сложнее', | ||
template: TEMPLATE_2, | ||
choices: allChoices, | ||
}, | ||
{ | ||
id: '3', | ||
title: 'Уровень 3', | ||
description: 'Российский автопром', | ||
template: TEMPLATE_2, | ||
choices: [ | ||
'atom', | ||
], | ||
}, | ||
{ | ||
id: '4', | ||
title: 'Уровень 4', | ||
description: 'Только топовые марки', | ||
template: TEMPLATE_2, | ||
choices: [ | ||
'bugatti', | ||
'ferrari', | ||
'lamborghini', | ||
'mclaren', | ||
'porsche', | ||
'rolls-royce', | ||
'tesla', | ||
], | ||
}, | ||
{ | ||
id: '5', | ||
title: 'Уровень 5', | ||
description: 'Только немецкие марки', | ||
template: TEMPLATE_2, | ||
choices: [ | ||
'audi', | ||
'bmw', | ||
'mercedes-benz', | ||
'porsche', | ||
'volkswagen', | ||
], | ||
}, | ||
{ | ||
id: '6', | ||
title: 'Уровень 6', | ||
description: 'Только китайские марки', | ||
template: TEMPLATE_2, | ||
choices: [ | ||
'byd', | ||
'nio', | ||
], | ||
}, | ||
{ | ||
id: '7', | ||
title: 'Уровень 7', | ||
description: 'Только японские марки', | ||
template: TEMPLATE_2, | ||
choices: [ | ||
'honda', | ||
'lexus', | ||
'subaru', | ||
'toyota', | ||
], | ||
}, | ||
] | ||
|
||
export function getLevelById(id: string | undefined): LevelInfo | undefined { | ||
return levels.find(level => level.id === id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { getLevelById } from '@/components/mahjong/levels.ts' | ||
import { Mahjong } from '@/components/mahjong/Mahjong' | ||
import { createFileRoute } from '@tanstack/react-router' | ||
|
||
export const Route = createFileRoute('/play')({ | ||
component: RouteComponent, | ||
validateSearch: (search: Record<string, unknown>) => { | ||
return { | ||
level: (search.level as string | undefined) || undefined, | ||
} | ||
}, | ||
}) | ||
|
||
function RouteComponent() { | ||
const { level: levelId } = Route.useSearch() | ||
|
||
const level = getLevelById(levelId) | ||
|
||
if (!level) { | ||
return <div>Invalid level id</div> | ||
} | ||
|
||
return ( | ||
<div> | ||
<Mahjong level={level} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters