@tungstenstudio/outschart-generator 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,141 @@
1
+ // === Out Modes ===
2
+
3
+ export type OutMode = 'double' | 'single';
4
+
5
+ // === Dartboard Types ===
6
+
7
+ export type BedType =
8
+ | 'treble'
9
+ | 'double'
10
+ | 'smallSingle'
11
+ | 'largeSingle'
12
+ | 'Bull'
13
+ | '25'
14
+ | 'off'
15
+ | null; // bare single (e.g. "20")
16
+
17
+ export type MissType = 'radialIn' | 'radialOut' | 'lateralCW' | 'lateralCCW';
18
+
19
+ export interface ParsedTarget {
20
+ bed: BedType;
21
+ number: number | null;
22
+ value: number;
23
+ }
24
+
25
+ export interface FormattedTarget {
26
+ label: string;
27
+ value: number;
28
+ }
29
+
30
+ export interface MissTarget extends FormattedTarget {
31
+ missType: MissType;
32
+ }
33
+
34
+ export interface ThrowEvaluation {
35
+ target: string;
36
+ targetValue: number;
37
+ remaining: number;
38
+ misses: EvaluatedMiss[];
39
+ bustCount: number;
40
+ totalMisses: number;
41
+ }
42
+
43
+ export interface EvaluatedMiss extends MissTarget {
44
+ newRemaining: number;
45
+ busts: boolean;
46
+ }
47
+
48
+ // === Checkout Types ===
49
+
50
+ export interface CheckoutEntry {
51
+ darts: string[];
52
+ numDarts: number;
53
+ alternates?: string[][];
54
+ }
55
+
56
+ export type CheckoutChart = Record<number, CheckoutEntry>;
57
+
58
+ // === Enumeration Types ===
59
+
60
+ export interface EnumeratedEntry {
61
+ options: string[][];
62
+ count: number;
63
+ }
64
+
65
+ export type EnumeratedCheckoutMap = Record<number, EnumeratedEntry>;
66
+
67
+ export interface EnumeratedResult {
68
+ checkouts: EnumeratedCheckoutMap;
69
+ bogeyNumbers: number[];
70
+ totalOptions: number;
71
+ }
72
+
73
+ // === Generation Options ===
74
+
75
+ export interface GenerateOptions {
76
+ outMode: OutMode;
77
+ min?: number;
78
+ max?: number;
79
+ }
80
+
81
+ export interface RecommendOptions extends GenerateOptions {
82
+ includeAlternates?: boolean;
83
+ altThreshold?: number;
84
+ overrides?: Record<number, { darts: string[] }>;
85
+ }
86
+
87
+ export interface CheckoutResult {
88
+ checkouts: CheckoutChart;
89
+ bogeyNumbers: number[];
90
+ }
91
+
92
+ // === Miss Analysis Types ===
93
+
94
+ export interface DartAnnotation {
95
+ dart: number;
96
+ target: string;
97
+ missRelevant: boolean;
98
+ missResult?: string;
99
+ missRemaining?: number;
100
+ stillCheckable?: boolean;
101
+ remainderCheckout?: string[] | null;
102
+ }
103
+
104
+ export interface MissAnalysisResult {
105
+ score: number;
106
+ path: string[];
107
+ annotations: DartAnnotation[];
108
+ missResiliency: string;
109
+ }
110
+
111
+ // === Dartboard Layout Types ===
112
+
113
+ export interface DartboardNeighbor {
114
+ clockwise: number;
115
+ counterClockwise: number;
116
+ }
117
+
118
+ export interface DartboardLayout {
119
+ boardOrder: number[];
120
+ neighbors: Record<string, DartboardNeighbor>;
121
+ }
122
+
123
+ // === Error Handling ===
124
+
125
+ export type OutsChartErrorCode =
126
+ | 'INVALID_TARGET'
127
+ | 'INVALID_SCORE'
128
+ | 'INVALID_OUT_MODE'
129
+ | 'INVALID_RANGE'
130
+ | 'SCORE_NOT_CHECKABLE'
131
+ | 'INVALID_OVERRIDE';
132
+
133
+ export class OutsChartError extends Error {
134
+ code: OutsChartErrorCode;
135
+
136
+ constructor(code: OutsChartErrorCode, message: string) {
137
+ super(message);
138
+ this.name = 'OutsChartError';
139
+ this.code = code;
140
+ }
141
+ }