Skip to content
Merged

5.5.0 #287

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@
"DL.AvailabilityR": "Rare",
"DL.AvailabilityU": "Uncommon",
"DL.BackgroundTitle": "Background",
"DL.BecomeFrightenedForRound" : "You become frightened for {round} round.",
"DL.BecomeFrightenedForRounds" : "You become frightened for {round} rounds.",
"DL.BecomeStunned" : "You become stunned for {round} round.",
"DL.BecomeFrightenedForRound": "You become frightened for {round} round.",
"DL.BecomeFrightenedForRounds": "You become frightened for {round} rounds.",
"DL.BecomeStunned": "You become stunned for {round} round.",
"DL.ButtonEdit": "Edit",
"DL.ButtonView": "View",
"DL.ChallengeRequestRollText": "Request Challenge Roll",
Expand Down Expand Up @@ -308,6 +308,7 @@
"DL.DialogDeleteSpellText": "The Spell will be permanently deleted.",
"DL.DialogDeleteTraditionText": "The Tradition and all spells attached will be permanently deleted.",
"DL.DialogDeleteTraitText": "The Trait will be permanently deleted.",
"DL.DialogDeleteCreatureRoleText": "The Creature Role will be permanently deleted.",
"DL.DialogFortuneAwarded": "Awarded a Fortune point.",
"DL.DialogFortuneExpended": "Expended a Fortune point.",
"DL.DialogHealedFor": "Healed ",
Expand Down Expand Up @@ -356,6 +357,7 @@
"DL.DialogWarningActorDamageImmune": "Actor is immune to this type of damage.",
"DL.DialogWarningActorsNotSelected": "Actor(s) not selected",
"DL.DialogWarningActorsNotTargeted": "Actor(s) not targeted",
"DL.DialogWarningAfflictionFromEffect": "Affliction is applied from effect. Remove the effect to remove the affliction.",
"DL.DialogWarningBlindedChallengeFailer": "You're blinded and perception challenge rolls result in failure.",
"DL.DialogWarningCreatureArmor": "You can't add armor to a creature. Change the Defense value manually.",
"DL.DialogWarningDazedFailer": "You're dazed and cannot use actions.",
Expand Down Expand Up @@ -391,8 +393,8 @@
"DL.FeaturesTitle": "Features",
"DL.FourOrMoreCreatures": "Four or more creatures at once",
"DL.FourOrMoreCreaturesInSight": "Sees four or more creatures at once",
"DL.GainedInsanity" : "You gain {insanity} Insanity.",
"DL.GainedInsanityAndGoMad" : "You gain {insanity} Insanity and go mad.",
"DL.GainedInsanity": "You gain {insanity} Insanity.",
"DL.GainedInsanityAndGoMad": "You gain {insanity} Insanity and go mad.",
"DL.GMTools": "GM Tools",
"DL.GMnote": "GM Notes",
"DL.GMnoteEdit": "Edit GM Note",
Expand All @@ -401,6 +403,7 @@
"DL.ImmuneAffliction": "Immune to Affliction",
"DL.ImmuneAttribute": "Immune Attribute",
"DL.ImmuneCharacteristic": "Immune Characteristic",
"DL.AfflictionImmunityEffectName": "{affliction} Immunity",
"DL.IsFrightening": "Is Frightening",
"DL.IsHorrifying": "Is Horrifying",
"DL.ItemAddItem": "Add item",
Expand Down Expand Up @@ -591,6 +594,8 @@
"DL.SettingConcentrationEffectHint": "Apply effect with duration when casting a spell which requires concentration.",
"DL.SettingConfirmAncestryPathRemoval": "Confirm ancestry/path removal",
"DL.SettingConfirmAncestryPathRemovalHint": "Show a confirmation dialog when attempting to remove an ancestry or path from a character of level 1 or higher.",
"DL.SettingConfirmCreatureRoleRemoval": "Confirm creature role removal",
"DL.SettingConfirmCreatureRoleRemovalHint": "Show a confirmation dialog when attempting to remove a creature role from a character of level 1 or higher.",
"DL.SettingConvertIntoBadge": "Convert icons into badges.",
"DL.SettingConvertIntoBadgeHint": "Surround ancestry and path icons with a badge background.",
"DL.SettingDSN": "Dice So Nice! Configuration",
Expand Down
7 changes: 6 additions & 1 deletion src/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"DL.DialogDeleteSpellText": "El Hechizo será borrado permanentemente.",
"DL.DialogDeleteTraditionText": "La Tradición y todos los conjuros vinculados serán borrados permanentemente.",
"DL.DialogDeleteTraitText": "El Rasgo será borrado permanentemente.",
"DL.DialogDeleteCreatureRoleText": "El Rol de Criatura será borrado permanentemente.",
"DL.DialogFortuneAwarded": "Punto de Fortuna otorgado.",
"DL.DialogFortuneExpended": "Punto de Fortuna consumido.",
"DL.DialogHealedFor": "Curado(s) ",
Expand Down Expand Up @@ -344,10 +345,11 @@
"DL.DialogUseItemHealingPotion": "Poción de Curación",
"DL.DialogUseItemHealingPotionText": "Cura # puntos de daño.",
"DL.DialogUseTalent": "Usar Talento",
"DL.DialogWarningActorImmune": "Eres inmune a este estado.",
"DL.DialogWarningActorImmune": "Eres inmune a esta aflicción.",
"DL.DialogWarningActorDamageImmune": "Actor es inmune a este tipo de daño.",
"DL.DialogWarningActorsNotSelected": "Actor(es) no seleccionados",
"DL.DialogWarningActorsNotTargeted": "Actor(es) no marcado(s) como Objetivo",
"DL.DialogWarningAfflictionFromEffect": "Esta aflicción fue aplicado por un efecto. Elimina el efecto para eliminar la aflicción.",
"DL.DialogWarningBlindedChallengeFailer": "Estás cegado y todas tus pruebas de percepción fallan automáticamente.",
"DL.DialogWarningCreatureArmor": "No puedes añadir una armadura a una criatura. Cambia el valor de Defensa manualmente.",
"DL.DialogWarningDazedFailer": "Estás desorientado y no puedes realizar acciones.",
Expand Down Expand Up @@ -389,6 +391,7 @@
"DL.ImmuneAffliction": "Inmune a Aflicción",
"DL.ImmuneAttribute": "Atributo Inmune",
"DL.ImmuneCharacteristic": "Característica Inmune",
"DL.AfflictionImmunityEffectName": "Inmunidad a {affliction}",
"DL.IsFrightening": "Es Aterradora",
"DL.IsHorrifying": "Es Horripilante",
"DL.ItemAddItem": "Añadir Objeto",
Expand Down Expand Up @@ -569,6 +572,8 @@
"DL.SettingConcentrationEffectHint": "Aplicar efecto con la duración cuandose lance un hechizo que requiera concentración.",
"DL.SettingConfirmAncestryPathRemoval": "Confirmar eliminación de linaje/senda",
"DL.SettingConfirmAncestryPathRemovalHint": "Muestra un diálogo de confirmación al intentar borrar un linaje o una senda de un personaje de nivel 1 o mayor.",
"DL.SettingConfirmCreatureRoleRemoval": "Confirmar eliminación de rol de criatura",
"DL.SettingConfirmCreatureRoleRemovalHint": "Muestra un diálogo de confirmación al intentar borrar un rol de criatura de una criatura.",
"DL.SettingConvertIntoBadge": "Convertir en insignia.",
"DL.SettingConvertIntoBadgeHint": "Rodear los icono de linaje y senda con un fondo de insignia.",
"DL.SettingDSN": "Configuración de Dice So Nice!",
Expand Down
77 changes: 76 additions & 1 deletion src/module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {handleCreateAncestry, handleCreatePath, handleCreateRole, handleCreateRelic } from '../item/nested-objects'
import {TokenManager} from '../pixi/token-manager'
import {findAddEffect, findDeleteEffect} from "../demonlord";
import { createActorNestedItems } from '../item/nested-objects'

