From 5176433b06ef69be271916de13d6fa8d0c121652 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sat, 3 Sep 2022 11:56:14 -0400 Subject: [PATCH 01/12] update system.json and .js files (may still be some missed items) --- module/actor/actor-sheet.js | 72 +++++++++++++------------ module/actor/actor.js | 103 +++++++++++++++++------------------- module/deltagreen.js | 16 +++--- module/item/item-sheet.js | 2 +- module/item/item.js | 22 ++++---- system.json | 6 +++ 6 files changed, 113 insertions(+), 108 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 4f195a5..08afd9e 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -22,7 +22,7 @@ export class DeltaGreenActorSheet extends ActorSheet { get template() { if(this.actor !== null){ - if(this.actor.data.type === 'agent'){ + if(this.actor.type === 'agent'){ if ( !game.user.isGM && this.actor.limited ) { return "systems/deltagreen/templates/actor/limited-sheet.html"; } @@ -31,10 +31,10 @@ export class DeltaGreenActorSheet extends ActorSheet { return `systems/deltagreen/templates/actor/actor-sheet.html`; } } - else if(this.actor.data.type === 'unnatural'){ + else if(this.actor.type === 'unnatural'){ return `systems/deltagreen/templates/actor/unnatural-sheet.html`; } - else if(this.actor.data.type === 'npc'){ + else if(this.actor.type === 'npc'){ return `systems/deltagreen/templates/actor/npc-sheet.html`; } else{ @@ -51,7 +51,7 @@ export class DeltaGreenActorSheet extends ActorSheet { const data = super.getData(); // Prepare items. - if (this.actor.data.type == 'agent') { + if (this.actor.type == 'agent') { this._prepareCharacterItems(data); } @@ -75,7 +75,7 @@ export class DeltaGreenActorSheet extends ActorSheet { // Iterate through items, allocating to containers // let totalWeight = 0; for (let i of sheetData.items) { - let item = i.data; + let item = i; i.img = i.img || DEFAULT_TOKEN; // Append to armor. if (i.type === 'armor') { @@ -208,9 +208,9 @@ export class DeltaGreenActorSheet extends ActorSheet { event.preventDefault(); let currentBreakingPoint = 0; - currentBreakingPoint = this.actor.data.data.sanity.value - this.actor.data.data.statistics.pow.value; + currentBreakingPoint = this.actor.system.sanity.value - this.actor.system.statistics.pow.value; - let updatedData = duplicate(this.actor.data.data); + let updatedData = duplicate(this.actor.system); updatedData.sanity.currentBreakingPoint = currentBreakingPoint; this.actor.update({"data": updatedData}); }); @@ -227,8 +227,8 @@ export class DeltaGreenActorSheet extends ActorSheet { event.preventDefault(); let targetskill = event.target.getAttribute("data-typedskill"); - let existingLabel = this.actor.data.data.typedSkills[targetskill].label; - let existingGroup = this.actor.data.data.typedSkills[targetskill].group; + let existingLabel = this.actor.system.typedSkills[targetskill].label; + let existingGroup = this.actor.system.typedSkills[targetskill].group; //this.actor.update({[`data.typedSkills.${targetskill}.label`]: 'test'}); @@ -242,7 +242,7 @@ export class DeltaGreenActorSheet extends ActorSheet { let targetskill = event.target.getAttribute("data-typedskill"); // many bothans died to bring us this information on how to delete a property on an entity - this.actor.update({[`data.typedSkills.-=${targetskill}`]: null}); + this.actor.update({[`system.typedSkills.-=${targetskill}`]: null}); }); @@ -396,7 +396,7 @@ export class DeltaGreenActorSheet extends ActorSheet { } _addNewTypedSkill(newSkillLabel, newSkillGroup){ - let updatedData = duplicate(this.actor.data.data); + let updatedData = duplicate(this.actor.system); let typedSkills = updatedData.typedSkills; let d = new Date(); @@ -413,7 +413,7 @@ export class DeltaGreenActorSheet extends ActorSheet { _updateTypedSkill(targetSkill, newSkillLabel, newSkillGroup){ if(newSkillLabel !== null && newSkillLabel !== "" && newSkillGroup !== null & newSkillGroup !== ""){ - let updatedData = duplicate(this.actor.data.data); + let updatedData = duplicate(this.actor.system); updatedData.typedSkills[targetSkill].label = newSkillLabel; updatedData.typedSkills[targetSkill].group = newSkillGroup; @@ -433,8 +433,10 @@ export class DeltaGreenActorSheet extends ActorSheet { const header = event.currentTarget; // Get the type of item to create. const type = header.dataset.type; + // Grab any data associated with this control. - const data = duplicate(header.dataset); + //const system = duplicate(header.dataset); Not really sure what this was doing here. Seems unnecessary. + // Initialize a default name. //const name = `New ${type.capitalize()}`; const name = game.i18n.localize("DG.ItemTypes.NewPrefix") + game.i18n.localize("DG.ItemTypes." + type) @@ -442,22 +444,22 @@ export class DeltaGreenActorSheet extends ActorSheet { const itemData = { name: name, type: type, - data: data + system: {} }; // Remove the type from the dataset since it's in the itemData.type prop. - delete itemData.data["type"]; + // delete itemData.data["type"]; if(type == "weapon"){ - itemData.data.skill = "firearms"; //default skill to firearms, since that will be most common - itemData.data.expense = "Standard"; + itemData.system.skill = "firearms"; //default skill to firearms, since that will be most common + itemData.system.expense = "Standard"; } else if(type == "armor"){ - itemData.data.armor = 3; - itemData.data.expense = "Standard"; + itemData.system.armor = 3; + itemData.system.expense = "Standard"; } else if(type == "bond"){ - itemData.data.score = this.object.data.data.statistics.cha.value; // Can vary, but at character creation starting bond score is usually agent's charisma + itemData.system.score = this.object.system.statistics.cha.value; // Can vary, but at character creation starting bond score is usually agent's charisma itemData.img = "icons/svg/mystery-man.svg" } @@ -506,40 +508,40 @@ export class DeltaGreenActorSheet extends ActorSheet { // otherwise roll a regular skill test if(targetVal === "dex"){ label = game.i18n.localize("DG.Attributes.dex").toUpperCase() + "x5"; - targetVal = this.actor.data.data.statistics.dex.x5; + targetVal = this.actor.system.statistics.dex.x5; } else if(targetVal === "int"){ label = game.i18n.localize("DG.Attributes.int").toUpperCase() + "x5"; - targetVal = this.actor.data.data.statistics.int.x5; + targetVal = this.actor.system.statistics.int.x5; } else if(targetVal === "str"){ label = game.i18n.localize("DG.Attributes.str").toUpperCase() + "x5"; - targetVal = this.actor.data.data.statistics.str.x5; + targetVal = this.actor.system.statistics.str.x5; } else if(targetVal === "con"){ label = game.i18n.localize("DG.Attributes.con").toUpperCase() + "x5"; - targetVal = this.actor.data.data.statistics.con.x5; + targetVal = this.actor.system.statistics.con.x5; } else if(targetVal === "pow"){ label = game.i18n.localize("DG.Attributes.pow").toUpperCase() + "x5"; - targetVal = this.actor.data.data.statistics.pow.x5; + targetVal = this.actor.system.statistics.pow.x5; } else if(targetVal === "cha"){ label = game.i18n.localize("DG.Attributes.cha").toUpperCase() + "x5"; - targetVal = this.actor.data.data.statistics.cha.x5; + targetVal = this.actor.system.statistics.cha.x5; } else{ label = game.i18n.localize("DG.Skills." + targetVal).toUpperCase() + "x5"; - targetVal = this.actor.data.data.skills[targetVal].proficiency; + targetVal = this.actor.system.skills[targetVal].proficiency; } } else if(dataset.target === "statistic.x5"){ - let stat = this.actor.data.data.statistics[key]; + let stat = this.actor.system.statistics[key]; targetVal = stat.x5; label = game.i18n.localize("DG.Attributes." + key).toUpperCase(); } else if(rollType === "sanity"){ - targetVal = this.actor.data.data.sanity.value; + targetVal = this.actor.system.sanity.value; label = game.i18n.localize("DG.Attributes.SAN").toUpperCase(); } else if(rollType === "damage"){ @@ -559,7 +561,7 @@ export class DeltaGreenActorSheet extends ActorSheet { let skillType = dataset.skill ? dataset.skill : ''; if(this.actor.type === 'agent' && (skillType === 'unarmed_combat' || skillType === 'melee_weapons')){ - diceFormula += this.actor.data.data.statistics.str.meleeDamageBonusFormula; + diceFormula += this.actor.system.statistics.str.meleeDamageBonusFormula; } if(requestedModifyRoll){ @@ -591,13 +593,13 @@ export class DeltaGreenActorSheet extends ActorSheet { let currentBreakingPoint = 0; - currentBreakingPoint = this.actor.data.data.sanity.value - this.actor.data.data.statistics.pow.value; + currentBreakingPoint = this.actor.system.sanity.value - this.actor.system.statistics.pow.value; if(currentBreakingPoint < 0){ currentBreakingPoint = 0; } - let updatedData = duplicate(this.actor.data.data); + let updatedData = duplicate(this.actor.system); updatedData.sanity.currentBreakingPoint = currentBreakingPoint; @@ -612,7 +614,7 @@ export class DeltaGreenActorSheet extends ActorSheet { try{ //const item = this.actor.getOwnedItem(dataset.id); const item = this.actor.items.get(dataset.id); - var isEquipped = item.data.data.equipped; + var isEquipped = item.system.equipped; isEquipped = !isEquipped; item.update({data:{equipped: isEquipped}}); } @@ -636,14 +638,14 @@ export class DeltaGreenActorSheet extends ActorSheet { if ( li.dataset.itemId ) { const item = this.actor.items.get(li.dataset.itemId); dragData.type = "Item"; - dragData.data = item.data; + dragData = item; } // Active Effect if ( li.dataset.effectId ) { const effect = this.actor.effects.get(li.dataset.effectId); dragData.type = "ActiveEffect"; - dragData.data = effect.data; + dragData = effect; } // Set data transfer diff --git a/module/actor/actor.js b/module/actor/actor.js index 4f240ff..17f2a5b 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -10,8 +10,8 @@ export class DeltaGreenActor extends Actor { prepareData() { super.prepareData(); - const actorData = this.data; - const data = actorData.data; + const actorData = this; + const system = actorData.system; const flags = actorData.flags; //console.log('actor.js prepareData'); @@ -35,48 +35,47 @@ export class DeltaGreenActor extends Actor { * @param {*} agent */ _prepareNpcData(actor){ - let actorData = actor.data; - const data = actorData.data; + const { system } = actor; // Loop through ability scores, and add their modifiers to our sheet output. - for (let [key, statistic] of Object.entries(data.statistics)) { + for (let [key, statistic] of Object.entries(system.statistics)) { // the x5 is just whatever the raw statistic is x 5 to turn it into a d100 percentile statistic.x5 = statistic.value * 5; } // initialize sanity, don't set these afterwards, as they need to be manually edited - if(actorData.data.sanity.value >= 100){ - actorData.data.sanity.value = actorData.data.statistics.pow.x5 - actorData.data.sanity.currentBreakingPoint = actorData.data.sanity.value - actorData.data.statistics.pow.value; + if(system.sanity.value >= 100){ + system.sanity.value = system.statistics.pow.x5 + system.sanity.currentBreakingPoint = system.sanity.value - system.statistics.pow.value; }; - actorData.data.sanity.max = 99 - actorData.data.skills.unnatural.proficiency; + system.sanity.max = 99 - system.skills.unnatural.proficiency; - actorData.data.skills.ritual = { + system.skills.ritual = { label: "Ritual", - proficiency: 99 - actorData.data.sanity.value, + proficiency: 99 - system.sanity.value, cannotBeImprovedByFailure: true, failure: false }; - if(actorData.data.skills.ritual.proficiency > 99){ - actorData.data.skills.ritual.proficiency = 99 + if(system.skills.ritual.proficiency > 99){ + system.skills.ritual.proficiency = 99 } - else if(actorData.data.skills.ritual.proficiency < 1){ - actorData.data.skills.ritual.proficiency = 1 + else if(system.skills.ritual.proficiency < 1){ + system.skills.ritual.proficiency = 1 } // calculate total armor rating let protection = 0; for (let i of actor.items) { if (i.type === 'armor') { - if(i.data.data.equipped === true){ - protection += i.data.data.protection; + if(i.system.equipped === true){ + protection += i.system.protection; } } } - actorData.data.health.protection = protection; + system.health.protection = protection; console.log(actor); } @@ -86,11 +85,10 @@ export class DeltaGreenActor extends Actor { * @param {*} agent */ _prepareUnnaturalData(actor){ - let actorData = actor.data; - const data = actorData.data; + const { system } = actor; // Loop through ability scores, and add their modifiers to our sheet output. - for (let [key, statistic] of Object.entries(data.statistics)) { + for (let [key, statistic] of Object.entries(system.statistics)) { // the x5 is just whatever the raw statistic is x 5 to turn it into a d100 percentile statistic.x5 = statistic.value * 5; } @@ -99,13 +97,13 @@ export class DeltaGreenActor extends Actor { let protection = 0; for (let i of actor.items) { if (i.type === 'armor') { - if(i.data.data.equipped === true){ - protection += i.data.data.protection; + if(i.system.equipped === true){ + protection += i.system.protection; } } } - actorData.data.health.protection = protection; + system.health.protection = protection; console.log(actor); } @@ -115,37 +113,36 @@ export class DeltaGreenActor extends Actor { */ _prepareAgentData(agent) { - let actorData = agent.data; - const data = actorData.data; + const { system } = agent; // Make modifications to data here. For example: // Loop through ability scores, and add their modifiers to our sheet output. - for (let [key, statistic] of Object.entries(data.statistics)) { + for (let [key, statistic] of Object.entries(system.statistics)) { // the x5 is just whatever the raw statistic is x 5 to turn it into a d100 percentile statistic.x5 = statistic.value * 5; } // The ritual skill is from the Handler's Guide, it is for activating a ritual and is always equal to 99 - current sanity. // The rules can be found on page 166, under 'Ritual Activation'. - actorData.data.skills.ritual = { + system.skills.ritual = { label: "Ritual", - proficiency: 99 - actorData.data.sanity.value, + proficiency: 99 - system.sanity.value, cannotBeImprovedByFailure: true, failure: false }; - if(actorData.data.skills.ritual.proficiency > 99){ - actorData.data.skills.ritual.proficiency = 99 + if(system.skills.ritual.proficiency > 99){ + system.skills.ritual.proficiency = 99 } - else if(actorData.data.skills.ritual.proficiency < 1){ - actorData.data.skills.ritual.proficiency = 1 + else if(system.skills.ritual.proficiency < 1){ + system.skills.ritual.proficiency = 1 } // The unnatural skill is sort of special // It cannot be improved via failure, so add in a special property to reflect this // Mostly to make it easy to deactivate the failure checkbox in the GUI - for (let [key, skill] of Object.entries(data.skills)){ + for (let [key, skill] of Object.entries(system.skills)){ if(key === 'unnatural'){ skill.cannotBeImprovedByFailure = true; } @@ -168,52 +165,52 @@ export class DeltaGreenActor extends Actor { } } - actorData.data.wp.max = actorData.data.statistics.pow.value; + system.wp.max = system.statistics.pow.value; - actorData.data.health.max = Math.ceil((actorData.data.statistics.con.value + actorData.data.statistics.str.value) / 2); + system.health.max = Math.ceil((system.statistics.con.value + system.statistics.str.value) / 2); // initialize sanity, don't set these afterwards, as they need to be manually edited - if(actorData.data.sanity.value >= 100){ - actorData.data.sanity.value = actorData.data.statistics.pow.x5 - actorData.data.sanity.currentBreakingPoint = actorData.data.sanity.value - actorData.data.statistics.pow.value; + if(system.sanity.value >= 100){ + system.sanity.value = system.statistics.pow.x5 + system.sanity.currentBreakingPoint = system.sanity.value - system.statistics.pow.value; }; - actorData.data.sanity.max = 99 - actorData.data.skills.unnatural.proficiency; + system.sanity.max = 99 - system.skills.unnatural.proficiency; // Sanity Loss Adaptations Logic - let adaptations = actorData.data.sanity.adaptations; + let adaptations = system.sanity.adaptations; if (adaptations.violence.incident1 && adaptations.violence.incident2 && adaptations.violence.incident3){ - actorData.data.sanity.adaptations.violence.isAdapted = true; + system.sanity.adaptations.violence.isAdapted = true; } else{ - actorData.data.sanity.adaptations.violence.isAdapted = false; + system.sanity.adaptations.violence.isAdapted = false; } if (adaptations.helplessness.incident1 && adaptations.helplessness.incident2 && adaptations.helplessness.incident3){ - actorData.data.sanity.adaptations.helplessness.isAdapted = true; + system.sanity.adaptations.helplessness.isAdapted = true; } else{ - actorData.data.sanity.adaptations.helplessness.isAdapted = false; + system.sanity.adaptations.helplessness.isAdapted = false; } // calculate total armor rating let protection = 0; for (let i of agent.items) { if (i.type === 'armor') { - if(i.data.data.equipped === true){ - protection += i.data.data.protection; + if(i.system.equipped === true){ + protection += i.system.protection; } } } - actorData.data.health.protection = protection; + system.health.protection = protection; // Damage Bonus/Malus From Strength in Hand-to-hand Combat (melee/unarmed) let bonus = 0; let sbonus = ""; - let strength = actorData.data.statistics.str; + let strength = system.statistics.str; if(strength.value < 5){ sbonus = "-2"; @@ -232,8 +229,8 @@ export class DeltaGreenActor extends Actor { bonus = 2; } - actorData.data.statistics.str.meleeDamageBonus = bonus; - actorData.data.statistics.str.meleeDamageBonusFormula = sbonus; + system.statistics.str.meleeDamageBonus = bonus; + system.statistics.str.meleeDamageBonusFormula = sbonus; console.log(agent); } @@ -254,7 +251,7 @@ export class DeltaGreenActor extends Actor { let alreadyAdded = false; - for(let item of this.data.items){ + for(let item of this.items){ let flag = await item.getFlag('deltagreen', 'SystemName'); @@ -275,7 +272,7 @@ export class DeltaGreenActor extends Actor { let _temp = await handToHandPack.getDocument(idx._id); if(_temp.name === 'Unarmed Attack'){ - toAdd.push(_temp.data); + toAdd.push(_temp); } } diff --git a/module/deltagreen.js b/module/deltagreen.js index cc67251..14a17d5 100644 --- a/module/deltagreen.js +++ b/module/deltagreen.js @@ -103,7 +103,7 @@ Hooks.once('init', async function() { } }); - Handlebars.registerHelper('getActorSkillProp', function(actorData, skillName, prop) { + Handlebars.registerHelper('getActorSkillProp', function(actorData, skillName, prop) { // Is this used anywhere? try{ if(skillName != "" && prop != ""){ let skills = actorData.data.skills; @@ -295,7 +295,7 @@ Hooks.on('createActor', async function(actor, options, userId){ // can put logic specific to a particular user session below if (userId != game.user.id) { return; }; - if(actor != null && actor.data != null && actor.data.type === 'agent'){ + if(actor != null && actor.type === 'agent'){ // update the default type skill of Art - Painting's labels to try to be localized // since I really backed myself into a corner on this with my implementation of it... console.log('createActor Hook'); @@ -303,7 +303,7 @@ Hooks.on('createActor', async function(actor, options, userId){ let artLabel = game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"; let paintingLabel = game.i18n.translations.DG?.TypeSkills?.Subskills?.Painting ?? "Painting"; - let updatedData = duplicate(actor.data.data); + let updatedData = duplicate(actor.system); updatedData.typedSkills.tskill_01.group = artLabel; updatedData.typedSkills.tskill_01.label = paintingLabel; @@ -312,7 +312,7 @@ Hooks.on('createActor', async function(actor, options, userId){ // throw on an unarmed strike item for convenience actor.AddUnarmedAttackItemIfMissing(); } - else if(actor.data.type === 'unnatural'){ + else if(actor.type === 'unnatural'){ } @@ -336,7 +336,7 @@ Hooks.on('createActor', async function(actor, options, userId){ async function createDeltaGreenMacro(data, slot) { if (data.type !== "Item") return; if (!("data" in data)) return ui.notifications.warn("You can only create macro buttons for owned Items"); - const item = data.data; + const item = data.system; // Create the macro command let command = '// Uncomment line below to also roll skill check if desired.' @@ -390,9 +390,9 @@ function rollItemSkillCheckMacro(itemName) { const item = actor ? actor.items.find(i => i.name === itemName) : null; if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`); - let skillName = item.data.data.skill.toString(); + let skillName = item.system.skill.toString(); - let skill = actor.data.data.skills[skillName]; + let skill = actor.system.skills[skillName]; let translatedSkillLabel = ""; try{ @@ -413,7 +413,7 @@ function rollSkillMacro(skillName) { if(!actor) return ui.notifications.warn('Must have an Actor selected first.'); - let skill = actor.data.data.skills[skillName]; + let skill = actor.system.skills[skillName]; if(!skill) return ui.notifications.warn('Bad skill name passed to macro.'); diff --git a/module/item/item-sheet.js b/module/item/item-sheet.js index 241144f..29f8ad1 100644 --- a/module/item/item-sheet.js +++ b/module/item/item-sheet.js @@ -19,7 +19,7 @@ export class DeltaGreenItemSheet extends ItemSheet { const path = "systems/deltagreen/templates/item"; // unique item sheet by type, like `weapon-sheet.html`. - return `${path}/item-${this.item.data.type}-sheet.html`; + return `${path}/item-${this.item.type}-sheet.html`; } /* -------------------------------------------- */ diff --git a/module/item/item.js b/module/item/item.js index f35a700..3117210 100644 --- a/module/item/item.js +++ b/module/item/item.js @@ -12,9 +12,9 @@ export class DeltaGreenItem extends Item { super.prepareData(); // Get the Item's data - const itemData = this.data; - const actorData = this.actor ? this.actor.data : {}; - const data = itemData.data; + const itemData = this; + const actorData = this.actor || {}; + const system = itemData.system; } /** @@ -25,21 +25,21 @@ export class DeltaGreenItem extends Item { async roll() { // Basic template rendering data const token = this.actor.token; - const item = this.data; - const actorData = this.actor ? this.actor.data.data : {}; - const itemData = item.data; + const itemData = this; + const actorSystemData = this.actor.system || {}; + const { system } = itemData; - if(item.data.isLethal){ - sendLethalityTestToChat(this.actor, item.name, item.data.lethality, game.settings.get("core", "rollMode")) + if(system.isLethal){ + sendLethalityTestToChat(this.actor, item.name, system.lethality, game.settings.get("core", "rollMode")) } else{ // regular damage roll - let diceFormula = item.data.damage; - let skillType = item.data.skill; + let diceFormula = system.damage; + let skillType = system.skill; if(skillType === 'unarmed_combat' || skillType === 'melee_weapons'){ - diceFormula += this.actor.data.data.statistics.str.meleeDamageBonusFormula; + diceFormula += actorSystemData.statistics.str.meleeDamageBonusFormula; } sendDamageRollToChat(this.actor, item.name, diceFormula); diff --git a/system.json b/system.json index 6d829e3..0f278c4 100644 --- a/system.json +++ b/system.json @@ -1,5 +1,6 @@ { "name": "deltagreen", + "id": "deltagreen", "title": "Delta Green (Unofficial)", "description": "Fan-made Foundry VTT system for Delta Green: The Role Playing Game for Foundry VTT. Based on the rules in the Agent's Handbook (https://www.drivethrurpg.com/product/181674/Delta-Green-Agents-Handbook) [*NOT* Call of Cthulu]. Made with the permission of but neither affiliated with nor endorsed by Arc Dream Publishing or the Delta Green Partnership.", "author": "TheLastScrub (https://github.com/TheLastScrub)", @@ -8,6 +9,11 @@ "license": "LICENSE.txt", "flags": {}, "version": "1.0.6", + "compatibility": { + "minimum": 10, + "verified": 10, + "maximum": 10 + }, "minimumCoreVersion": "0.8.6", "compatibleCoreVersion": "9", "scripts": [], From c7de25722a6fef2986d24c118656bee8011bcdd0 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sat, 3 Sep 2022 12:28:08 -0400 Subject: [PATCH 02/12] updated .html files --- templates/actor/actor-sheet.html | 120 +++++++++++----------- templates/actor/cv-partial.html | 20 ++-- templates/actor/limited-sheet.html | 2 +- templates/actor/npc-sheet.html | 76 +++++++------- templates/actor/unnatural-sheet.html | 74 ++++++------- templates/item/item-armor-sheet.html | 18 ++-- templates/item/item-bond-sheet.html | 6 +- templates/item/item-gear-sheet.html | 16 +-- templates/item/item-motivation-sheet.html | 12 +-- templates/item/item-weapon-sheet.html | 62 +++++------ 10 files changed, 203 insertions(+), 203 deletions(-) diff --git a/templates/actor/actor-sheet.html b/templates/actor/actor-sheet.html index d4694ab..08dd841 100644 --- a/templates/actor/actor-sheet.html +++ b/templates/actor/actor-sheet.html @@ -13,7 +13,7 @@

-

+

@@ -22,51 +22,51 @@ {{!-- HP --}}
- +
- + / - +
-
{{numberFormat actor.data.data.health.max decimals=0 sign=false}}
+
{{numberFormat actor.system.health.max decimals=0 sign=false}}
{{!-- WP --}}
- +
- + / - +
-
{{numberFormat actor.data.data.wp.max decimals=0 sign=false}}
+
{{numberFormat actor.system.wp.max decimals=0 sign=false}}
{{!-- Sanity --}}
-
{{#if (keepSanityPrivate)}} - + /
-
{{numberFormat actor.data.data.sanity.max decimals=0 sign=false}}
+
{{numberFormat actor.system.sanity.max decimals=0 sign=false}}
{{/if}} {{#unless (keepSanityPrivate)}} - + /
-
{{numberFormat actor.data.data.sanity.max decimals=0 sign=false}}
+
{{numberFormat actor.system.sanity.max decimals=0 sign=false}}
{{/unless}} @@ -94,10 +94,10 @@
- {{#each actor.data.data.skills as |skill key|}} + {{#each actor.system.skills as |skill key|}}
-
- {{#each actor.data.data.typedSkills as |skill key|}} + {{#each actor.system.typedSkills as |skill key|}}
- - + +
@@ -161,16 +161,16 @@ {{!-- Physical Statistics like STR, CON, etc. --}}
- {{#each actor.data.data.statistics as |statistic key|}} + {{#each actor.system.statistics as |statistic key|}}
- - + + ({{numberFormat statistic.x5 decimals=0 sign=false}}%)
- +
@@ -181,13 +181,13 @@ - +
- + - +
@@ -197,7 +197,7 @@
- + {{localize 'DG.Mental.Reset'}}
@@ -206,27 +206,27 @@
- - - + + + - - - + + + @@ -251,15 +251,15 @@
  • {{item.name}}

    - {{#if item.data.data.crossedOut}} -

    {{item.data.data.disorder}}

    + {{#if item.system.crossedOut}} +

    {{item.system.disorder}}

    {{/if}}
    @@ -305,32 +305,32 @@ class="item-name rollable" data-roll="d100" data-rolltype="weaponskill" - data-target="{{item.data.data.skill}}" - data-label="{{localizeWeaponSkill item.data.data.skill}}" - title="{{localize 'DG.Tooltip.SkillLabel'}} ({{localizeWeaponSkill item.data.data.skill}})" + data-target="{{item.system.skill}}" + data-label="{{localizeWeaponSkill item.system.skill}}" + title="{{localize 'DG.Tooltip.SkillLabel'}} ({{localizeWeaponSkill item.system.skill}})" > {{item.name}} - {{#unless item.data.data.isLethal}} + {{#unless item.system.isLethal}} - {{toUpperCase item.data.data.damage}}{{#if_eq item.data.data.skill 'unarmed_combat'}}{{actor.data.data.statistics.str.meleeDamageBonusFormula}}{{/if_eq}}{{#if_eq item.data.data.skill 'melee_weapons'}}{{actor.data.data.statistics.str.meleeDamageBonusFormula}}{{/if_eq}} + {{toUpperCase item.system.damage}}{{#if_eq item.system.skill 'unarmed_combat'}}{{actor.system.statistics.str.meleeDamageBonusFormula}}{{/if_eq}}{{#if_eq item.system.skill 'melee_weapons'}}{{actor.system.statistics.str.meleeDamageBonusFormula}}{{/if_eq}} {{/unless}} - {{#if item.data.data.isLethal}} - {{formatLethality item.data.data.lethality}} + >{{formatLethality item.system.lethality}} {{/if}} - {{item.data.data.armorPiercing}} + {{item.system.armorPiercing}}
    @@ -366,10 +366,10 @@
  • {{item.name}}

    - {{item.data.data.protection}} + {{item.system.protection}} - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} @@ -415,7 +415,7 @@ - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} @@ -463,8 +463,8 @@
  • {{item.name}}

    - {{item.data.data.relationship}} - {{item.data.data.score}} + {{item.system.relationship}} + {{item.system.score}}
    diff --git a/templates/actor/cv-partial.html b/templates/actor/cv-partial.html index aeeec1c..148b02a 100644 --- a/templates/actor/cv-partial.html +++ b/templates/actor/cv-partial.html @@ -1,24 +1,24 @@
    {{localize 'DG.CV.Sex'}} - + {{localize 'DG.CV.AgeAndDoB'}} - +
    {{localize 'DG.CV.Employer'}} - + {{localize 'DG.CV.Nationality'}} - +
    {{localize 'DG.CV.Education'}} - +
    {{#if (playerHasGamemasterPrivileges)}} @@ -27,20 +27,20 @@ {{localize 'DG.ImpossibleLanscapes.IHaveSeenThe'}} {{localize 'DG.ImpossibleLanscapes.YellowSign'}} - + {{localize 'DG.ImpossibleLanscapes.CorruptionFirstHalf'}} {{localize 'DG.ImpossibleLanscapes.CorruptionSecondHalf'}} - +
    {{localize 'DG.ImpossibleLanscapes.Gift'}} - + {{localize 'DG.ImpossibleLanscapes.Insight'}} - +
    {{/if}} @@ -50,5 +50,5 @@
  • - {{editor content=actor.data.data.physicalDescription target="data.physicalDescription" button=true owner=owner editable=editable}} + {{editor actor.system.physicalDescription target="system.physicalDescription" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/templates/actor/limited-sheet.html b/templates/actor/limited-sheet.html index 65af6a2..8126f1b 100644 --- a/templates/actor/limited-sheet.html +++ b/templates/actor/limited-sheet.html @@ -13,7 +13,7 @@

    -

    +

    diff --git a/templates/actor/npc-sheet.html b/templates/actor/npc-sheet.html index 02805df..aa0da74 100644 --- a/templates/actor/npc-sheet.html +++ b/templates/actor/npc-sheet.html @@ -13,7 +13,7 @@

    -

    +

    @@ -22,33 +22,33 @@ {{!-- HP --}}
    - +
    - + / - +
    {{!-- WP --}}
    - +
    - + / - +
    {{!-- Sanity --}}
    -
    - + {{localize 'DG.NPCSheet.BreakPointAbbreviation'}}: - +
    @@ -58,15 +58,15 @@ {{!-- Physical Statistics like STR, CON, etc. --}}
    - {{#each actor.data.data.statistics as |statistic key|}} + {{#each actor.system.statistics as |statistic key|}}
    - - + + ({{numberFormat statistic.x5 decimals=0 sign=false}}%)
    - {{!--
    --}} + {{!--
    --}}
    {{/each}} @@ -90,22 +90,22 @@
    {{!-- Checkbox to hide/show skills that are at zero --}}
    - {{localize 'DG.UnnaturalSheet.HideUntrainedSkillsLabel'}}: - + {{localize 'DG.UnnaturalSheet.HideUntrainedSkillsLabel'}}: +
    - {{#each actor.data.data.skills as |skill key|}} + {{#each actor.system.skills as |skill key|}} - {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.data.data.showUntrainedSkills skill.proficiency)}} + {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.system.showUntrainedSkills skill.proficiency)}}
    - - +
    {{/if}} @@ -118,8 +118,8 @@ {{localize 'DG.Skills.AddTypedOrCustomSkill'}}
    - {{#each actor.data.data.typedSkills as |skill key|}} - {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.data.data.showUntrainedSkills skill.proficiency)}} + {{#each actor.system.typedSkills as |skill key|}} + {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.system.showUntrainedSkills skill.proficiency)}}
    - +
    @@ -143,7 +143,7 @@
    - {{editor content=actor.data.data.notes target="data.notes" button=true owner=owner editable=editable}} + {{editor actor.system.notes target="system.notes" button=true owner=owner editable=editable}}
    @@ -180,32 +180,32 @@ class="item-name rollable" data-roll="d100" data-rolltype="weaponskill" - data-target="{{item.data.data.skill}}" - data-label="{{localizeWeaponSkill item.data.data.skill}}" - title="{{localize 'DG.Tooltip.SkillLabel'}} ({{localizeWeaponSkill item.data.data.skill}})" + data-target="{{item.system.skill}}" + data-label="{{localizeWeaponSkill item.system.skill}}" + title="{{localize 'DG.Tooltip.SkillLabel'}} ({{localizeWeaponSkill item.system.skill}})" > {{item.name}} - {{#unless item.data.data.isLethal}} + {{#unless item.system.isLethal}} - {{toUpperCase item.data.data.damage}} + {{toUpperCase item.system.damage}} {{/unless}} - {{#if item.data.data.isLethal}} - {{formatLethality item.data.data.lethality}} + >{{formatLethality item.system.lethality}} {{/if}} - {{item.data.data.armorPiercing}} + {{item.system.armorPiercing}}
    @@ -241,10 +241,10 @@
  • {{item.name}}

    - {{item.data.data.protection}} + {{item.system.protection}} - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} @@ -291,7 +291,7 @@ - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} diff --git a/templates/actor/unnatural-sheet.html b/templates/actor/unnatural-sheet.html index 54b62d5..ac20b0d 100644 --- a/templates/actor/unnatural-sheet.html +++ b/templates/actor/unnatural-sheet.html @@ -13,7 +13,7 @@

  • -

    +

    @@ -22,31 +22,31 @@ {{!-- HP --}}
    - +
    - + / - +
    {{!-- WP --}}
    - +
    - + / - +
    {{!-- Sanity Damage --}}
    - +
    - + / - +
    @@ -56,12 +56,12 @@ {{!-- Physical Statistics like STR, CON, etc. --}}
    - {{#each actor.data.data.statistics as |statistic key|}} + {{#each actor.system.statistics as |statistic key|}}
    - - + + ({{numberFormat statistic.x5 decimals=0 sign=false}}%)
    @@ -87,22 +87,22 @@
    {{!-- Checkbox to hide/show skills that are at zero --}}
    - {{localize 'DG.UnnaturalSheet.HideUntrainedSkillsLabel'}}: - + {{localize 'DG.UnnaturalSheet.HideUntrainedSkillsLabel'}}: +
    - {{#each actor.data.data.skills as |skill key|}} + {{#each actor.system.skills as |skill key|}} - {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.data.data.showUntrainedSkills skill.proficiency)}} + {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.system.showUntrainedSkills skill.proficiency)}}
    - - +
    {{/if}} @@ -115,8 +115,8 @@ {{localize 'DG.Skills.AddTypedOrCustomSkill'}}
    - {{#each actor.data.data.typedSkills as |skill key|}} - {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.data.data.showUntrainedSkills skill.proficiency)}} + {{#each actor.system.typedSkills as |skill key|}} + {{#if (hideSkillBasedOnProficiencyAndUserChoice ../actor.system.showUntrainedSkills skill.proficiency)}}
    - +
    @@ -140,7 +140,7 @@
    - {{editor content=actor.data.data.notes target="data.notes" button=true owner=owner editable=editable}} + {{editor actor.system.notes target="system.notes" button=true owner=owner editable=editable}}
    @@ -177,32 +177,32 @@ class="item-name rollable" data-roll="d100" data-rolltype="weaponskill" - data-target="{{item.data.data.skill}}" - data-label="{{localizeWeaponSkill item.data.data.skill}}" - title="{{localize 'DG.Tooltip.SkillLabel'}} ({{localizeWeaponSkill item.data.data.skill}})" + data-target="{{item.system.skill}}" + data-label="{{localizeWeaponSkill item.system.skill}}" + title="{{localize 'DG.Tooltip.SkillLabel'}} ({{localizeWeaponSkill item.system.skill}})" > {{item.name}} - {{#unless item.data.data.isLethal}} + {{#unless item.system.isLethal}} - {{toUpperCase item.data.data.damage}} + {{toUpperCase item.system.damage}} {{/unless}} - {{#if item.data.data.isLethal}} - {{formatLethality item.data.data.lethality}} + >{{formatLethality item.system.lethality}} {{/if}} - {{item.data.data.armorPiercing}} + {{item.system.armorPiercing}}
    @@ -238,10 +238,10 @@
  • {{item.name}}

    - {{item.data.data.protection}} + {{item.system.protection}} - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} @@ -288,7 +288,7 @@ - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} diff --git a/templates/item/item-armor-sheet.html b/templates/item/item-armor-sheet.html index c7a3d74..934a75e 100644 --- a/templates/item/item-armor-sheet.html +++ b/templates/item/item-armor-sheet.html @@ -10,23 +10,23 @@ {{localize 'DG.ItemWindow.Armor.Expense'}}: - + + + + + {{localize 'DG.ItemWindow.Armor.Equipped'}}: - +
  • {{localize 'DG.ItemWindow.Armor.ArmorRating'}}: - +
    @@ -41,7 +41,7 @@ {{!-- Description Tab --}}
    - {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}} + {{editor system.description target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-bond-sheet.html b/templates/item/item-bond-sheet.html index a995800..54ef5f0 100644 --- a/templates/item/item-bond-sheet.html +++ b/templates/item/item-bond-sheet.html @@ -9,12 +9,12 @@ {{localize 'DG.Bonds.Score'}}: - {{localize 'DG.Bonds.Relationship'}}: - +
    @@ -30,7 +30,7 @@ {{!-- Description Tab --}}
    - {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}} + {{editor system.description target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-gear-sheet.html b/templates/item/item-gear-sheet.html index 22660f7..79de9c4 100644 --- a/templates/item/item-gear-sheet.html +++ b/templates/item/item-gear-sheet.html @@ -11,16 +11,16 @@ {{localize 'DG.ItemWindow.Gear.Expense'}}: - + + + + + {{localize 'DG.ItemWindow.Gear.Equipped'}}: - +
    @@ -38,7 +38,7 @@ {{!-- Description Tab --}}
    - {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}} + {{editor system.description target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-motivation-sheet.html b/templates/item/item-motivation-sheet.html index 50a7956..4a07283 100644 --- a/templates/item/item-motivation-sheet.html +++ b/templates/item/item-motivation-sheet.html @@ -13,7 +13,7 @@
    {{localize 'DG.ItemWindow.Motivations.IsDisorder'}}: - @@ -25,7 +25,7 @@ title="{{localize 'DG.ItemWindow.Motivations.MotivationNameTooltip'}}" {{!-- If a motivation has been crossed off after a breaking point, do a strikeout on it and disable it. --}} - {{#if data.data.crossedOut}} + {{#if system.crossedOut}} style="text-decoration: line-through;" disabled {{/if}} @@ -33,17 +33,17 @@ {{!-- Only Show the Disorders Section if Motivation Lost Checked --}} - {{#if data.data.crossedOut}} + {{#if system.crossedOut}} {{localize 'DG.ItemWindow.Motivations.Disorder'}}: - {{localize 'DG.ItemWindow.Motivations.DisorderHasBeenCured'}}: - @@ -54,7 +54,7 @@
    - {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}} + {{editor system.description target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-weapon-sheet.html b/templates/item/item-weapon-sheet.html index 2cb597e..e85a2ba 100644 --- a/templates/item/item-weapon-sheet.html +++ b/templates/item/item-weapon-sheet.html @@ -10,16 +10,16 @@ {{localize 'DG.ItemWindow.Weapons.Expense'}}: - + + + + + {{localize 'DG.ItemWindow.Gear.Equipped'}}: - +
    @@ -29,57 +29,57 @@
    {{localize 'DG.ItemWindow.Weapons.Skill'}}: - + + + + + + + + + + + + + {{localize 'DG.ItemWindow.Weapons.IsLethality'}}: - {{localize 'DG.ItemWindow.Weapons.KillRadius'}}: - +
    {{localize 'DG.ItemWindow.Weapons.Range'}}: - + {{!-- If a weapon is 'Lethal', need to show the d100% Lethality input, otherwise only show the regular Damage formula (e.g. 1D6, 1D4+2, etc...) --}} - {{#unless data.data.isLethal}} + {{#unless system.isLethal}} {{localize 'DG.ItemWindow.Weapons.Damage'}}: - + {{/unless}} - {{#if data.data.isLethal}} + {{#if system.isLethal}} {{localize 'DG.ItemWindow.Weapons.Lethality'}} %: - {{/if}} {{localize 'DG.ItemWindow.Weapons.ArmorPiercing'}}: - +
    @@ -87,7 +87,7 @@
    {{localize 'DG.ItemWindow.Weapons.Ammo'}}: - +
    @@ -103,7 +103,7 @@ {{!-- Description Tab --}}
    - {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}} + {{editor system.description target="system.description" button=true owner=owner editable=editable}}
    From d0fac732b6e072cbfd48a80a32e5e820e3971595 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sat, 3 Sep 2022 12:31:06 -0400 Subject: [PATCH 03/12] forgot roll.js when i updated .js files --- module/deltagreen.js | 4 +++- module/roll/roll.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/module/deltagreen.js b/module/deltagreen.js index 14a17d5..4ba5960 100644 --- a/module/deltagreen.js +++ b/module/deltagreen.js @@ -103,7 +103,9 @@ Hooks.once('init', async function() { } }); - Handlebars.registerHelper('getActorSkillProp', function(actorData, skillName, prop) { // Is this used anywhere? + + // Is this used anywhere? + Handlebars.registerHelper('getActorSkillProp', function(actorData, skillName, prop) { try{ if(skillName != "" && prop != ""){ let skills = actorData.data.skills; diff --git a/module/roll/roll.js b/module/roll/roll.js index b37c37b..01e8009 100644 --- a/module/roll/roll.js +++ b/module/roll/roll.js @@ -2,7 +2,7 @@ import {localizeWithFallback} from "../other/utility-functions.js" export async function sendPercentileTestToChat(actor, skill, target, rollMode){ //let roll = new Roll('1D100', actor.data.data).evaluate(false); - let roll = new Roll('1D100', actor.data.data) + let roll = new Roll('1D100', actor.system) await roll.evaluate({async: true}); @@ -140,7 +140,7 @@ export function skillCheckResultIsCritical(rollResult){ export async function sendLethalityTestToChat(actor, weaponName, target, rollMode){ //let roll = new Roll('1D100', actor.data.data).evaluate(false); - let roll = new Roll('1D100', actor.data.data); + let roll = new Roll('1D100', actor.system); await roll.evaluate({async: true}); @@ -244,7 +244,7 @@ export async function sendDamageRollToChat(actor, label, diceFormula, rollMode){ //diceFormula += actor.data.data.statistics.str.meleeDamageBonusFormula; - let roll = new Roll(diceFormula, actor.data.data); + let roll = new Roll(diceFormula, actor.system); await roll.evaluate({async: true}); From 953b643729e433841c488d019ea1e5b0ef72bc5c Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sat, 3 Sep 2022 14:37:50 -0400 Subject: [PATCH 04/12] fixed incorrect references in item sheet .htmls causing sheets to not work; followed advised procedures for editor handlesbars (see https://foundryvtt.com/article/v10-text-editor/); fixed incorrect reference in npc/unnatural sheet .htmls causing 'hide untrained' skills to work incorrectly --- module/actor/actor-sheet.js | 13 ++++- module/item/item-sheet.js | 3 +- templates/actor/cv-partial.html | 2 +- templates/actor/limited-sheet.html | 2 +- templates/actor/npc-sheet.html | 5 +- templates/actor/unnatural-sheet.html | 5 +- templates/item/item-armor-sheet.html | 16 +++---- templates/item/item-bond-sheet.html | 6 +-- templates/item/item-gear-sheet.html | 14 +++--- templates/item/item-motivation-sheet.html | 12 ++--- templates/item/item-weapon-sheet.html | 58 +++++++++++------------ 11 files changed, 73 insertions(+), 63 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 08afd9e..201570b 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -47,13 +47,24 @@ export class DeltaGreenActorSheet extends ActorSheet { } /** @override */ - getData() { + async getData() { const data = super.getData(); // Prepare items. if (this.actor.type == 'agent') { this._prepareCharacterItems(data); } + + switch (this.actor.type) { + case "agent": + data.enrichedDescription = await TextEditor.enrichHTML(this.object.system.physicalDescription, {async: true}); + break; + case "npc": + case "unnatural": + data.enrichedDescription = await TextEditor.enrichHTML(this.object.system.notes, {async: true}); + break; + default: + } return data; } diff --git a/module/item/item-sheet.js b/module/item/item-sheet.js index 29f8ad1..277eb31 100644 --- a/module/item/item-sheet.js +++ b/module/item/item-sheet.js @@ -25,8 +25,9 @@ export class DeltaGreenItemSheet extends ItemSheet { /* -------------------------------------------- */ /** @override */ - getData() { + async getData() { const data = super.getData(); + data.enrichedDescription = await TextEditor.enrichHTML(this.object.system.description, {async: true}); return data; } diff --git a/templates/actor/cv-partial.html b/templates/actor/cv-partial.html index 148b02a..336975f 100644 --- a/templates/actor/cv-partial.html +++ b/templates/actor/cv-partial.html @@ -50,5 +50,5 @@
    - {{editor actor.system.physicalDescription target="system.physicalDescription" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.physicalDescription" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/templates/actor/limited-sheet.html b/templates/actor/limited-sheet.html index 8126f1b..9400c44 100644 --- a/templates/actor/limited-sheet.html +++ b/templates/actor/limited-sheet.html @@ -13,7 +13,7 @@

    -

    +

    diff --git a/templates/actor/npc-sheet.html b/templates/actor/npc-sheet.html index aa0da74..c0173a2 100644 --- a/templates/actor/npc-sheet.html +++ b/templates/actor/npc-sheet.html @@ -1,5 +1,4 @@
    - {{!-- Sheet Header --}}
    @@ -91,7 +90,7 @@ {{!-- Checkbox to hide/show skills that are at zero --}}
    {{localize 'DG.UnnaturalSheet.HideUntrainedSkillsLabel'}}: - +
    @@ -143,7 +142,7 @@
    - {{editor actor.system.notes target="system.notes" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.notes" button=true owner=owner editable=editable}}
    diff --git a/templates/actor/unnatural-sheet.html b/templates/actor/unnatural-sheet.html index ac20b0d..f5f0c92 100644 --- a/templates/actor/unnatural-sheet.html +++ b/templates/actor/unnatural-sheet.html @@ -1,5 +1,4 @@ - {{!-- Sheet Header --}}
    @@ -88,7 +87,7 @@ {{!-- Checkbox to hide/show skills that are at zero --}}
    {{localize 'DG.UnnaturalSheet.HideUntrainedSkillsLabel'}}: - +
    @@ -140,7 +139,7 @@
    - {{editor actor.system.notes target="system.notes" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.notes" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-armor-sheet.html b/templates/item/item-armor-sheet.html index 934a75e..f89c01e 100644 --- a/templates/item/item-armor-sheet.html +++ b/templates/item/item-armor-sheet.html @@ -11,22 +11,22 @@ {{localize 'DG.ItemWindow.Armor.Expense'}}: {{localize 'DG.ItemWindow.Armor.Equipped'}}: - +
    {{localize 'DG.ItemWindow.Armor.ArmorRating'}}: - +
    @@ -41,7 +41,7 @@ {{!-- Description Tab --}}
    - {{editor system.description target="system.description" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-bond-sheet.html b/templates/item/item-bond-sheet.html index 54ef5f0..4cb083b 100644 --- a/templates/item/item-bond-sheet.html +++ b/templates/item/item-bond-sheet.html @@ -9,12 +9,12 @@ {{localize 'DG.Bonds.Score'}}: - {{localize 'DG.Bonds.Relationship'}}: - + @@ -30,7 +30,7 @@ {{!-- Description Tab --}}
    - {{editor system.description target="system.description" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-gear-sheet.html b/templates/item/item-gear-sheet.html index 79de9c4..2a816b3 100644 --- a/templates/item/item-gear-sheet.html +++ b/templates/item/item-gear-sheet.html @@ -12,15 +12,15 @@ {{localize 'DG.ItemWindow.Gear.Expense'}}: {{localize 'DG.ItemWindow.Gear.Equipped'}}: - + @@ -38,7 +38,7 @@ {{!-- Description Tab --}}
    - {{editor system.description target="system.description" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-motivation-sheet.html b/templates/item/item-motivation-sheet.html index 4a07283..94e8e2a 100644 --- a/templates/item/item-motivation-sheet.html +++ b/templates/item/item-motivation-sheet.html @@ -13,7 +13,7 @@
    {{localize 'DG.ItemWindow.Motivations.IsDisorder'}}: - @@ -25,7 +25,7 @@ title="{{localize 'DG.ItemWindow.Motivations.MotivationNameTooltip'}}" {{!-- If a motivation has been crossed off after a breaking point, do a strikeout on it and disable it. --}} - {{#if system.crossedOut}} + {{#if item.system.crossedOut}} style="text-decoration: line-through;" disabled {{/if}} @@ -33,17 +33,17 @@ {{!-- Only Show the Disorders Section if Motivation Lost Checked --}} - {{#if system.crossedOut}} + {{#if item.system.crossedOut}} {{localize 'DG.ItemWindow.Motivations.Disorder'}}: - {{localize 'DG.ItemWindow.Motivations.DisorderHasBeenCured'}}: - @@ -54,7 +54,7 @@
    - {{editor system.description target="system.description" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item/item-weapon-sheet.html b/templates/item/item-weapon-sheet.html index e85a2ba..c8e0c49 100644 --- a/templates/item/item-weapon-sheet.html +++ b/templates/item/item-weapon-sheet.html @@ -11,15 +11,15 @@ {{localize 'DG.ItemWindow.Weapons.Expense'}}: {{localize 'DG.ItemWindow.Gear.Equipped'}}: - + @@ -30,56 +30,56 @@ {{localize 'DG.ItemWindow.Weapons.Skill'}}: {{localize 'DG.ItemWindow.Weapons.IsLethality'}}: - {{localize 'DG.ItemWindow.Weapons.KillRadius'}}: - +
    {{localize 'DG.ItemWindow.Weapons.Range'}}: - + {{!-- If a weapon is 'Lethal', need to show the d100% Lethality input, otherwise only show the regular Damage formula (e.g. 1D6, 1D4+2, etc...) --}} - {{#unless system.isLethal}} + {{#unless item.system.isLethal}} {{localize 'DG.ItemWindow.Weapons.Damage'}}: - + {{/unless}} - {{#if system.isLethal}} + {{#if item.system.isLethal}} {{localize 'DG.ItemWindow.Weapons.Lethality'}} %: - {{/if}} {{localize 'DG.ItemWindow.Weapons.ArmorPiercing'}}: - +
    @@ -87,7 +87,7 @@
    {{localize 'DG.ItemWindow.Weapons.Ammo'}}: - +
    @@ -103,7 +103,7 @@ {{!-- Description Tab --}}
    - {{editor system.description target="system.description" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
    From 57f965b127993eb3ed2333dd3ab543004fa27927 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sat, 3 Sep 2022 14:58:46 -0400 Subject: [PATCH 05/12] update system.json to be fully v10 compatible --- system.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/system.json b/system.json index 0f278c4..0d58da3 100644 --- a/system.json +++ b/system.json @@ -1,5 +1,4 @@ { - "name": "deltagreen", "id": "deltagreen", "title": "Delta Green (Unofficial)", "description": "Fan-made Foundry VTT system for Delta Green: The Role Playing Game for Foundry VTT. Based on the rules in the Agent's Handbook (https://www.drivethrurpg.com/product/181674/Delta-Green-Agents-Handbook) [*NOT* Call of Cthulu]. Made with the permission of but neither affiliated with nor endorsed by Arc Dream Publishing or the Delta Green Partnership.", @@ -14,8 +13,6 @@ "verified": 10, "maximum": 10 }, - "minimumCoreVersion": "0.8.6", - "compatibleCoreVersion": "9", "scripts": [], "esmodules": [ "module/deltagreen.js" @@ -107,8 +104,7 @@ "private": false } ], - "system": [], - "dependencies": [], + "relationships": {}, "socket": false, "manifest": "https://github.com/TheLastScrub/delta-green-foundry-vtt-system-unofficial/raw/master/system.json", "download": "https://github.com/TheLastScrub/delta-green-foundry-vtt-system-unofficial/archive/v1.0.6.zip", From d18a690177bc7e2a571dbbcdde298e15c2488b3b Mon Sep 17 00:00:00 2001 From: TheLastScrub <67403321+TheLastScrub@users.noreply.github.com> Date: Sun, 4 Sep 2022 11:44:49 -0700 Subject: [PATCH 06/12] start work on v10 --- css/deltagreen.css | 2 +- module/actor/actor-sheet.js | 11 +- module/actor/actor.js | 30 +++- module/templates.js | 3 +- template.json | 16 +- templates/actor/vehicle-sheet.html | 274 +++++++++++++++++++++++++++++ 6 files changed, 326 insertions(+), 10 deletions(-) create mode 100644 templates/actor/vehicle-sheet.html diff --git a/css/deltagreen.css b/css/deltagreen.css index 2f581bb..f6e0f69 100644 --- a/css/deltagreen.css +++ b/css/deltagreen.css @@ -621,7 +621,7 @@ div.motivation-editor-container div.editor{ } .deltagreen .editor-host .editor { - min-height: 35px; + min-height: 50px; } .deltagreen .editor-host .tox { diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 4f195a5..71085ae 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -22,7 +22,7 @@ export class DeltaGreenActorSheet extends ActorSheet { get template() { if(this.actor !== null){ - if(this.actor.data.type === 'agent'){ + if(this.actor.type === 'agent'){ if ( !game.user.isGM && this.actor.limited ) { return "systems/deltagreen/templates/actor/limited-sheet.html"; } @@ -31,12 +31,15 @@ export class DeltaGreenActorSheet extends ActorSheet { return `systems/deltagreen/templates/actor/actor-sheet.html`; } } - else if(this.actor.data.type === 'unnatural'){ + else if(this.actor.type === 'unnatural'){ return `systems/deltagreen/templates/actor/unnatural-sheet.html`; } - else if(this.actor.data.type === 'npc'){ + else if(this.actor.type === 'npc'){ return `systems/deltagreen/templates/actor/npc-sheet.html`; } + else if(this.actor.type === 'vehicle'){ + return `systems/deltagreen/templates/actor/vehicle-sheet.html`; + } else{ return "systems/deltagreen/templates/actor/limited-sheet.html"; } @@ -51,7 +54,7 @@ export class DeltaGreenActorSheet extends ActorSheet { const data = super.getData(); // Prepare items. - if (this.actor.data.type == 'agent') { + if (this.actor.type == 'agent') { this._prepareCharacterItems(data); } diff --git a/module/actor/actor.js b/module/actor/actor.js index 4f240ff..66da155 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -10,9 +10,10 @@ export class DeltaGreenActor extends Actor { prepareData() { super.prepareData(); - const actorData = this.data; - const data = actorData.data; - const flags = actorData.flags; + const actorData = this; + //const actorData = this.data; + //const data = actorData.data; + //const flags = actorData.flags; //console.log('actor.js prepareData'); //console.log(this); @@ -28,12 +29,35 @@ export class DeltaGreenActor extends Actor { else if(actorData.type === 'npc'){ this._prepareNpcData(this); } + else if(actorData.type === 'vehicle'){ + this._prepareVehicleData(this); + } } /** * * @param {*} agent */ + + _prepareVehicleData(actor){ + let actorData = actor; + //const data = actorData.data; + + // calculate total armor rating + let protection = 0; + for (let i of actor.items) { + if (i.type === 'armor') { + if(i.data.data.equipped === true){ + protection += i.data.data.protection; + } + } + } + + actorData.system.health.protection = protection; + + console.log(actor); + } + _prepareNpcData(actor){ let actorData = actor.data; const data = actorData.data; diff --git a/module/templates.js b/module/templates.js index daa5c0b..41eedf4 100644 --- a/module/templates.js +++ b/module/templates.js @@ -11,6 +11,7 @@ export const preloadHandlebarsTemplates = async function() { "systems/deltagreen/templates/actor/unnatural-sheet.html", "systems/deltagreen/templates/actor/npc-sheet.html", "systems/deltagreen/templates/actor/cv-partial.html", - "systems/deltagreen/templates/dialog/modify-percentile-roll.html" + "systems/deltagreen/templates/dialog/modify-percentile-roll.html", + "systems/deltagreen/templates/actor/vehicle-sheet.html" ]); }; \ No newline at end of file diff --git a/template.json b/template.json index 4ef4c83..41dc998 100644 --- a/template.json +++ b/template.json @@ -3,7 +3,8 @@ "types": [ "agent", "unnatural", - "npc" + "npc", + "vehicle" ], "templates": { "base": { @@ -461,6 +462,19 @@ "shortDescription": "", "showUntrainedSkills": true }, + "vehicle":{ + "name": "", + "description": "", + "shortDescription": "", + "health": { + "value": 10, + "min": 0, + "max": 10 + }, + "speed": "", + "expense": "Standard", + "passengers": [] + }, "agent": { "templates": [ "base", diff --git a/templates/actor/vehicle-sheet.html b/templates/actor/vehicle-sheet.html new file mode 100644 index 0000000..aea7e65 --- /dev/null +++ b/templates/actor/vehicle-sheet.html @@ -0,0 +1,274 @@ +
    + + {{!-- Sheet Header --}} +
    + +
    + + {{!-- Name, Portrait --}} +
    + +
    +
    +

    +
    +
    +

    +
    +
    +
    + +
    + + {{!-- HP --}} +
    + +
    + + / + +
    +
    +
    + +
    +
    + + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
    + + {{!-- Descriptions --}} +
    +
    + {{localize 'DG.UnnaturalSheet.NotesLabel'}} +
    +
    +
    + {{editor actor.system.notes target="system.notes" button=true owner=owner editable=editable}} +
    +
    + +
    + + {{!-- GEAR --}} +
    +
    + +
    + {{localize 'DG.Gear.Weapons'}} +
    + +
      + +
    1. +
      + {{localize 'DG.Gear.Name'}} + {{localize 'DG.Gear.DamageOrLethality'}} + {{localize 'DG.Gear.ArmorPiercing'}} + +
    2. + + {{#each actor.items as |item id|}} + {{#if_eq item.type 'weapon'}} + +
    3. +
      + +

      + {{item.name}} +

      + + {{#unless item.data.data.isLethal}} + + {{toUpperCase item.data.data.damage}} + {{/unless}} + + {{#if item.data.data.isLethal}} + {{formatLethality item.data.data.lethality}} + {{/if}} + + {{item.data.data.armorPiercing}} + +
      + + +
      + +
    4. + + {{/if_eq}} + {{/each}} +
    +
    +
    + +
    + {{localize 'DG.Gear.Armor'}} +
    + +
      +
    1. +
      +
      {{localize 'DG.Gear.Name'}}
      + {{localize 'DG.Gear.ArmorRating'}} + {{localize 'DG.Gear.Equipped'}} + +
    2. + + {{#each actor.items as |item id|}} + {{#if_eq item.type 'armor'}} + +
    3. +
      +

      {{item.name}}

      + {{item.data.data.protection}} + + + {{#if item.data.data.equipped}} + + {{else}} + + {{/if}} + + +
      + + +
      +
    4. + + {{/if_eq}} + {{/each}} + +
    +
    +
    + +
    + {{localize 'DG.Gear.OtherGear'}} +
    + +
      +
    1. +
      +
      {{localize 'DG.Gear.Name'}}
      +
      + {{localize 'DG.Gear.Equipped'}} + +
    2. + + {{#each actor.items as |item id|}} + {{#if_eq item.type 'gear'}} + +
    3. +
      + +

      {{item.name}}

      + + + + + + {{#if item.data.data.equipped}} + + {{else}} + + {{/if}} + + + +
      + + +
      +
    4. + + {{/if_eq}} + {{/each}} + +
    +
    +
    + + {{!-- About Tab --}} +
    +
    + +
    +
    + + + +
    +
    + This is an unofficial fan work, it is not affiliated with or endorsed by Shaney Ivey or Arc Dream Publishing. +
    +
    +
    + Delta Green Community License (NONCOMMERCIAL) +

    + Published by arrangement with the Delta Green Partnership. + The intellectual property known as Delta Green is a trademark and copyright owned by the Delta Green Partnership, who has licensed its use here. +

    +

    + The contents of this system are licensed per the terms of the included license file, excepting those elements that are components of the Delta Green intellectual property. +

    +

    + Some content may additionally also be covered under the terms of the Open Game License (Copyright 2000 Wizards of the Coast, Inc.). +

    +
    +
    +
    + +
    +
    + + \ No newline at end of file From 014aea23b182ca33ad28015d0cb6d803a9edf1f8 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sun, 4 Sep 2022 15:33:47 -0400 Subject: [PATCH 07/12] editor in vehicle sheet uses enrichHTML --- module/actor/actor-sheet.js | 3 +++ templates/actor/vehicle-sheet.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 0dafc5b..94abf67 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -62,6 +62,9 @@ export class DeltaGreenActorSheet extends ActorSheet { case "agent": data.enrichedDescription = await TextEditor.enrichHTML(this.object.system.physicalDescription, {async: true}); break; + case "vehicle": + data.enrichedDescription = await TextEditor.enrichHTML(this.object.system.description, {async: true}); + break; case "npc": case "unnatural": data.enrichedDescription = await TextEditor.enrichHTML(this.object.system.notes, {async: true}); diff --git a/templates/actor/vehicle-sheet.html b/templates/actor/vehicle-sheet.html index aea7e65..588d919 100644 --- a/templates/actor/vehicle-sheet.html +++ b/templates/actor/vehicle-sheet.html @@ -51,7 +51,7 @@
    - {{editor actor.system.notes target="system.notes" button=true owner=owner editable=editable}} + {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
    From 653b1e70b2a6486d183226659b2dad536b57d4c6 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sun, 4 Sep 2022 15:44:01 -0400 Subject: [PATCH 08/12] update skill improvement stuff for v10 --- module/actor/actor-sheet.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index bfb2113..395e9d1 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -267,7 +267,7 @@ export class DeltaGreenActorSheet extends ActorSheet { event.preventDefault(); - const failures = Object.entries(this.actor.data.data.skills).filter((skill) => skill[1].failure); + const failures = Object.entries(this.actor.system.skills).filter((skill) => skill[1].failure); if (failures.length === 0) { ui.notifications.warn('No Skills to Increase') return; @@ -690,7 +690,7 @@ export class DeltaGreenActorSheet extends ActorSheet { } _applySkillImprovements(baseRollFormula, failures) { - const actorData = this.actor.data.data; + const actorData = this.actor.system; const resultList = []; let rollFormula; @@ -721,7 +721,7 @@ export class DeltaGreenActorSheet extends ActorSheet { const updatedData = duplicate(actorData); updatedData.skills[skill].proficiency += resultList[value] ?? 1; updatedData.skills[skill].failure = false; - this.actor.update({"data": updatedData}); + this.actor.update({"system": updatedData}); // So we can record the skills and how much they were increased by in chat. if (updatedSkills === "") { From 475a827c725d41d1a3a664d7a534cae500063f12 Mon Sep 17 00:00:00 2001 From: TheLastScrub <67403321+TheLastScrub@users.noreply.github.com> Date: Sun, 4 Sep 2022 17:59:58 -0700 Subject: [PATCH 09/12] added vehicle sheet --- CHANGELOG.md | 5 ++ css/deltagreen.css | 7 +++ lang/ca.json | 7 ++- lang/en.json | 7 ++- lang/es.json | 7 ++- lang/ja.json | 7 ++- module/actor/actor-sheet.js | 15 +++--- module/actor/actor.js | 42 +++++++++++++-- module/deltagreen.js | 37 +++++++------ system.json | 76 +++++++++++++------------- templates/actor/vehicle-sheet.html | 86 ++++-------------------------- 11 files changed, 148 insertions(+), 148 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 922abf0..8857869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Release/Patch Notes +### Version 1.0.7 - ??? [BREAKING CHANGE: THIS VERSION FORWARD COMPATIBLE WITH FOUNDRY V10 OR HIGHER ONLY!] + +* Enhancement - Update to new data model for Foundry V10 +* Enhancement [GitHub #56] - Added an actor sheet for Vehicles + ### Version 1.0.6 - 2022-05-26 * Enhancement - IgorAK25 has submitted a Portuguese translation for the system. diff --git a/css/deltagreen.css b/css/deltagreen.css index f6e0f69..e4ce961 100644 --- a/css/deltagreen.css +++ b/css/deltagreen.css @@ -897,4 +897,11 @@ input.item-sheet-short-input{ .yellow-king textarea:focus, .yellow-king input:focus{ color: #a0912f; +} + +.top-div-border{ + border-top: 1px solid #AAA; + margin-bottom: 10px; + padding-bottom: 10px; + padding-top: 10px; } \ No newline at end of file diff --git a/lang/ca.json b/lang/ca.json index 2daa3a5..6f604c1 100644 --- a/lang/ca.json +++ b/lang/ca.json @@ -238,5 +238,10 @@ "DG.ImpossibleLanscapes.CorruptionFirstHalf": "Corrup", "DG.ImpossibleLanscapes.CorruptionSecondHalf": "tion", "DG.ImpossibleLanscapes.Gift": "Gift", - "DG.ImpossibleLanscapes.Insight": "Insight" + "DG.ImpossibleLanscapes.Insight": "Insight", + + "DG.VehicleSheet.NotesTabName": "Notes", + "DG.VehicleSheet.GearTabName": "Gear", + "DG.VehicleSheet.NotesLabel": "NOTES", + "DG.VehicleSheet.DescriptionPlaceHolder": "Vehicle Description" } diff --git a/lang/en.json b/lang/en.json index df166af..266b11b 100644 --- a/lang/en.json +++ b/lang/en.json @@ -238,5 +238,10 @@ "DG.ImpossibleLanscapes.CorruptionFirstHalf": "Corrup", "DG.ImpossibleLanscapes.CorruptionSecondHalf": "tion", "DG.ImpossibleLanscapes.Gift": "Gift", - "DG.ImpossibleLanscapes.Insight": "Insight" + "DG.ImpossibleLanscapes.Insight": "Insight", + + "DG.VehicleSheet.NotesTabName": "Notes", + "DG.VehicleSheet.GearTabName": "Gear", + "DG.VehicleSheet.NotesLabel": "NOTES", + "DG.VehicleSheet.DescriptionPlaceHolder": "Vehicle Description" } \ No newline at end of file diff --git a/lang/es.json b/lang/es.json index 680b330..5e273ae 100644 --- a/lang/es.json +++ b/lang/es.json @@ -238,5 +238,10 @@ "DG.ImpossibleLanscapes.CorruptionFirstHalf": "Corrup", "DG.ImpossibleLanscapes.CorruptionSecondHalf": "tion", "DG.ImpossibleLanscapes.Gift": "Gift", - "DG.ImpossibleLanscapes.Insight": "Insight" + "DG.ImpossibleLanscapes.Insight": "Insight", + + "DG.VehicleSheet.NotesTabName": "Notes", + "DG.VehicleSheet.GearTabName": "Gear", + "DG.VehicleSheet.NotesLabel": "NOTES", + "DG.VehicleSheet.DescriptionPlaceHolder": "Vehicle Description" } \ No newline at end of file diff --git a/lang/ja.json b/lang/ja.json index eba25f3..9d4d8be 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -238,5 +238,10 @@ "DG.ImpossibleLanscapes.CorruptionFirstHalf": "腐", "DG.ImpossibleLanscapes.CorruptionSecondHalf": "敗", "DG.ImpossibleLanscapes.Gift": "ギフト", - "DG.ImpossibleLanscapes.Insight": "インサイト" + "DG.ImpossibleLanscapes.Insight": "インサイト", + + "DG.VehicleSheet.NotesTabName": "ノート", + "DG.VehicleSheet.GearTabName": "装備", + "DG.VehicleSheet.NotesLabel": "ノート", + "DG.VehicleSheet.DescriptionPlaceHolder": "" } \ No newline at end of file diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 94abf67..4367b1d 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -446,17 +446,18 @@ export class DeltaGreenActorSheet extends ActorSheet { * @private */ _onItemCreate(event) { + event.preventDefault(); + const header = event.currentTarget; + // Get the type of item to create. const type = header.dataset.type; - // Grab any data associated with this control. - //const system = duplicate(header.dataset); Not really sure what this was doing here. Seems unnecessary. - // Initialize a default name. //const name = `New ${type.capitalize()}`; const name = game.i18n.localize("DG.ItemTypes.NewPrefix") + game.i18n.localize("DG.ItemTypes." + type) + // Prepare the item object. const itemData = { name: name, @@ -464,9 +465,6 @@ export class DeltaGreenActorSheet extends ActorSheet { system: {} }; - // Remove the type from the dataset since it's in the itemData.type prop. - // delete itemData.data["type"]; - if(type == "weapon"){ itemData.system.skill = "firearms"; //default skill to firearms, since that will be most common itemData.system.expense = "Standard"; @@ -480,8 +478,7 @@ export class DeltaGreenActorSheet extends ActorSheet { itemData.img = "icons/svg/mystery-man.svg" } - // Finally, create the item! - //return this.actor.createOwnedItem(itemData); + // create the item return this.actor.createEmbeddedDocuments("Item", [itemData]); } @@ -645,7 +642,7 @@ export class DeltaGreenActorSheet extends ActorSheet { if ( event.target.classList.contains("entity-link") ) return; // Create drag data - const dragData = { + let dragData = { actorId: this.actor.id, sceneId: this.actor.isToken ? canvas.scene?.id : null, tokenId: this.actor.isToken ? this.actor.token.id : null diff --git a/module/actor/actor.js b/module/actor/actor.js index c0f377f..391a943 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -40,14 +40,13 @@ export class DeltaGreenActor extends Actor { _prepareVehicleData(actor){ let actorData = actor; - //const data = actorData.data; // calculate total armor rating let protection = 0; for (let i of actor.items) { if (i.type === 'armor') { - if(i.data.data.equipped === true){ - protection += i.data.data.protection; + if(i.system.equipped === true){ + protection += i.system.protection; } } } @@ -313,6 +312,41 @@ export class DeltaGreenActor extends Actor { console.log('Error adding unarmed strike item to Actor.') console.log(ex); } - } + } + + async AddBaseVehicleItemsIfMissing(){ + try{ + let flag = await this.getFlag('deltagreen', 'DefaultVehicleArmorAdded'); + + if(flag !== null && flag !== undefined && flag !== true){ + console.log('found a flag'); + console.log(flag); + } + else{ + // mark the actor so that we don't accidently do this again later, or if we want to fix/change something on it in the future + this.setFlag('deltagreen', 'DefaultVehicleArmorAdded', true); + + let toAdd = []; // createEmbeddedDocument expects an array + + let armor = await Item.create({type:"armor", name:"Vehicle Frame"}); + + // this is the current default, but set it anyways in case it gets changed later. + armor.system.protection = 3; + + toAdd.push(armor); + + // create the item on the actor + let newItems = await this.createEmbeddedDocuments("Item", toAdd); + + for(let item of newItems){ + await item.setFlag('deltagreen','AutoAdded', true); + } + + } + } + catch(ex){ + console.log(ex); + } + } } \ No newline at end of file diff --git a/module/deltagreen.js b/module/deltagreen.js index 4ba5960..b816265 100644 --- a/module/deltagreen.js +++ b/module/deltagreen.js @@ -297,24 +297,31 @@ Hooks.on('createActor', async function(actor, options, userId){ // can put logic specific to a particular user session below if (userId != game.user.id) { return; }; - if(actor != null && actor.type === 'agent'){ - // update the default type skill of Art - Painting's labels to try to be localized - // since I really backed myself into a corner on this with my implementation of it... - console.log('createActor Hook'); + if(actor != null){ - let artLabel = game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"; - let paintingLabel = game.i18n.translations.DG?.TypeSkills?.Subskills?.Painting ?? "Painting"; + if(actor.type === 'agent'){ + // update the default type skill of Art - Painting's labels to try to be localized + // since I really backed myself into a corner on this with my implementation of it... + console.log('createActor Hook'); - let updatedData = duplicate(actor.system); - updatedData.typedSkills.tskill_01.group = artLabel; - updatedData.typedSkills.tskill_01.label = paintingLabel; + let artLabel = game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"; + let paintingLabel = game.i18n.translations.DG?.TypeSkills?.Subskills?.Painting ?? "Painting"; + + let updatedData = duplicate(actor.system); + updatedData.typedSkills.tskill_01.group = artLabel; + updatedData.typedSkills.tskill_01.label = paintingLabel; + + actor.update({"data": updatedData}); + + // throw on an unarmed strike item for convenience + actor.AddUnarmedAttackItemIfMissing(); + } + else if(actor.type === 'unnatural'){ - actor.update({"data": updatedData}); - - // throw on an unarmed strike item for convenience - actor.AddUnarmedAttackItemIfMissing(); - } - else if(actor.type === 'unnatural'){ + } + else if(actor.type === 'vehicle'){ + actor.AddBaseVehicleItemsIfMissing(); + } } diff --git a/system.json b/system.json index 0d58da3..a0f6310 100644 --- a/system.json +++ b/system.json @@ -2,18 +2,12 @@ "id": "deltagreen", "title": "Delta Green (Unofficial)", "description": "Fan-made Foundry VTT system for Delta Green: The Role Playing Game for Foundry VTT. Based on the rules in the Agent's Handbook (https://www.drivethrurpg.com/product/181674/Delta-Green-Agents-Handbook) [*NOT* Call of Cthulu]. Made with the permission of but neither affiliated with nor endorsed by Arc Dream Publishing or the Delta Green Partnership.", - "author": "TheLastScrub (https://github.com/TheLastScrub)", - "authors": [], "url": "https://github.com/TheLastScrub/delta-green-foundry-vtt-system-unofficial", "license": "LICENSE.txt", - "flags": {}, "version": "1.0.6", "compatibility": { - "minimum": 10, - "verified": 10, - "maximum": 10 + "minimum": "0.8.6" }, - "scripts": [], "esmodules": [ "module/deltagreen.js" ], @@ -25,27 +19,32 @@ { "lang": "en", "name": "English", - "path": "lang/en.json" + "path": "lang/en.json", + "flags": {} }, { "lang": "ja", "name": "日本語", - "path": "lang/ja.json" + "path": "lang/ja.json", + "flags": {} }, { "lang": "es", "name": "Español", - "path": "lang/es.json" + "path": "lang/es.json", + "flags": {} }, { "lang": "ca", "name": "Català", - "path": "lang/ca.json" + "path": "lang/ca.json", + "flags": {} }, { "lang": "pt", "name": "Português (Brasil)", - "path": "lang/pt.json" + "path": "lang/pt.json", + "flags": {} } ], "packs": [ @@ -53,64 +52,61 @@ "name": "firearms", "label": "Firearms", "system": "deltagreen", - "module": "deltagreen", - "path": "./packs/firearms.db", - "entity": "Item", - "private": false + "path": "packs/firearms.db", + "private": false, + "type": "Item", + "flags": {} }, { "name": "armor", "label": "Armor", "system": "deltagreen", - "module": "deltagreen", - "path": "./packs/armor.db", - "entity": "Item", - "private": false + "path": "packs/armor.db", + "private": false, + "type": "Item", + "flags": {} }, { "name": "hand-to-hand-weapons", "label": "Hand-to-Hand Weapons", "system": "deltagreen", - "module": "deltagreen", - "path": "./packs/hand-to-hand-weapons.db", - "entity": "Item", - "private": false + "path": "packs/hand-to-hand-weapons.db", + "private": false, + "type": "Item", + "flags": {} }, { "name": "agent-pregens", "label": "Agent Pregens", "system": "deltagreen", - "module": "deltagreen", - "path": "./packs/pregens.db", - "entity": "Actor", - "private": false + "path": "packs/pregens.db", + "private": false, + "type": "Actor", + "flags": {} }, { "name": "operation-code-name-generator-tables", "label": "Operation Code Name Generator Tables", "system": "deltagreen", - "module": "deltagreen", - "path": "./packs/operation-code-name-generator.db", - "entity": "RollTable", - "private": false + "path": "packs/operation-code-name-generator.db", + "private": false, + "type": "RollTable", + "flags": {} }, { "name": "operation-code-name-generator-macro", "label": "Operation Code Name Generator Macro", "system": "deltagreen", - "module": "deltagreen", - "path": "./packs/operation-code-name-generator-macro.db", - "entity": "Macro", - "private": false + "path": "packs/operation-code-name-generator-macro.db", + "private": false, + "type": "Macro", + "flags": {} } ], - "relationships": {}, - "socket": false, "manifest": "https://github.com/TheLastScrub/delta-green-foundry-vtt-system-unofficial/raw/master/system.json", "download": "https://github.com/TheLastScrub/delta-green-foundry-vtt-system-unofficial/archive/v1.0.6.zip", - "protected": false, "gridDistance": 1, "gridUnits": "m", "primaryTokenAttribute": "health", "secondaryTokenAttribute": "wp" -} +} \ No newline at end of file diff --git a/templates/actor/vehicle-sheet.html b/templates/actor/vehicle-sheet.html index 588d919..344d0f6 100644 --- a/templates/actor/vehicle-sheet.html +++ b/templates/actor/vehicle-sheet.html @@ -13,7 +13,7 @@

    -

    +

    @@ -36,18 +36,18 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}}
    - {{!-- Descriptions --}} -
    + {{!-- Descriptions (Notes) --}} +
    - {{localize 'DG.UnnaturalSheet.NotesLabel'}} + {{localize 'DG.VehicleSheet.NotesLabel'}}
    @@ -59,73 +59,7 @@ {{!-- GEAR --}}
    -
    - -
    - {{localize 'DG.Gear.Weapons'}} -
    - -
      - -
    1. -
      - {{localize 'DG.Gear.Name'}} - {{localize 'DG.Gear.DamageOrLethality'}} - {{localize 'DG.Gear.ArmorPiercing'}} - -
    2. - - {{#each actor.items as |item id|}} - {{#if_eq item.type 'weapon'}} - -
    3. -
      - -

      - {{item.name}} -

      - - {{#unless item.data.data.isLethal}} - - {{toUpperCase item.data.data.damage}} - {{/unless}} - - {{#if item.data.data.isLethal}} - {{formatLethality item.data.data.lethality}} - {{/if}} - - {{item.data.data.armorPiercing}} - -
      - - -
      - -
    4. - - {{/if_eq}} - {{/each}} -
    -
    +
    @@ -149,10 +83,10 @@
  • {{item.name}}

    - {{item.data.data.protection}} + {{item.system.protection}} - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} @@ -199,7 +133,7 @@ - {{#if item.data.data.equipped}} + {{#if item.system.equipped}} {{else}} From 2ed511f71c76dc632ded2efa6df2445f62717d1a Mon Sep 17 00:00:00 2001 From: jalensailin Date: Sun, 4 Sep 2022 21:11:37 -0400 Subject: [PATCH 10/12] skill improvements work correctly for typed skills; rollFormula is now only chosen by GMs, controllable in settings --- module/actor/actor-sheet.js | 92 ++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 31 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 395e9d1..513f212 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -267,30 +267,34 @@ export class DeltaGreenActorSheet extends ActorSheet { event.preventDefault(); - const failures = Object.entries(this.actor.system.skills).filter((skill) => skill[1].failure); - if (failures.length === 0) { + const failedSkills = Object.entries(this.actor.system.skills).filter((skill) => skill[1].failure); + const failedTypedSkills = Object.entries(this.actor.system.typedSkills).filter((skill) => skill[1].failure); + if (failedSkills.length === 0 && failedTypedSkills.length === 0) { ui.notifications.warn('No Skills to Increase') return; } let htmlContent = ""; let failedSkillNames = ""; - failures.forEach(([skill], value) => { + failedSkills.forEach(([skill], value) => { if (value === 0) { failedSkillNames += (game.i18n.localize("DG.Skills." + skill)); } else { failedSkillNames += `, ${(game.i18n.localize("DG.Skills." + skill))}`; } }) + failedTypedSkills.forEach(([skillName, skillData], value) => { + if (value === 0 && failedSkillNames === "") { + failedSkillNames += `${game.i18n.localize("DG.TypeSkills." + skillData.group.split(" ").join(""))} (${skillData.label})`; + } else { + failedSkillNames += `, ${game.i18n.localize("DG.TypeSkills." + skillData.group.split(" ").join(""))} (${skillData.label})`; + } + }) + + const baseRollFormula = game.settings.get("deltagreen", "skillImprovementFormula"); htmlContent += `
    `; - htmlContent += ` `; - htmlContent += ` `; + htmlContent += ` `; htmlContent += `
    `; htmlContent += ` ${game.i18n.localize("DG.Skills.ApplySkillImprovementsDialogEffectsFollowing")} ${failedSkillNames} `; htmlContent += `
    `; @@ -303,8 +307,7 @@ export class DeltaGreenActorSheet extends ActorSheet { apply:{ label: game.i18n.translations.DG?.Skills?.Apply ?? "Apply", callback: btn =>{ - const baseRollForumla = btn.find("[name='roll-formula']").val(); - this._applySkillImprovements(baseRollForumla, failures); + this._applySkillImprovements(baseRollFormula, failedSkills, failedTypedSkills); }, } } @@ -689,21 +692,22 @@ export class DeltaGreenActorSheet extends ActorSheet { } } - _applySkillImprovements(baseRollFormula, failures) { + _applySkillImprovements(baseRollFormula, failedSkills, failedTypedSkills) { const actorData = this.actor.system; const resultList = []; let rollFormula; + // Define the amount of dice being rolled, if any. switch (baseRollFormula) { case "1": rollFormula = 1; break; case "1d3": - rollFormula = `${failures.length}d3`; + rollFormula = `${failedSkills.length + failedTypedSkills.length}d3`; break; case "1d4": case "1d4-1": - rollFormula = `${failures.length}d4`; + rollFormula = `${failedSkills.length + failedTypedSkills.length}d4`; break; default: } @@ -712,38 +716,64 @@ export class DeltaGreenActorSheet extends ActorSheet { if (rollFormula !== 1) { roll = new Roll(rollFormula, actorData); roll.evaluate({async: true}); + // Put the results into a list. roll.terms[0].results.forEach((result) => resultList.push(baseRollFormula === "1d4-1" ? result.result - 1 : result.result)); } - let updatedSkills = ""; + // This will be end up being a list of skills and how much each were improved by. It gets modified in the following loops. + let improvedSkillList = ""; - failures.forEach(([skill], value) => { + failedSkills.forEach(([skill], value) => { const updatedData = duplicate(actorData); - updatedData.skills[skill].proficiency += resultList[value] ?? 1; + updatedData.skills[skill].proficiency += resultList[value] ?? 1; // Increase proficiency by die result or by 1 if there is no dice roll. updatedData.skills[skill].failure = false; this.actor.update({"system": updatedData}); - // So we can record the skills and how much they were increased by in chat. - if (updatedSkills === "") { - updatedSkills += `${game.i18n.localize("DG.Skills." + skill)}: +${resultList[value] ?? 1}%`; + // So we can record the regular skills improved and how much they were increased by in chat. + // The if statement tells us whether to add a comma before the term or not. + if (value === 0) { + improvedSkillList += `${game.i18n.localize("DG.Skills." + skill)}: +${resultList[value] ?? 1}%`; } else { - updatedSkills += `, ${game.i18n.localize("DG.Skills." + skill)}: +${resultList[value] ?? 1}%`; + improvedSkillList += `, ${game.i18n.localize("DG.Skills." + skill)}: +${resultList[value] ?? 1}%`; } }) + failedTypedSkills.forEach(([skillName, skillData], value) => { + const updatedData = duplicate(actorData); + // We must increase value in the following line by the length of failedSkills, so that we index the entire resultList. + // Otherwise we would be adding the same die results to regular skills and typed skills. + updatedData.typedSkills[skillName].proficiency += resultList[value + failedSkills.length] ?? 1; + updatedData.typedSkills[skillName].failure = false; + this.actor.update({"system": updatedData}); + + // So we can record the typed skills improved and how much they were increased by in chat. + // The if statement tells us whether to add a comma before the term or not. + if (value === 0 && improvedSkillList === "") { + improvedSkillList += `${game.i18n.localize("DG.TypeSkills." + skillData.group.split(" ").join(""))} (${skillData.label}): +${resultList[value + failedSkills.length] ?? 1}%`; + } else { + improvedSkillList += `, ${game.i18n.localize("DG.TypeSkills." + skillData.group.split(" ").join(""))} (${skillData.label}): +${resultList[value + failedSkills.length] ?? 1}%`; + } + }) + + let html; + html = `
    ` + html += `
    ${improvedSkillList}
    ` + html += `
    ` + const chatData = { - speaker: ChatMessage.getSpeaker({actor: this.actor, token: this.token, alias: this.actor.data.name}), - content: updatedSkills, - flavor: `${game.i18n.localize("DG.Skills.ApplySkillImprovementsChatFlavor")} +${baseRollFormula}%:`, + speaker: ChatMessage.getSpeaker({actor: this.actor, token: this.token, alias: this.actor.name}), + content: html, + flavor: `${game.i18n.localize("DG.Skills.ApplySkillImprovementsChatFlavor")} +${baseRollFormula}%:`, type: baseRollFormula === "1" ? 0 : 5, // 0 = CHAT_MESSAGE_TYPES.OTHER, 5 = CHAT_MESSAGE_TYPES.ROLL - roll: baseRollFormula === "1" ? null : roll, // If adding flat +1, there is no roll. + rolls: baseRollFormula === "1" ? [] : [roll], // If adding flat +1, there is no roll. rollMode: game.settings.get("core", "rollMode") }; - - // play the dice rolling sound, like a regular in-chat roll - if (roll) AudioHelper.play({src: "sounds/dice.wav", volume: 0.8, autoplay: true, loop: false}, true); - - ChatMessage.create(chatData, {}); + + // play the dice rolling sound, like a regular in-chat roll + if (roll) AudioHelper.play({src: "sounds/dice.wav", volume: 0.8, autoplay: true, loop: false}, true); + + ChatMessage.create(chatData, {}); + } _onDragStart(event) { From 4229048e7725c8d897d41a004186b7d543859ff1 Mon Sep 17 00:00:00 2001 From: TheLastScrub <67403321+TheLastScrub@users.noreply.github.com> Date: Sun, 4 Sep 2022 18:39:01 -0700 Subject: [PATCH 11/12] fix chat card label on non x5 weapon tests --- module/actor/actor-sheet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index d6c62eb..6b533da 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -597,14 +597,14 @@ export class DeltaGreenActorSheet extends ActorSheet { targetVal = this.actor.system.statistics.cha.x5; } else{ - label = game.i18n.localize("DG.Skills." + targetVal).toUpperCase() + "x5"; + label = game.i18n.localize("DG.Skills." + targetVal).toUpperCase(); targetVal = this.actor.system.skills[targetVal].proficiency; } } else if(dataset.target === "statistic.x5"){ let stat = this.actor.system.statistics[key]; targetVal = stat.x5; - label = game.i18n.localize("DG.Attributes." + key).toUpperCase(); + label = game.i18n.localize("DG.Attributes." + key).toUpperCase() + "x5"; } else if(rollType === "sanity"){ targetVal = this.actor.system.sanity.value; From 31454457bc99beef6d3b89e367b64fe81607db21 Mon Sep 17 00:00:00 2001 From: TheLastScrub <67403321+TheLastScrub@users.noreply.github.com> Date: Sun, 4 Sep 2022 18:43:15 -0700 Subject: [PATCH 12/12] made x5 label in physical tab rollable as well --- templates/actor/actor-sheet.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/actor/actor-sheet.html b/templates/actor/actor-sheet.html index a785c80..02b5966 100644 --- a/templates/actor/actor-sheet.html +++ b/templates/actor/actor-sheet.html @@ -168,7 +168,7 @@
    - ({{numberFormat statistic.x5 decimals=0 sign=false}}%) + ({{numberFormat statistic.x5 decimals=0 sign=false}}%)