Skip to content

Commit

Permalink
Fixed a templating bug with HP Bonuses from talents. Also added an ex…
Browse files Browse the repository at this point in the history
…plicit cast to Number() in the HP calc to help further protect against invalid input.

#20
  • Loading branch information
AlexOkafor committed Sep 6, 2020
1 parent bd85059 commit 523bc70
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.96
- Fixed a templating bug with HP Bonuses in talents that would cause the HP Bar to become too large.

# 0.95
- Added support for HP bonuses in Talents. Talent items now have an HP Bonus field.
- Added proper support for Melee weapons. Weapon items now have a melee checkbox. It will now roll the correct skill+attributes for melee combat.
Expand Down
2 changes: 1 addition & 1 deletion module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class yzecoriolisActor extends Actor {
continue
}
const tData = t.data;
bonus += tData.hpBonus
bonus += Number(tData.hpBonus)
}
return bonus;
}
Expand Down
7 changes: 3 additions & 4 deletions module/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ export class yzecoriolisItem extends Item {
const itemData = this.data;
const actorData = this.actor ? this.actor.data : {};
const data = itemData.data;

if (itemData.type === 'character') this._prepareItemData(itemData);
if (itemData.type === 'talent') this._prepareTalentData(itemData);
}

_prepareItemData(itemData) {
// prep item data?
_prepareTalentData(itemData) {

}

async roll() {
Expand Down
4 changes: 4 additions & 0 deletions module/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ export const migrateItemData = function (item) {
} else if (item.type === 'weapon' && !hasProperty(item.data, 'melee')) {
updateData = { 'data.melee': false }
}
// fix string contamination of talents' hpBonus fields
if (item.type === 'talent' && hasProperty(item.data, 'hpBonus')) {
updateData = { 'data.hpBonus': Number(item.data.hpBonus) }
}
// Remove deprecated fields
_migrateRemoveDeprecated(item, updateData);

Expand Down
2 changes: 1 addition & 1 deletion module/yzecoriolis.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Hooks.on('getSceneControlButtons', (controls) => {
Hooks.once('ready', async function () {
// Determine whether a system migration is required and feasible
const currentVersion = game.settings.get("yzecoriolis", "systemMigrationVersion");
const NEEDS_MIGRATION_VERSION = 0.95;
const NEEDS_MIGRATION_VERSION = 0.96;
const COMPATIBLE_MIGRATION_VERSION = 0.4;
let needMigration = (currentVersion < NEEDS_MIGRATION_VERSION) || (currentVersion === null) || (isNaN(currentVersion));

Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "yzecoriolis",
"title": "Year Zero Engine - Coriolis",
"description": "The Year Zero Engine - Coriolis System for Foundry VTT.",
"version": 0.95,
"version": 0.96,
"minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.6.6",
"templateVersion": 2,
Expand All @@ -28,5 +28,5 @@
"secondaryTokenAttribute": "power",
"url": "",
"manifest": "https://raw.githubusercontent.com/winks-vtt/yze-coriolis/master/system.json",
"download": "https://github.com/winks-vtt/yze-coriolis/archive/v0.95.zip"
"download": "https://github.com/winks-vtt/yze-coriolis/archive/v0.96.zip"
}
2 changes: 1 addition & 1 deletion template.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"category": "",
"cost": 0,
"groupConcept": "",
"hpBonus": ""
"hpBonus": 0
},
"weapon": {
"templates": ["gear"],
Expand Down

0 comments on commit 523bc70

Please sign in to comment.