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

Commit

Permalink
chore: update levels
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Nov 30, 2024
1 parent 9647633 commit bca8e0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Binary file modified frontend/public/preview/zen-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions frontend/src/components/mahjong/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class Game {
}

const kinds: string[] = []
let byTwo = false
if (availableCoords.length / 4 > allKinds.length) {
kinds.push(...allKinds)
for (let i = 0; i < availableCoords.length / 4 - allKinds.length; i++) {
Expand All @@ -63,23 +64,30 @@ export class Game {
else {
const leftoverKinds = [...allKinds]
shuffleArray(leftoverKinds)
kinds.push(...leftoverKinds.slice(0, Math.ceil(availableCoords.length / 4)))
kinds.push(...leftoverKinds.slice(0, Math.ceil(availableCoords.length / 2)))
byTwo = true
}
console.log('kindCounter')

const kindCounter: { [key: string]: number } = {}
let current = 0
for (const kind of kinds) {
if (availableCoords.length - current >= 4) {
kindCounter[kind] = (kindCounter[kind] || 0) + 4
current += 4
}
else if (availableCoords.length - current === 2) {
if (byTwo) {
kindCounter[kind] = (kindCounter[kind] || 0) + 2
current += 2
}
else {
throw new Error('Invalid number of available coordinates')
if (availableCoords.length - current >= 4) {
kindCounter[kind] = (kindCounter[kind] || 0) + 4
current += 4
}
else if (availableCoords.length - current === 2) {
kindCounter[kind] = (kindCounter[kind] || 0) + 2
current += 2
}
else {
throw new Error('Invalid number of available coordinates')
}
}
}
console.log('kindCounter', kindCounter)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/mahjong/levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const levels: LevelInfo[] = [
template: ZEN_2,
choices: allChoices,
requiredLevel: 'zen-1',
story: 'Постепенно сложность уровней будет увеличиваться. На этом уровне больше производителей, и есть заблокированные фигуры - те, которые закрыты справа и слева другими фигурами.',
},
{
id: 'zen-3',
Expand All @@ -75,6 +76,7 @@ export const levels: LevelInfo[] = [
template: ZEN_3,
choices: allChoices,
requiredLevel: 'zen-2',
story: 'А на этом уровне несколько слоёв. Но мы уверены, что вы справитесь!',
},
{
id: '1',
Expand Down

0 comments on commit bca8e0b

Please sign in to comment.