Skip to content

Commit 4e9c306

Browse files
committed
Refactoring
1 parent 78560de commit 4e9c306

58 files changed

Lines changed: 3530 additions & 3076 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# THIS IS AUTOGENERATED. DO NOT EDIT MANUALLY
2+
version = 1
3+
name = "thisman.github.io"
4+
5+
[setup]
6+
script = ""
7+
8+
[[actions]]
9+
name = "Запустить"
10+
icon = "run"
11+
command = "python -m http.server 8000"

babylon-tower/index.html

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title>Babylon Tower</title>
77
<meta name="theme-color" content="#f5f5f5" />
88
<script src="/shared/theme.js"></script>
9+
<script src="/shared/browser/analytics.js"></script>
910
<link rel="stylesheet" href="/shared/common.css" />
1011
<style>
1112
* {
@@ -156,17 +157,6 @@
156157
}
157158
</style>
158159

159-
<script type="text/javascript">
160-
(function(m,e,t,r,i,k,a){
161-
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
162-
m[i].l=1*new Date();
163-
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
164-
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a);
165-
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=107098559', 'ym');
166-
167-
ym(107098559, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});
168-
</script>
169-
<noscript><div><img src="https://mc.yandex.ru/watch/107098559" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
170160
</head>
171161
<body>
172162
<canvas id="game-canvas"></canvas>
@@ -204,8 +194,6 @@
204194
}
205195
}
206196
</script>
207-
<script type="module" src="logic.js"></script>
208-
<script type="module" src="render.js"></script>
209-
<script type="module" src="input.js"></script>
197+
<script type="module" src="./src/main.js"></script>
210198
</body>
211199
</html>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
canSlide,
2222
scramble,
2323
EMPTY
24-
} from './logic.js';
24+
} from '../core/puzzle.js';
2525

2626
import {
2727
initScene,
@@ -47,7 +47,7 @@ import {
4747
shouldFlipRotationDirection,
4848
markDirty,
4949
consumeRenderFlag
50-
} from './render.js';
50+
} from '../ui/renderer.js';
5151

5252
// Game state
5353
let gameState = null;

babylon-tower/src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './app/controller.js';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import * as THREE from 'three';
11-
import { EMPTY, C1, C2, C3, C4, LAYERS, FACES } from './logic.js';
11+
import { EMPTY, C1, C2, C3, C4, LAYERS, FACES } from '../core/puzzle.js';
1212

1313
// Scene configuration
1414
const CELL_SIZE = 0.9; // Size of each cell (square)

babylon-tower/tests/puzzle.test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import test from 'node:test';
2+
import assert from 'node:assert/strict';
3+
4+
import {
5+
applyRotate,
6+
applySlide,
7+
canSlide,
8+
createSolvedState,
9+
getAllValidMoves,
10+
isSolved
11+
} from '../src/core/puzzle.js';
12+
13+
test('createSolvedState builds solved board', () => {
14+
const state = createSolvedState();
15+
assert.equal(isSolved(state), true);
16+
});
17+
18+
test('applyRotate keeps layer size and mutates order', () => {
19+
const state = createSolvedState();
20+
const original = [...state[0]];
21+
applyRotate(state, 0, 1);
22+
assert.notDeepEqual(state[0], original);
23+
assert.equal(state[0].length, original.length);
24+
});
25+
26+
test('canSlide and applySlide move chip into empty slot', () => {
27+
const state = createSolvedState();
28+
state[1][0] = 1;
29+
state[0][0] = 0;
30+
assert.equal(canSlide(state, 0, 1, -1), true);
31+
applySlide(state, 0, 1, -1);
32+
assert.equal(state[0][0], 1);
33+
});
34+
35+
test('getAllValidMoves returns rotates and slides', () => {
36+
const moves = getAllValidMoves(createSolvedState());
37+
assert.equal(moves.some((move) => move.type === 'rotate'), true);
38+
});

gamma-trainer/index.html

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,9 @@
66
<title>Гаммы и лады — тренажёр</title>
77
<meta name="theme-color" content="#f5f5f5" />
88
<script src="/shared/theme.js"></script>
9-
<link rel="stylesheet" href="../shared/common.css" />
9+
<script src="/shared/browser/analytics.js"></script>
10+
<link rel="stylesheet" href="/shared/common.css" />
1011
<link rel="stylesheet" href="./index.css" />
11-
12-
<script type="text/javascript">
13-
(function(m,e,t,r,i,k,a){
14-
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
15-
m[i].l=1*new Date();
16-
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
17-
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a);
18-
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=107098559', 'ym');
19-
20-
ym(107098559, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});
21-
</script>
22-
<noscript><div><img src="https://mc.yandex.ru/watch/107098559" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
2312
</head>
2413
<body>
2514
<main class="container gamma-page">
@@ -79,6 +68,6 @@ <h2 class="section-title">Highlight Guide</h2>
7968
<a href="https://github.com/Thisman/thisman.github.io" target="_blank" rel="noreferrer">Repository</a>
8069
</footer>
8170

82-
<script src="./index.js"></script>
71+
<script type="module" src="./src/main.js"></script>
8372
</body>
8473
</html>

gamma-trainer/index.js

Lines changed: 0 additions & 131 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createScalePresentation } from '../core/music-theory.js';
2+
3+
export function createGammaTrainerApp(view) {
4+
function update(selection = view.readSelection()) {
5+
view.render(createScalePresentation(selection.tonicIndex, selection.modeId));
6+
}
7+
8+
function init() {
9+
view.mountChipBars();
10+
view.bind(update);
11+
update();
12+
}
13+
14+
return {
15+
init,
16+
update
17+
};
18+
}

0 commit comments

Comments
 (0)