diff --git a/package-lock.json b/package-lock.json index 49780da..0c8abca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "2.3.2", "license": "MIT", "dependencies": { - "@joist/di": "^3.0.8-next.1", - "@joist/element": "^3.0.8-next.1", + "@joist/di": "^3.1.0", + "@joist/element": "^3.1.0", "tslib": "^2.5.2" }, "devDependencies": { @@ -95,14 +95,14 @@ } }, "node_modules/@joist/di": { - "version": "3.0.8-next.1", - "resolved": "https://registry.npmjs.org/@joist/di/-/di-3.0.8-next.1.tgz", - "integrity": "sha512-3HpUebEjaKy8VGhUmJw1MVCZyt1OWYAT3KkcjpQM7qA2xHRXh4OUXCXfG16WdKTS3nNnyhsyioa0akYzEclaOQ==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@joist/di/-/di-3.1.0.tgz", + "integrity": "sha512-mU8js+Mg+4JKAXClv4Vfdx6BdLLULv1cY3l1E8QJiUOyz1eLSI6Du1Pw0Y40oCU9w+bNRIiJ3yMcA2ya/XzOuQ==" }, "node_modules/@joist/element": { - "version": "3.0.8-next.1", - "resolved": "https://registry.npmjs.org/@joist/element/-/element-3.0.8-next.1.tgz", - "integrity": "sha512-RF2BhpgH3CqtD4ZviUK6FxuizFt9n/qHcTSdLN71+DJ+nAZ+w00L02iEfdXB+IfqaGBRpR6H1MGwjda105NVuA==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@joist/element/-/element-3.1.0.tgz", + "integrity": "sha512-+iziuGw9tpf4FBUrZAoc4TxVUuVhfQ+zxT4BrfT7i/Mc0L6yCn1et48udiwpJgCHZPrL1Hd/vryVw5SNlQRQQg==" }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", diff --git a/package.json b/package.json index cd7f696..2afabd9 100644 --- a/package.json +++ b/package.json @@ -90,8 +90,8 @@ } }, "dependencies": { - "@joist/di": "^3.0.8-next.1", - "@joist/element": "^3.0.8-next.1", + "@joist/di": "^3.1.0", + "@joist/element": "^3.1.0", "tslib": "^2.5.2" }, "devDependencies": { diff --git a/src/sfx.ts b/src/sfx.ts index b7d54d2..1e3c795 100644 --- a/src/sfx.ts +++ b/src/sfx.ts @@ -1,3 +1,27 @@ +const stone_sounds = [ + [1000.0, 137.20833333333331], + [2137.208333333333, 58.854166666666664], + [3196.0625, 86.60416666666666], + [4282.666666666667, 85.0], + [5367.666666666667, 86.8125], +] as const; + +const capture_stone_sounds = [ + [2507.1041666666665, 1074.6458333333333], + [6200.895833333333, 1485.9166666666667], + [10539.125, 1034.9375], + [14253.833333333332, 895.8541666666666], +] as const; + +const capture_pile_sounds = [ + [1000.0, 507.1041666666667], + [4581.75, 619.1458333333333], + [8686.8125, 852.3125], + [12574.0625, 679.7708333333334], + [16149.687499999998, 1148.8125], + [18298.5, 1145.3333333333333], +] as const; + export class Sfx { #stones = new Audio(); #effects = new Audio(); @@ -13,15 +37,8 @@ export class Sfx { } placeStone() { - let sounds = [ - [1000.0, 137.20833333333331], - [2137.208333333333, 58.854166666666664], - [3196.0625, 86.60416666666666], - [4282.666666666667, 85.0], - [5367.666666666667, 86.8125], - ]; - - const [start, duration] = sounds[Math.floor(Math.random() * sounds.length)]; + const [start, duration] = + stone_sounds[Math.floor(Math.random() * stone_sounds.length)]; return new Promise((resolve) => { this.#stones.currentTime = start / 1000; @@ -36,33 +53,23 @@ export class Sfx { } captureStones(count: number) { - const single = [ - [2507.1041666666665, 1074.6458333333333], - [6200.895833333333, 1485.9166666666667], - [10539.125, 1034.9375], - [14253.833333333332, 895.8541666666666], - ]; - - const pile = [ - [1000.0, 507.1041666666667], - [4581.75, 619.1458333333333], - [8686.8125, 852.3125], - [12574.0625, 679.7708333333334], - [16149.687499999998, 1148.8125], - [18298.5, 1145.3333333333333], - ]; - return new Promise((resolve) => { let start: number; let duration: number; if (count === 1) { - const sprite = single[Math.floor(Math.random() * single.length)]; + const sprite = + capture_stone_sounds[ + Math.floor(Math.random() * capture_stone_sounds.length) + ]; start = sprite[0]; duration = sprite[1]; } else { - const sprite = pile[Math.floor(Math.random() * pile.length)]; + const sprite = + capture_pile_sounds[ + Math.floor(Math.random() * capture_pile_sounds.length) + ]; start = sprite[0]; duration = sprite[1];