diff --git a/lang/en.json b/lang/en.json index 3e65c8a..7e93497 100644 --- a/lang/en.json +++ b/lang/en.json @@ -441,7 +441,8 @@ }, "Notitications": { "NoWeaponSkill": "No weapon skill found for this weapon. Check Weapon definition or available skills/era", - "NoWeaponType": "No weapon type found for this weapon subtype. Check Weapon definition or available skills/era" + "NoWeaponType": "No weapon type found for this weapon subtype. Check Weapon definition or available skills/era", + "skillAlreadyExists": "Skill already exists" } } } diff --git a/module/applications/sheets/protagonist-sheet.mjs b/module/applications/sheets/protagonist-sheet.mjs index 5bba1dc..612d6c4 100644 --- a/module/applications/sheets/protagonist-sheet.mjs +++ b/module/applications/sheets/protagonist-sheet.mjs @@ -98,22 +98,30 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS case "skills": context.tab = context.tabs.skills context.skills = doc.itemTypes.skill + context.skills.sort((a, b) => a.name.localeCompare(b.name)) break case "equipment": context.tab = context.tabs.equipment context.weapons = doc.itemTypes.weapon + context.weapons.sort((a, b) => a.name.localeCompare(b.name)) context.armors = doc.itemTypes.armor + context.armors.sort((a, b) => a.name.localeCompare(b.name)) context.gears = doc.itemTypes.gear + context.gears.sort((a, b) => a.name.localeCompare(b.name)) break case "status": context.tab = context.tabs.status context.injuries = doc.itemTypes.injury + context.injuries.sort((a, b) => a.name.localeCompare(b.name)) context.mentaldisorders = doc.itemTypes.mentaldisorder + context.mentaldisorders.sort((a, b) => a.name.localeCompare(b.name)) context.bonds = doc.itemTypes.bond + context.bonds.sort((a, b) => a.name.localeCompare(b.name)) break case "biography": context.tab = context.tabs.biography context.motivations = doc.itemTypes.motivation + context.motivations.sort((a, b) => a.name.localeCompare(b.name)) context.enrichedDescription = await TextEditor.enrichHTML(doc.system.description, { async: true }) context.enrichedNotes = await TextEditor.enrichHTML(doc.system.notes, { async: true }) break diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index ee82081..1c9c01a 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -1,7 +1,7 @@ import CthulhuEternalUtils from "../utils.mjs" export default class CthulhuEternalActor extends Actor { - + static async create(data, options) { // Case of compendium global import @@ -19,7 +19,7 @@ export default class CthulhuEternalActor extends Actor { const skills = await CthulhuEternalUtils.loadCompendium("fvtt-cthulhu-eternal.skills") data.items = data.items || [] for (let skill of skills) { - if (skill.system.settings === era ) { + if (skill.system.settings === era) { data.items.push(skill.toObject()) } } @@ -30,7 +30,7 @@ export default class CthulhuEternalActor extends Actor { _onUpdate(changed, options, userId) { // DEBUG : console.log("CthulhuEternalActor.update", changed, options, userId) - if ( changed?.system?.wp?.exhausted) { + if (changed?.system?.wp?.exhausted) { ChatMessage.create({ user: userId, speaker: { alias: this.name }, @@ -42,19 +42,36 @@ export default class CthulhuEternalActor extends Actor { return super._onUpdate(changed, options, userId) } - async _preCreate(data, options, user) { - await super._preCreate(data, options, user) - - // Configure prototype token settings - const prototypeToken = {} - if (this.type === "protagonist") { - Object.assign(prototypeToken, { - sight: { enabled: true }, - actorLink: true, - disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY, - }) - this.updateSource({ prototypeToken }) + async createEmbeddedDocuments(embeddedName, data, operation) { + let newData = [] + if (embeddedName === "Item") { + for (let i of data) { + if (i.type === "skill") { + if (this.items.find(item => item.name.toLowerCase() === i.name.toLowerCase())) { + ui.notifications.warn(game.i18n.localize("CTHULHUETERNAL.Notifications.skillAlreadyExists")) + continue + } + } + newData.push(i) + } + return super.createEmbeddedDocuments(embeddedName, newData, operation) } + return super.createEmbeddedDocuments(embeddedName, data, operation) } + async _preCreate(data, options, user) { + await super._preCreate(data, options, user) + + // Configure prototype token settings + const prototypeToken = {} + if (this.type === "protagonist") { + Object.assign(prototypeToken, { + sight: { enabled: true }, + actorLink: true, + disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY, + }) + this.updateSource({ prototypeToken }) + } +} + } diff --git a/packs-system/skills/000053.log b/packs-system/skills/000053.log new file mode 100644 index 0000000..e69de29 diff --git a/packs-system/skills/CURRENT b/packs-system/skills/CURRENT index a9ebced..f774e85 100644 --- a/packs-system/skills/CURRENT +++ b/packs-system/skills/CURRENT @@ -1 +1 @@ -MANIFEST-000048 +MANIFEST-000052 diff --git a/packs-system/skills/LOG b/packs-system/skills/LOG index 8f92da3..733f366 100644 --- a/packs-system/skills/LOG +++ b/packs-system/skills/LOG @@ -1,3 +1,3 @@ -2025/01/09-15:39:16.704802 7f0abb7fe6c0 Recovering log #46 -2025/01/09-15:39:16.715860 7f0abb7fe6c0 Delete type=3 #44 -2025/01/09-15:39:16.715933 7f0abb7fe6c0 Delete type=0 #46 +2025/01/10-00:04:46.700736 7f0abaffd6c0 Recovering log #50 +2025/01/10-00:04:46.711152 7f0abaffd6c0 Delete type=3 #48 +2025/01/10-00:04:46.711210 7f0abaffd6c0 Delete type=0 #50 diff --git a/packs-system/skills/LOG.old b/packs-system/skills/LOG.old index 017b0cb..c7f8318 100644 --- a/packs-system/skills/LOG.old +++ b/packs-system/skills/LOG.old @@ -1,8 +1,8 @@ -2025/01/09-15:36:12.923109 7f0aba7fc6c0 Recovering log #42 -2025/01/09-15:36:12.933058 7f0aba7fc6c0 Delete type=3 #40 -2025/01/09-15:36:12.933138 7f0aba7fc6c0 Delete type=0 #42 -2025/01/09-15:36:31.742879 7f0ab9bff6c0 Level-0 table #47: started -2025/01/09-15:36:31.742910 7f0ab9bff6c0 Level-0 table #47: 0 bytes OK -2025/01/09-15:36:31.749117 7f0ab9bff6c0 Delete type=0 #45 -2025/01/09-15:36:31.749289 7f0ab9bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) -2025/01/09-15:36:31.759629 7f0ab9bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) +2025/01/09-15:39:16.704802 7f0abb7fe6c0 Recovering log #46 +2025/01/09-15:39:16.715860 7f0abb7fe6c0 Delete type=3 #44 +2025/01/09-15:39:16.715933 7f0abb7fe6c0 Delete type=0 #46 +2025/01/09-16:20:07.336867 7f0ab9bff6c0 Level-0 table #51: started +2025/01/09-16:20:07.336898 7f0ab9bff6c0 Level-0 table #51: 0 bytes OK +2025/01/09-16:20:07.343031 7f0ab9bff6c0 Delete type=0 #49 +2025/01/09-16:20:07.352821 7f0ab9bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) +2025/01/09-16:20:07.369688 7f0ab9bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) diff --git a/packs-system/skills/MANIFEST-000052 b/packs-system/skills/MANIFEST-000052 new file mode 100644 index 0000000..835b91b Binary files /dev/null and b/packs-system/skills/MANIFEST-000052 differ