new UI + new targets.

This commit is contained in:
Jan Pleterski
2026-11-27 14:37:44 +01:00
parent 5f9e2a3b86
commit 2fc741a9f6
113 changed files with 6861 additions and 7381 deletions
+54
View File
@@ -0,0 +1,54 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:sd_kovinar/models/holiday_theme.dart';
import 'package:sd_kovinar/models/target_style.dart';
void main() {
String? on(int y, int m, int d) => HolidayTheme.on(DateTime(y, m, d))?.name;
test('Easter Sunday', () {
expect(HolidayTheme.easterSunday(2024), DateTime(2024, 3, 31));
expect(HolidayTheme.easterSunday(2025), DateTime(2025, 4, 20));
expect(HolidayTheme.easterSunday(2026), DateTime(2026, 4, 5));
expect(HolidayTheme.easterSunday(2027), DateTime(2027, 3, 28));
});
test('windows, inclusive, across the new year', () {
expect(on(2026, 11, 30), isNull);
expect(on(2026, 12, 1), 'Božič');
expect(on(2026, 12, 26), 'Božič');
expect(on(2026, 12, 27), 'Novo leto');
expect(on(2027, 1, 2), 'Novo leto');
expect(on(2027, 1, 3), isNull);
expect(on(2026, 6, 23), 'Kresna noč');
expect(on(2026, 6, 24), 'Dan državnosti');
expect(on(2026, 10, 31), 'Noč čarovnic');
expect(on(2026, 11, 11), 'Martinovo');
expect(on(2026, 11, 27), isNull);
});
test('Easter-based holidays', () {
// 2026: Easter 5. 4., Shrove Tuesday 17. 2.
expect(on(2026, 2, 17), 'Pust');
expect(on(2026, 2, 12), 'Valentinovo'); // first in the list wins over Pust (-52 = 12. 2.)
expect(on(2026, 3, 29), 'Velika noč');
expect(on(2026, 4, 6), 'Velika noč');
expect(on(2026, 4, 7), isNull);
});
test('Easter windows in calendar days, across the clock change', () {
final easter = HolidayTheme.all.firstWhere((h) => h.name == 'Velika noč');
expect(easter.window(DateTime(2026, 4, 1)), (DateTime(2026, 3, 29), DateTime(2026, 4, 6)));
expect(on(2026, 3, 28), isNull); // the day before the window
final pust = HolidayTheme.all.firstWhere((h) => h.name == 'Pust');
expect(pust.window(DateTime(2026, 2, 17)).$2, DateTime(2026, 2, 18));
});
test('every holiday has its target and the window of a date around new year', () {
for (final h in HolidayTheme.all) {
expect(TargetStyle.byId(h.targetId).id, h.targetId);
}
final newYear = HolidayTheme.all.firstWhere((h) => h.name == 'Novo leto');
expect(newYear.window(DateTime(2027, 1, 1)), (DateTime(2026, 12, 27), DateTime(2027, 1, 2)));
expect(newYear.window(DateTime(2026, 12, 30)), (DateTime(2026, 12, 27), DateTime(2027, 1, 2)));
});
}
+9 -3
View File
@@ -29,10 +29,16 @@ void main() {
test('ring edges count the bullet radius', () {
const c = TargetScoring.center;
// Bullet edge exactly on the outer edge of ring 10
expect(TargetScoring.scoreAt(c + const Offset(14 + 25, 0)), 10);
expect(TargetScoring.scoreAt(c + const Offset(14 + 25 + 0.5, 0)), 9);
expect(TargetScoring.scoreAt(c + const Offset(15 + 25, 0)), 10);
expect(TargetScoring.scoreAt(c + const Offset(15 + 25 + 0.5, 0)), 9);
// Touching a line counts the higher value: the edge is the line's outer edge
expect(TargetScoring.scoreAt(c + const Offset(70 + 2.5 + 25, 0)), 9); // 5 px line
expect(TargetScoring.scoreAt(c + const Offset(70 + 2.5 + 25 + 0.5, 0)), 8);
expect(TargetScoring.scoreAt(c + const Offset(235 + 1.5 + 25, 0)), 6); // 3 px line
expect(TargetScoring.scoreAt(c + const Offset(235 + 1.5 + 25 + 0.5, 0)), 5);
// Outside the last ring
expect(TargetScoring.scoreAt(c + const Offset(510 + 25 + 0.5, 0)), 0);
expect(TargetScoring.scoreAt(c + const Offset(510 + 1.5 + 25, 0)), 1);
expect(TargetScoring.scoreAt(c + const Offset(510 + 1.5 + 25 + 0.5, 0)), 0);
});
test('hand-entered shots stay on the 1200x1200 target', () {
+22
View File
@@ -0,0 +1,22 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:sd_kovinar/models/target_style.dart';
void main() {
test('every target design has its image, and ids are unique', () {
final ids = <int>{};
for (final style in [...TargetStyle.all, ...TargetStyle.holidays]) {
expect(ids.add(style.id), isTrue, reason: 'duplicate id ${style.id}');
final asset = style.asset;
if (style.isDefault) {
expect(asset, isNull); // drawn as vectors
} else {
expect(File(asset!).existsSync(), isTrue, reason: '$asset missing');
}
}
expect(TargetStyle.byId(13), TargetStyle.fallback); // removed skin falls back to the default
expect(TargetStyle.all.length, 6); // the default and five designs
expect(TargetStyle.byId(24), TargetStyle.fallback); // a design no longer shipped falls back too
});
}