Extracted pure functions to make tests happy

This commit is contained in:
Renan LE CARO 2025-03-29 21:22:19 +01:00
parent 8d7d97608d
commit a4e24fd397
5 changed files with 199 additions and 193 deletions

View file

@ -1,6 +1,6 @@
import { Ball, GameState, PerkId, PerksMap } from "./types";
import { icons, upgrades } from "./loadGameData";
import { t } from "./i18n/i18n";
import {Ball, GameState, PerkId, PerksMap} from "./types";
import {icons, upgrades} from "./loadGameData";
import {t} from "./i18n/i18n";
export function getMajorityValue(arr: string[]): string {
const count: { [k: string]: number } = {};
@ -119,9 +119,6 @@ export function distanceBetween(
return Math.sqrt(distance2(a, b));
}
export function clamp(value: number, min: number, max: number) {
return Math.max(min, Math.min(value, max));
}
export function defaultSounds() {
return {
aboutToPlaySound: {
@ -190,6 +187,3 @@ export function countBricksBelow(gameState: GameState, index: number) {
return count;
}
export function comboKeepingRate(level:number){
return clamp(1-1/(1+level)*1.5,0,1)
}