Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
feat: add more logos
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Nov 29, 2024
1 parent 29009af commit 1950490
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 9 deletions.
Binary file added frontend/public/logos/alfa-romeo-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/aston-martin-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/audi-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/bmw-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/bugatti-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/byd-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/chevrolet-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/ferrari-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/fiat-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/ford-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/honda-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/hyundai-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/jeep-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/kia-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/lamborghini-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/land-rover-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/lexus-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/lucid-motors-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/mclaren-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/mercedes-benz-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/mini-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/nio-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/porsche-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/rivian-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logos/rolls-royce-logo.png
Binary file added frontend/public/logos/subaru-logo.png
Binary file added frontend/public/logos/toyota-logo.png
Binary file added frontend/public/logos/volkswagen-logo.png
Binary file added frontend/public/logos/volvo-logo.png
36 changes: 35 additions & 1 deletion frontend/src/components/mahjong/Mahjong.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,41 @@ export function Mahjong() {
const g = Game.random(
FieldTemplate.decode(TEMPLATE_2),
(a, b) => a === b,
['atom', 'bentley', 'tesla', 'atom', 'bentley'],
[
'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',
],
)
g.onTilesChange = setTiles
g.onSelectedTileChange = setSelected
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/mahjong/field-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export const TEMPLATE_2: EncodedTemplate = [
[
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[1, 1, 1, 1, 1],
[2, 2, 2, 2, 2],
[0, 1, 1, 1, 0],
[0, 2, 2, 2, 0],
[0, 0, 0, 0, 0],
],
]
33 changes: 27 additions & 6 deletions frontend/src/components/mahjong/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Game {
public static random(
template: FieldTemplate,
comparator: Comparator,
kinds: string[],
allKinds: string[],
maxRetries = 100,
): Game {
const availableCoords = [...template.tileCoords]
Expand All @@ -40,16 +40,37 @@ export class Game {
throw new Error(`The number of tile positions (${availableCoords.length}) must be even`)
}

if (availableCoords.length !== kinds.length * 4 && availableCoords.length !== kinds.length * 2) {
throw new Error(`The number of tile positions (${availableCoords.length}) must be equal to the number of choices (${kinds.length}) times 4 or times 2`)
const kinds: string[] = []
if (availableCoords.length / 4 > allKinds.length) {
kinds.push(...allKinds)
for (let i = 0; i < availableCoords.length / 4 - allKinds.length; i++) {
kinds.push(allKinds[Math.floor(Math.random() * allKinds.length)])
}
}
else if (availableCoords.length / 4 === allKinds.length) {
kinds.push(...allKinds)
}
else {
const leftoverKinds = [...allKinds]
shuffleArray(leftoverKinds)
kinds.push(...leftoverKinds.slice(0, Math.ceil(availableCoords.length / 4)))
}

for (let retry = 0; retry < maxRetries; retry++) {
const tiles: Tile[] = []
const tilePerKind = availableCoords.length / kinds.length
for (const kind of kinds) {
for (let i = 0; i < tilePerKind; i++) {
tiles.push({ kind, coord: null as any })
if (availableCoords.length - tiles.length >= 4) {
for (let i = 0; i < 4; i++) {
tiles.push({ kind, coord: null as any })
}
}
else if (availableCoords.length - tiles.length === 2) {
for (let i = 0; i < 2; i++) {
tiles.push({ kind, coord: null as any })
}
}
else {
throw new Error('Invalid number of available coordinates')
}
}
// Shuffle tiles
Expand Down

0 comments on commit 1950490

Please sign in to comment.