@@ -42,6 +42,7 @@ export function migrate() {
4242 let isSuccess = true ;
4343 isSuccess = ( ! migrationVersion || foundry . utils . isNewerVersion ( "1.3.4" , migrationVersion ) ) ? migrateRollMode ( ) : true ;
4444 isSuccess = ( ! migrationVersion || foundry . utils . isNewerVersion ( "1.4.0" , migrationVersion ) ) ? migrateAwardInspirationRollType ( ) : true ;
45+ isSuccess = ( ! migrationVersion || foundry . utils . isNewerVersion ( "2.2.4" , migrationVersion ) ) ? migrateConditions ( ) : true ;
4546
4647 if ( isSuccess ) {
4748 setSetting ( constants . VERSION . SETTING . KEY , moduleVersion ) ;
@@ -101,3 +102,36 @@ export async function migrateAwardInspirationRollType() {
101102 await setSetting ( CONSTANTS . INSPIRATION . SETTING . AWARD_INSPIRATION_ROLL_TYPES . KEY , newRollTypes ) ;
102103 return true ;
103104}
105+
106+ /* -------------------------------------------- */
107+
108+ /**
109+ * Migrate condition settings to use 'name' and 'img' properties instead of 'label' and 'icon'.
110+ * @returns {Promise<boolean> } Whether the migration was successful
111+ */
112+ export async function migrateConditions ( ) {
113+ try {
114+ Logger . debug ( "Migrating conditions..." ) ;
115+ const conditions = foundry . utils . deepClone ( getSetting ( CONSTANTS . CONDITIONS . SETTING . CONFIG . KEY ) ) ;
116+
117+ if ( ! conditions ) return true ;
118+
119+ for ( const value of Object . values ( conditions ) ) {
120+ const name = value ?. name ?? value ?. label ;
121+ const img = value ?. img ?? value ?. icon ;
122+
123+ value . name = name ;
124+ value . img = img ;
125+
126+ delete value . label ;
127+ delete value . icon ;
128+ }
129+
130+ await setSetting ( CONSTANTS . CONDITIONS . SETTING . CONFIG . KEY , conditions ) ;
131+ Logger . debug ( "Conditions migrated." ) ;
132+ return true ;
133+ } catch ( err ) {
134+ Logger . debug ( err . message , err ) ;
135+ return false ;
136+ }
137+ }
0 commit comments