11#!/usr/bin/env deno run --allow-read --allow-write
22/**
3- * Generates StdlibObjectMappings.java from WurstStdlib2 object editing wurst files.
3+ * Generates stdlib-obj-mappings.json from WurstStdlib2 object editing wurst files.
44 * Run this script after stdlib changes to regenerate the mappings used by the compiler
55 * when producing enriched object editing output.
66 *
@@ -14,12 +14,16 @@ function resolveStdlibBase(): string {
1414 return "./de.peeeq.wurstscript/temp/WurstStdlib2/wurst" ;
1515}
1616const STDLIB_BASE = resolveStdlibBase ( ) ;
17- const HELPER_ABILITY_FILE = "./HelperScripts/AbilityObjEditing.wurst" ;
18- const UNIT_BALANCE_SLK = "./HelperScripts/unitbalance.slk" ;
17+ function resolveUnitBalanceSlk ( ) : string {
18+ const legacy = "./HelperScripts/unitbalance.slk" ;
19+ try { Deno . statSync ( legacy ) ; return legacy ; } catch ( _ ) { }
20+ return `${ GAMEDATA_DIR } /unitbalance.slk` ;
21+ }
1922const OUT_FILE =
2023 "./de.peeeq.wurstscript/src/main/resources/stdlib-obj-mappings.json" ;
2124const KB_OUT_FILE = "./HelperScripts/wc3-knowledge-base.json" ;
2225const GAMEDATA_DIR = "./HelperScripts/gamedata" ;
26+ const UNIT_BALANCE_SLK = resolveUnitBalanceSlk ( ) ;
2327
2428// ---------------------------------------------------------------------------
2529// Types
@@ -823,33 +827,6 @@ const abilityClasses = parseObjEditingFile(
823827) ;
824828console . log ( `Parsed ${ abilityClasses . length } ability class definitions from stdlib` ) ;
825829
826- // Supplement with HelperScripts generated file: add classes for base IDs not already
827- // covered by the stdlib (these are abilities with only common fields — no specific fields).
828- try {
829- const helperClasses = parseObjEditingFile ( Deno . readTextFileSync ( HELPER_ABILITY_FILE ) ) ;
830- // Collect already-mapped base IDs from stdlib so we don't override them
831- const stdlibBaseIds = new Set < string > ( ) ;
832- for ( const cls of abilityClasses ) {
833- if ( cls . rawBaseId ) stdlibBaseIds . add ( cls . rawBaseId ) ;
834- if ( cls . abilityIdsConstant ) {
835- const r = abilityIdMap . get ( cls . abilityIdsConstant ) ;
836- if ( r ) stdlibBaseIds . add ( r ) ;
837- }
838- }
839- let supplemented = 0 ;
840- for ( const cls of helperClasses ) {
841- const rid = cls . rawBaseId ?? ( cls . abilityIdsConstant ? abilityIdMap . get ( cls . abilityIdsConstant ) : undefined ) ;
842- if ( rid && ! stdlibBaseIds . has ( rid ) ) {
843- abilityClasses . push ( cls ) ;
844- stdlibBaseIds . add ( rid ) ;
845- supplemented ++ ;
846- }
847- }
848- console . log ( `Supplemented ${ supplemented } base IDs from HelperScripts` ) ;
849- } catch ( _ ) {
850- console . log ( "HelperScripts/AbilityObjEditing.wurst not found, skipping supplement" ) ;
851- }
852-
853830const unitClasses = parseObjEditingFile (
854831 Deno . readTextFileSync ( `${ STDLIB_BASE } /objediting/UnitObjEditing.wurst` )
855832) ;
0 commit comments