-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from AnimaBeyondDevelop/fix/weapon-template-h…
…asOwnStr fix - weapon template hasOwnStr
- Loading branch information
Showing
5 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/module/migration/migrations/7-fix-weapons-ownStrength.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @typedef {import('./Migration').Migration} Migration | ||
/** @type Migration */ | ||
export const Migration7WeaponsOwnStrength = { | ||
version: 7, | ||
title: 'Migrate weapons own strength', | ||
description: | ||
'Shoot weapons often has its own strength for calculating the damage modifiers. ' + | ||
'However, this are sometimes in an old argument `system.weaponFue`.\n' + | ||
'Additionally, weapons have a `system.hasOwnStr` used to distinguish these cases. ' + | ||
'This migration will ensure weapons have all this values syncronised.', | ||
filterItems(item) { | ||
return item.type === 'weapon' && !!item.system.isRanged.value; | ||
}, | ||
filterActors(actor) { | ||
return actor.getWeapons().filter(w => w.system.isRanged.value).length !== 0; | ||
}, | ||
async updateItem(item) { | ||
if (item.type !== 'weapon') { | ||
console.error('AnimaBF | weapon filter in migration not working'); | ||
return; | ||
} | ||
|
||
if (item.system.weaponStrength.base.value === 0 && item.system.weaponFue?.value) { | ||
item.system.weaponStrength.base.value = item.system.weaponFue?.value ?? 0; | ||
} | ||
|
||
item.system.hasOwnStr = { value: !!item.system.weaponStrength.base.value }; | ||
|
||
return item; | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
src/module/migration/migrations/8-remove-unused-weaponFue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @typedef {import('./Migration').Migration} Migration | ||
/** @type Migration */ | ||
export const Migration8RemoveWeaponFue = { | ||
version: 8, | ||
title: 'Remove old, unused `weaponFue` from weapons', | ||
description: | ||
'`system.weaponFue` in weapons is no longer used, so this migration removes it.', | ||
filterItems(item) { | ||
return item.type === 'weapon'; | ||
}, | ||
filterActors(actor) { | ||
return actor.getWeapons().length !== 0; | ||
}, | ||
async updateItem(item) { | ||
if (item.type !== 'weapon') { | ||
console.error('AnimaBF | weapon filter in migration not working'); | ||
return; | ||
} | ||
await item.update({ 'system.-=weaponFue': null }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters