UI fixes and league

This commit is contained in:
Jan Pleterski
2026-11-28 12:22:02 +01:00
parent 2fc741a9f6
commit 258303deb8
118 changed files with 1439 additions and 537 deletions
+21 -4
View File
@@ -41,12 +41,29 @@ void main() {
expect(TargetScoring.scoreAt(c + const Offset(510 + 1.5 + 25 + 0.5, 0)), 0);
});
test('hand-entered shots stay on the 1200x1200 target', () {
for (int deg = 0; deg < 360; deg += 15) {
// The dot is wholly inside the target's 1200 square
bool onSquare(Offset p) {
const r = TargetScoring.bulletDiameter / 2;
return p.dx >= r && p.dy >= r && p.dx <= TargetScoring.size - r && p.dy <= TargetScoring.size - r;
}
test('a hand-entered 0 lands towards a corner, clear of ring 1', () {
for (int deg = 0; deg < 360; deg += 5) {
final p = TargetScoring.positionFor(0, deg * pi / 180);
expect(p.dx, inInclusiveRange(0, 1200));
expect(p.dy, inInclusiveRange(0, 1200));
expect(onSquare(p), isTrue, reason: '$deg°: $p');
// Past ring 1's decoration (r 510–590), not just past the ring
expect((p - TargetScoring.center).distance - TargetScoring.bulletDiameter / 2, greaterThan(590), reason: '$deg°: $p');
}
});
test('a shot far off is kept in the square and still scores 0', () {
for (final far in [const Offset(0, 0), const Offset(1200, 1200), const Offset(-500, 600), const Offset(600, 2000), const Offset(1190, 20)]) {
final p = TargetScoring.shown(far);
expect(onSquare(p), isTrue, reason: '$far -> $p');
expect(TargetScoring.scoreAt(p), 0);
}
const inside = Offset(700, 650);
expect(TargetScoring.shown(inside), inside); // inside: unchanged
});
});
}