@@ -19,62 +19,33 @@ import {
1919 getRankedTokens ,
2020} from "../util/allocateHats/getRankedTokens" ;
2121
22- // TODO: dedup with vscode
23-
24- export const HAT_COLORS = [
25- "default" ,
26- "blue" ,
27- "green" ,
28- "red" ,
29- "pink" ,
30- "yellow" ,
31- "userColor1" ,
32- "userColor2" ,
33- ] as const ;
34-
35- export const HAT_NON_DEFAULT_SHAPES = [
36- "ex" ,
37- "fox" ,
38- "wing" ,
39- "hole" ,
40- "frame" ,
41- "curve" ,
42- "eye" ,
43- "play" ,
44- "bolt" ,
45- "crosshairs" ,
46- ] as const ;
47-
48- export const HAT_SHAPES = [ "default" , ...HAT_NON_DEFAULT_SHAPES ] as const ;
49-
50- const charForShape : Map < string , string > = new Map (
51- Object . entries ( {
52- default : "*" ,
53- ex : "x" ,
54- fox : "v" ,
55- wing : "w" , // TODO: this is the only one that looks nothing like its shape
56- hole : "o" ,
57- frame : "#" ,
58- curve : "^" ,
59- eye : "0" ,
60- play : ">" ,
61- bolt : "~" ,
62- crosshairs : "+" ,
63- } ) ,
64- ) ;
65-
66- const charForColor : Map < string , string > = new Map (
67- Object . entries ( {
68- default : "*" ,
69- blue : "b" ,
70- green : "g" ,
71- red : "r" ,
72- pink : "p" ,
73- yellow : "y" ,
74- userColor1 : "1" ,
75- userColor2 : "2" ,
76- } ) ,
77- ) ;
22+ // We use special hat "colors"/"shapes" for nice ASCII art output.
23+ const HAT_COLORS = [ "default" , ..."ABCDEF" ] ;
24+ const HAT_NON_DEFAULT_SHAPES = [ ..."123456" ] ;
25+ const allHatStyles : HatStyleMap = {
26+ ...Object . fromEntries (
27+ HAT_COLORS . map ( ( color ) => [
28+ color ,
29+ {
30+ color,
31+ shape : "default" ,
32+ penalty : penaltyForColorShape ( color , "default" ) ,
33+ } ,
34+ ] ) ,
35+ ) ,
36+ ...Object . fromEntries (
37+ HAT_COLORS . flatMap ( ( color ) =>
38+ HAT_NON_DEFAULT_SHAPES . map ( ( shape ) => [
39+ `${ color } -${ shape } ` ,
40+ {
41+ color,
42+ shape,
43+ penalty : penaltyForColorShape ( color , shape ) ,
44+ } ,
45+ ] ) ,
46+ ) ,
47+ ) ,
48+ } ;
7849
7950const tokenHatSplittingDefaults : TokenHatSplittingMode = {
8051 preserveCase : false ,
@@ -101,31 +72,6 @@ suite("hatStats", () => {
10172 ...tokenHatSplittingDefaults ,
10273 } ) ;
10374 } ) ;
104- // Set up hat styles, mimicking the real thing.
105- const allHatStyles : HatStyleMap = {
106- ...Object . fromEntries (
107- HAT_COLORS . map ( ( color ) => [
108- color ,
109- {
110- color,
111- shape : "default" ,
112- penalty : penaltyForColorShape ( color , "default" ) ,
113- } ,
114- ] ) ,
115- ) ,
116- ...Object . fromEntries (
117- HAT_COLORS . flatMap ( ( color ) =>
118- HAT_NON_DEFAULT_SHAPES . map ( ( shape ) => [
119- `${ color } -${ shape } ` ,
120- {
121- color,
122- shape,
123- penalty : penaltyForColorShape ( color , shape ) ,
124- } ,
125- ] ) ,
126- ) ,
127- ) ,
128- } ;
12975
13076 const fixturePath = path . join (
13177 getCursorlessRepoRoot ( ) ,
@@ -328,17 +274,14 @@ function goldenHatFile(
328274 line1 += " " . repeat ( hatRange . start . character - line1 . length ) ;
329275 line1 += "_" ;
330276 } else if ( penalty === 1 ) {
331- const char =
332- color === "default"
333- ? charForShape . get ( shape )
334- : charForColor . get ( color ) ;
277+ const char = color === "default" ? shape : color ;
335278 line1 += " " . repeat ( hatRange . start . character - line1 . length ) ;
336279 line1 += char ;
337280 } else if ( penalty === 2 ) {
338281 line1 += " " . repeat ( hatRange . start . character - line1 . length ) ;
339- line1 += charForShape . get ( shape ) ;
282+ line1 += shape ;
340283 line2 += " " . repeat ( hatRange . start . character - line2 . length ) ;
341- line2 += charForColor . get ( color ) ;
284+ line2 += color ;
342285 } else {
343286 throw new Error ( `unexpected penalty: ${ penalty } ` ) ;
344287 }
0 commit comments