const tokenManager = new TokenManager()

Expand Down Expand Up @@ -344,6 +345,80 @@ export class DemonlordActor extends Actor {
// Don't need to update anything if the only change is the edit item state
const isNameChange = documents.length === 1 && data[0].name !== undefined

const documentChanges = {}

// Make a list of the necessary changes to the levels, which we will update afterwards
for (const sourceDocument of documents) {
if (sourceDocument.type === 'ancestry' || sourceDocument.type === 'path') {
// Property will be the level and value is an array of stuff
const addedItems = {}
let updateDocument = data.find(d => d._id === sourceDocument._id)

if (!updateDocument.system.levels?.length) continue // Didn't change the levels, nothing to do

const itemsFromThisDocument = this.items.filter(i => i.flags.demonlord?.parentItemId === sourceDocument._id)

documentChanges[sourceDocument._id] = {
}

// Now go through each level and search for the items
for (const level of updateDocument.system.levels.filter(l => parseInt(l.level) <= this.system.level)) {
addedItems[level.level] = {
languages: [],
spells: [],
talents: [],
talentspick: [],
talentsSelected: []
}

// Languages
for (const item of level.languages) {
const foundItem = itemsFromThisDocument.find(i => i.flags.demonlord?.levelRequired === level.level && i.flags.demonlord?.nestedItemId === item.id)

if (!foundItem) {
addedItems[level.level].languages.push(item)
} else {
itemsFromThisDocument.splice(itemsFromThisDocument.indexOf(foundItem), 1)
}
}

// Spells
for (const item of level.spells) {
const foundItem = itemsFromThisDocument.find(i => i.flags.demonlord?.levelRequired === level.level && i.flags.demonlord?.nestedItemId === item.id)

if (!foundItem) {
addedItems[level.level].spells.push(item)
} else {
itemsFromThisDocument.splice(itemsFromThisDocument.indexOf(foundItem), 1)
}
}

// Talents
for (const item of level.talents.concat(level.talentspick, level.talentsSelected)) {
const foundItem = itemsFromThisDocument.find(i => i.flags.demonlord?.levelRequired === level.level && i.flags.demonlord?.nestedItemId === item.id)

if (!foundItem) {
addedItems[level.level].talents.push(item)
} else {
itemsFromThisDocument.splice(itemsFromThisDocument.indexOf(foundItem), 1)
}
}

documentChanges[sourceDocument._id][level.level] = {
toRemove: itemsFromThisDocument,
toAdd: addedItems[level.level].languages.concat(addedItems[level.level].spells, addedItems[level.level].talents)
}
}

this.deleteEmbeddedDocuments('Item', Object.values(documentChanges).map(o => Object.values(o)).flat()[0].toRemove.map(i => i.id))

for (const documentSource in documentChanges) {
for (const level in documentChanges[documentSource])
await createActorNestedItems(this, documentChanges[documentSource][level].toAdd, documentSource, level)
}
}
}

if ((collection === 'items' || collection === 'effects') && userId === game.userId && !options.noEmbedEffects)
await this._handleOnUpdateDescendant(documents, isNameChange).then(_ => this.sheet.render())
}
Expand Down Expand Up @@ -572,7 +647,7 @@ export class DemonlordActor extends Actor {
await challengeRoll.evaluate()

if (mode) postCustomTextToChat(this, challengeRoll, mode, attribute.key)
else
else
postAttributeToChat(this, attribute.key, challengeRoll, parseInt(inputBoons) || 0, parseInt(inputModifier) || 0)

for (let effect of this.appliedEffects) {
Expand Down
Loading