Skip to content

Commit

Permalink
Merge pull request #216 from juanferrer/master
Browse files Browse the repository at this point in the history
4.6.1
  • Loading branch information
ClipplerBlood authored Nov 26, 2024
2 parents 07fb497 + bb02aa1 commit 7466610
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
22 changes: 16 additions & 6 deletions src/module/data/item/AncestryDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export default class AncestryDataModel extends foundry.abstract.DataModel {
perception: source.characteristics.perceptionmodifier,
speed: source.characteristics.speed,
power: source.characteristics.power,
insanity: source.characteristics.insanity.value,
corruption: source.characteristics.corruption.value,
insanity: source.characteristics.insanity,
corruption: source.characteristics.corruption
},
talents: source.talents,
languages: source.languagelist
Expand All @@ -142,8 +142,10 @@ export default class AncestryDataModel extends foundry.abstract.DataModel {
source.levels = source.levels.concat([
{
level: '4',
attributeselect: '',
characteristicsHealth: source.level4.healthbonus,
attributeSelect: '',
characteristics: {
health: source.level4.healthbonus,
},
// option1 is not in use
// option1text is not in use, but let's add it anyways
optionsText: source.option1text,
Expand All @@ -156,23 +158,27 @@ export default class AncestryDataModel extends foundry.abstract.DataModel {
}

// Move separate attribute and characteristics properties into their respective objects
if (source.levels[source.levels.length - 1].attributeStrength != undefined) {
if (source.levels?.length > 0 && source.levels[source.levels.length - 1].attributeStrength != undefined) {
for (const level of source.levels) {
level.attributes = {
strength: {
value: level.attributes?.strength?.value ?? level.attributeStrength,
formula: level.attributes?.strength.formula,
selected: level.attributes?.strength?.selected ?? level.attributeStrengthSelected
},
agility: {
value: level.attributes?.agility?.value ?? level.attributeAgility,
formula: level.attributes?.agility.formula,
selected: level.attributes?.agility?.selected ?? level.attributeAgilitySelected
},
intellect: {
value: level.attributes?.intellect?.value ?? level.attributeIntellect,
formula: level.attributes?.intellect.formula,
selected: level.attributes?.intellect?.selected ?? level.attributeIntellectSelected
},
will: {
value: level.attributes?.will?.value ?? level.attributeWill,
formula: level.attributes?.will.formula,
selected: level.attributes?.will?.selected ?? level.attributeWillSelected
}
}
Expand All @@ -185,9 +191,13 @@ export default class AncestryDataModel extends foundry.abstract.DataModel {
power: level.characteristics?.power ?? level.characteristicsPower,
insanity: {
value: level.characteristics?.insanity?.value ?? level.characteristicsInsanity,
immune: level.characteristics?.insanity?.immune,
formula: level.characteristics?.insanity?.formula
},
corruption: {
value: level.characteristics?.corruption?.value ?? level.characteristicsCorruption
value: level.characteristics?.corruption?.value ?? level.characteristicsCorruption,
immune: level.characteristics?.corruption?.immune,
formula: level.characteristics?.corruption?.formula
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/module/data/item/PathDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,27 @@ export default class PathDataModel extends foundry.abstract.DataModel {

static migrateData(source) {
// Move separate attribute and characteristics properties into their respective objects
if (source.levels[0].attributeStrength != undefined) {
if (source.levels?.length > 0 && source.levels[0].attributeStrength != undefined) {
for (const level of source.levels) {
level.attributes = {
strength: {
value: level.attributes?.strength?.value ?? level.attributeStrength,
formula: level.attributes?.strength.formula,
selected: level.attributes?.strength?.selected ?? level.attributeStrengthSelected
},
agility: {
value: level.attributes?.agility?.value ?? level.attributeAgility,
formula: level.attributes?.agility.formula,
selected: level.attributes?.agility?.selected ?? level.attributeAgilitySelected
},
intellect: {
value: level.attributes?.intellect?.value ?? level.attributeIntellect,
formula: level.attributes?.intellect.formula,
selected: level.attributes?.intellect?.selected ?? level.attributeIntellectSelected
},
will: {
value: level.attributes?.will?.value ?? level.attributeWill,
formula: level.attributes?.will.formula,
selected: level.attributes?.will?.selected ?? level.attributeWillSelected
}
}
Expand All @@ -121,9 +125,13 @@ export default class PathDataModel extends foundry.abstract.DataModel {
power: level.characteristics?.power ?? level.characteristicsPower,
insanity: {
value: level.characteristics?.insanity?.value ?? level.characteristicsInsanity,
immune: level.characteristics?.insanity?.immune,
formula: level.characteristics?.insanity?.formula
},
corruption: {
value: level.characteristics?.corruption?.value ?? level.characteristicsCorruption
value: level.characteristics?.corruption?.value ?? level.characteristicsCorruption,
immune: level.characteristics?.corruption?.immune,
formula: level.characteristics?.corruption?.formula
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions src/module/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,27 @@ export class DemonlordItem extends Item {
rolls.push({property: 'corruption', roll: roll })
}

// Send a message to chat with all the rolls
const actor = game.user.character ?? canvas.tokens.controlled[0]?.actor

// If we dropped it into an actor, print the roll data
if (rolls.length > 0) {
const templateData = {
item: ancestry,
rolls,
}

const actor = game.user.character ?? canvas.tokens.controlled[0].actor
const rollMode = game.settings.get('core', 'rollMode')
if (actor) {
const rollMode = game.settings.get('core', 'rollMode')

const chatData = getChatBaseData(actor, rollMode)
const chatData = getChatBaseData(actor, rollMode)

const template = 'systems/demonlord/templates/chat/formulaeroll.hbs'
renderTemplate(template, templateData).then(async content => {
chatData.content = content
chatData.sound = CONFIG.sounds.dice
await ChatMessage.create(chatData)
})
const template = 'systems/demonlord/templates/chat/formulaeroll.hbs'
renderTemplate(template, templateData).then(async content => {
chatData.content = content
chatData.sound = CONFIG.sounds.dice
await ChatMessage.create(chatData)
})
}
}

const l0 = this.system.levels.find(l => l.level === '0')
Expand Down

0 comments on commit 7466610

Please sign in to comment.