@@ -8,6 +8,7 @@ interface CataloguedPremoveMetadata {
88 readonly source ?: 'user' | 'fairy-stockfish-builtin' ;
99 readonly ini ?: string ;
1010 readonly baseVariant ?: string ;
11+ readonly betzaPieces ?: Readonly < Record < string , string > > ;
1112}
1213
1314interface CataloguedPremoveDefinition {
@@ -65,6 +66,11 @@ function parsePremoveDefinition(meta: CataloguedPremoveMetadata): CataloguedPrem
6566 const movements = new Map < string , BetzaPremove > ( ) ;
6667 let kingRoleLetter : string | undefined ;
6768
69+ for ( const [ roleLetter , betza ] of Object . entries ( meta . betzaPieces ?? { } ) ) {
70+ const normalizedRole = normalRoleLetter ( roleLetter ) ;
71+ if ( normalizedRole ) movements . set ( normalizedRole , createBetzaPremove ( betza ) ) ;
72+ }
73+
6874 for ( const { key, value } of options ) {
6975 const normalizedKey = key . toLowerCase ( ) ;
7076 if ( ! ( normalizedKey === 'king' || / ^ c u s t o m p i e c e \d + $ / i. test ( key ) ) || value === '-' ) continue ;
@@ -85,13 +91,10 @@ function parsePremoveDefinition(meta: CataloguedPremoveMetadata): CataloguedPrem
8591}
8692
8793export function registerCataloguedPremove ( meta : CataloguedPremoveMetadata ) : void {
88- // Site variants and catalogued Fairy-Stockfish built-ins continue to use
89- // chessgroundx's established hard-coded premoves. The generic Betza path is
90- // intentionally limited to user-defined variants.
91- if ( ! meta . name || meta . source === 'fairy-stockfish-builtin' ) {
92- cataloguedPremoveDefinitions . delete ( meta . name ) ;
93- return ;
94- }
94+ // Site variants never register here and keep chessgroundx's established
95+ // premoves. Catalogued variants can supplement their base-variant fallback
96+ // with Betza movement definitions resolved by the server.
97+ if ( ! meta . name ) return ;
9598 cataloguedPremoveDefinitions . set ( meta . name , parsePremoveDefinition ( meta ) ) ;
9699}
97100
0 commit comments