From 8ab4c68924f45568d2575dc39b217400791a4c59 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 22 May 2021 22:01:05 +0200 Subject: [PATCH 01/12] 0.8 branch --- system.json | 195 +++++++++++++++++++++++++--------------------------- 1 file changed, 94 insertions(+), 101 deletions(-) diff --git a/system.json b/system.json index 1e58e62..c213547 100644 --- a/system.json +++ b/system.json @@ -2,101 +2,21 @@ "name": "foundryvtt-shadows-over-sol", "title": "Shadows over Sol", "description": "Shadows over Sol for FoundryVTT", - "version": "1.0.0", - "manifestPlusVersion": "1.0.0", - "minimumCoreVersion": "0.7.5", - "compatibleCoreVersion": "0.7.9", - "templateVersion": 23, "author": "LeRatierBretonnien", - "esmodules": [ "module/sos-main.js" ], - "styles": ["styles/simple.css"], - "background" : "img/ui/background01.webp", - "media": [ + "authors": [], + "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", + "license": "LICENSE.txt", + "flags": {}, + "version": "2.0.0", + "minimumCoreVersion": "0.8.0", + "compatibleCoreVersion": "0.8.5", + "scripts": [], + "esmodules": [ + "module/sos-main.js" ], - "packs": [ - { - "name": "skills", - "label": "Skills", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/skills.db", - "entity": "Item", - "tags" : [ "skill", "skills" ] - }, - { - "name": "consequences", - "label": "Consequences", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/consequences.db", - "entity": "Item", - "tags" : [ "consequence", "Consequences" ] - }, - { - "name": "gears", - "label": "Gears", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/gears.db", - "entity": "Item", - "tags" : [ "gear", "weapon", "armor" ] - }, - { - "name": "injuries", - "label": "Injuries", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/injuries.db", - "entity": "Item", - "tags" : [ "injury" ] - }, - { - "name": "weaknesses", - "label": "Weaknesses", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/weaknesses.db", - "entity": "Item", - "tags" : [ "weakness" ] - }, - { - "name": "languages", - "label": "Languages", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/languages.db", - "entity": "Item", - "tags" : [ "language" ] - }, - { - "name": "combat-actions", - "label": "Combat Actions", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/combat-actions.db", - "entity": "Item", - "tags" : [ "actions", "combat", "attack" ] - }, - { - "name": "genelines", - "label": "Genelines", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/genelines.db", - "entity": "Item", - "tags" : [ "genelines", "genetic" ] - }, - { - "name": "subcultures", - "label": "Subcultures", - "system": "foundryvtt-shadows-over-sol", - "module": "foundryvtt-shadows-over-sol", - "path": "./packs/subcultures.db", - "entity": "Item", - "tags" : [ "subcultures", "cultures" ] - } + "styles": [ + "styles/simple.css" ], - "library": false, "languages": [ { "lang": "en", @@ -104,13 +24,86 @@ "path": "lang/en.json" } ], - "gridDistance": 5, - "gridUnits": "ft", - "primaryTokenAttribute": "", - "secondaryTokenAttribute": "", + "packs": [ + { + "name": "skills", + "label": "Skills", + "path": "./packs/skills.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "consequences", + "label": "Consequences", + "path": "./packs/consequences.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "gears", + "label": "Gears", + "path": "./packs/gears.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "injuries", + "label": "Injuries", + "path": "./packs/injuries.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "weaknesses", + "label": "Weaknesses", + "path": "./packs/weaknesses.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "languages", + "label": "Languages", + "path": "./packs/languages.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "combat-actions", + "label": "Combat Actions", + "path": "./packs/combat-actions.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "genelines", + "label": "Genelines", + "path": "./packs/genelines.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + }, + { + "name": "subcultures", + "label": "Subcultures", + "path": "./packs/subcultures.db", + "entity": "Item", + "system": "foundryvtt-shadows-over-sol", + "private": false + } + ], + "system": [], + "dependencies": [], "socket": true, - "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", - "manifest": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/-/raw/master/system.json", - "download": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/-/archive/master/foundryvtt-shadows-over-sol.zip", - "license": "LICENSE.txt" -} + "manifest": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/-/raw/dev_0.8/system.json", + "download": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/-/archive/dev_0.8/foundryvtt-shadows-over-sol.zip", + "protected": false, + "gridDistance": 5, + "gridUnits": "ft" +} \ No newline at end of file From 6ebc11c51855b8539c1a22f873c7a1f57f96109b Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 22 May 2021 23:20:23 +0200 Subject: [PATCH 02/12] Start 0.8 support --- module/actor-sheet.js | 76 ++++++++++++++++++------------- module/actor.js | 8 ++-- module/sos-main.js | 8 ++-- module/sos-utility.js | 34 ++++++++++++-- templates/actor-sheet.html | 92 +++++++++++++++++++------------------- 5 files changed, 130 insertions(+), 88 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index a47920e..d3f261e 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -23,34 +23,48 @@ export class SoSActorSheet extends ActorSheet { /* -------------------------------------------- */ getData() { - let data = super.getData(); - + const objectData = SoSUtility.data(this.object); + let formData = { + title: this.title, + id: objectData.id, + type: objectData.type, + img: objectData.img, + name: objectData.name, + editable: this.isEditable, + cssClass: this.isEditable ? "editable" : "locked", + data: foundry.utils.deepClone(this.object.data), + effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), + limited: this.object.limited, + options: this.options, + owner: this.document.isOwner + }; + this.actor.checkDeck(); - data.data.edgecard = this.actor.getEdgesCard(); - data.data.deckSize = this.actor.getDeckSize(); + formData.edgecard = this.actor.getEdgesCard(); + formData.deckSize = this.actor.getDeckSize(); - data.data.skills = this.actor.data.items.filter( item => item.type == 'skill').sort( (a, b) => { + formData.skills = this.actor.data.items.filter( item => item.type == 'skill').sort( (a, b) => { if ( a.name > b.name ) return 1; return -1; }); - - data.data.skill1 = data.data.skills.slice(0, Math.ceil(data.data.skills.length/2) ) - data.data.skill2 = data.data.skills.slice(Math.ceil(data.data.skills.length/2), data.data.skills.length ) - data.data.consequences = this.actor.data.items.filter( item => item.type == 'consequence').sort( (a, b) => { + + formData.skill1 = formData.skills.slice(0, Math.ceil(formData.skills.length/2) ) + formData.skill2 = formData.skills.slice(Math.ceil(formData.skills.length/2), formData.skills.length ) + formData.consequences = this.actor.data.items.filter( item => item.type == 'consequence').sort( (a, b) => { if ( a.name > b.name ) return 1; return -1; }); - data.data.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') ); + formData.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') ); // Build the gear tree - data.data.gearsRoot = data.data.gears.filter(item => item.data.containerid == ""); - for ( let container of data.data.gearsRoot) { + formData.gearsRoot = formData.gears.filter(item => item.data.containerid == ""); + for ( let container of formData.gearsRoot) { if ( container.type == 'container') { container.data.contains = [] container.data.containerEnc = 0; for (let gear of data.data.gears) { - if ( gear.data.containerid == container._id) { + if ( gear.data.containerid == container.id) { container.data.contains.push( gear ); if ( !gear.data.neg && !gear.data.software ) { container.data.containerEnc += (gear.big > 0) ? gear.big : 1; @@ -60,25 +74,25 @@ export class SoSActorSheet extends ActorSheet { } } - data.data.weapons = this.actor.data.items.filter( item => item.type == 'weapon'); - data.data.armors = this.actor.data.items.filter( item => item.type == 'armor'); - data.data.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items); - data.data.wounds = duplicate(this.actor.data.data.wounds); - data.data.isGM = game.user.isGM; - data.data.currentWounds = this.actor.computeCurrentWounds(); - data.data.totalWounds = this.actor.data.data.scores.wound.value; + formData.weapons = this.actor.data.items.filter( item => item.type == 'weapon'); + formData.armors = this.actor.data.items.filter( item => item.type == 'armor'); + formData.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items); + formData.wounds = duplicate(this.actor.data.data.wounds); + formData.isGM = game.user.isGM; + formData.currentWounds = this.actor.computeCurrentWounds(); + formData.totalWounds = this.actor.data.data.scores.wound.value; - data.data.subcultureList = this.actor.data.items.filter( item => item.type == 'subculture'); - if ( data.data.subculture != "" ) { // background.subculture contains the main subculture ID - data.data.mainSubculture = data.data.subcultureList.find( subc => subc._id == data.data.subculture); + formData.subcultureList = this.actor.data.items.filter( item => item.type == 'subculture'); + if ( formData.subculture != "" ) { // background.subculture contains the main subculture ID + formData.mainSubculture = formData.subcultureList.find( subc => subc._id == data.data.subculture); } - data.data.languageList = this.actor.data.items.filter( item => item.type == 'language'); - data.data.weaknessList = this.actor.data.items.filter( item => item.type == 'weakness'); - data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline'); - data.data.editStatSkill = this.options.editStatSkill; - //console.log("stats", data); + formData.languageList = this.actor.data.items.filter( item => item.type == 'language'); + formData.weaknessList = this.actor.data.items.filter( item => item.type == 'weakness'); + formData.geneline = this.actor.data.items.find( item => item.type == 'geneline'); + formData.editStatSkill = this.options.editStatSkill; - return data; + console.log("stats", formData); + return formData; } /* -------------------------------------------- */ @@ -94,7 +108,7 @@ export class SoSActorSheet extends ActorSheet { // Update Inventory Item html.find('.item-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); - const item = this.actor.getOwnedItem(li.data("item-id")); + const item = this.actor.items.get(li.data("item-id")); item.sheet.render(true); }); html.find('.item-equip').click(ev => { @@ -163,7 +177,7 @@ export class SoSActorSheet extends ActorSheet { const li = $(event.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("item-id")); let severity = $(event.currentTarget).val(); - this.actor.updateOwnedItem( { _id: item._id, 'data.severity': severity}); + this.actor.updateOwnedItem( { id: item.id, 'data.severity': severity}); this.render(true); }); html.find('.lock-unlock-sheet').click((event) => { diff --git a/module/actor.js b/module/actor.js index f0ffc54..ce86f31 100644 --- a/module/actor.js +++ b/module/actor.js @@ -34,17 +34,19 @@ export class SoSActor extends Actor { return actor; } - data.items = []; + let items = []; let compendiumName = "foundryvtt-shadows-over-sol.skills"; if ( compendiumName ) { let skills = await SoSUtility.loadCompendium(compendiumName); - data.items = data.items.concat( skills ); + items = skills.map(i => i.toObject()); } compendiumName = "foundryvtt-shadows-over-sol.consequences"; if ( compendiumName ) { let consequences = await SoSUtility.loadCompendium(compendiumName) - data.items = data.items.concat(consequences); + items = items.concat( consequences.map(i => i.toObject()) ); } + data.items = items; + console.log(data); return super.create(data, options); } diff --git a/module/sos-main.js b/module/sos-main.js index 35fd287..d33610a 100644 --- a/module/sos-main.js +++ b/module/sos-main.js @@ -56,8 +56,8 @@ Hooks.once("init", async function () { /* -------------------------------------------- */ // Define custom Entity classes - CONFIG.Actor.entityClass = SoSActor; - CONFIG.Combat.entityClass = SoSCombat; + CONFIG.Actor.documentClass = SoSActor; + CONFIG.Combat.documentClass = SoSCombat; CONFIG.SoS = { } @@ -83,8 +83,8 @@ Hooks.once("init", async function () { function welcomeMessage() { //ChatUtility.removeMyChatMessageContaining('
'); ChatMessage.create({ - user: game.user._id, - whisper: [game.user._id], + user: game.user.id, + whisper: [game.user.id], content: `
Welcome !
` }); } diff --git a/module/sos-utility.js b/module/sos-utility.js index e5841d4..d1ccefb 100644 --- a/module/sos-utility.js +++ b/module/sos-utility.js @@ -8,7 +8,7 @@ const severity2malus = { "none": 0, "light": -1, "moderate": -2, "severe": -3, " const severity2bonus = { "none": 0, "light": 1, "moderate": 2, "severe": 3, "critical": 4}; /* -------------------------------------------- */ -export class SoSUtility extends Entity { +export class SoSUtility { /* -------------------------------------------- */ static async preloadHandlebarsTemplates() { @@ -55,6 +55,32 @@ export class SoSUtility extends Entity { } } + /* -------------------------------------------- */ + static data(it) { + if (it instanceof Actor || it instanceof Item || it instanceof Combatant) { + return it.data; + } + return it; + } + + + /* -------------------------------------------- */ + static templateData(it) { + return SoSUtility.data(it)?.data ?? {} + } + + /* -------------------------------------------- */ + static async loadCompendiumData(compendium) { + const pack = game.packs.get(compendium); + return await pack?.getDocuments() ?? []; + } + + /* -------------------------------------------- */ + static async loadCompendium(compendium, filter = item => true) { + let compendiumData = await SoSUtility.loadCompendiumData(compendium); + return compendiumData.filter(filter); + } + /* -------------------------------------------- */ static async loadCompendiumNames(compendium) { const pack = game.packs.get(compendium); @@ -64,13 +90,13 @@ export class SoSUtility extends Entity { } /* -------------------------------------------- */ - static async loadCompendium(compendium, filter = item => true) { + /*static async loadCompendium(compendium, filter = item => true) { let compendiumItems = await SoSUtility.loadCompendiumNames(compendium); const pack = game.packs.get(compendium); let list = []; for (let compendiumItem of compendiumItems) { - await pack.getEntity(compendiumItem._id).then(it => { + await pack.getEntity(compendiumItem.id).then(it => { const item = it.data; if (filter(item)) { list.push(item); @@ -78,7 +104,7 @@ export class SoSUtility extends Entity { }); }; return list; - } + }*/ /* -------------------------------------------- */ static updateCombat(combat, round, diff, id) { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 63126aa..1b441f9 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -5,8 +5,8 @@
- -

+ +

@@ -28,8 +28,8 @@
lock/unlock{{#if data.editStatSkill}}Lock{{else}}Unlock{{/if}} + src="systems/foundryvtt-shadows-over-sol/img/icons/{{#if editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock" + >{{#if editStatSkill}}Lock{{else}}Unlock{{/if}}
  • Stat name @@ -37,7 +37,7 @@ XP
  • - {{#each data.stats as |stat key|}} + {{#each data.data.stats as |stat key|}} {{#if stat.isLevelUp}}
  • @@ -48,12 +48,12 @@
  • {{/if}} {{localize stat.label}} - {{#select stat.value}} {{>"systems/foundryvtt-shadows-over-sol/templates/stat-option-list.html"}} {{/select}} - +
  • {{/each}} @@ -66,14 +66,14 @@ Value Bonus/Malus - {{#each data.scores as |score key|}} + {{#each data.data.scores as |score key|}}
  • {{localize score.label}} - + {{#if (eq key 'defense')}} - + {{/if}} - +
  • {{/each}}
@@ -81,7 +81,7 @@
-

Current deck size : {{data.deckSize}} cards

+

Current deck size : {{deckSize}} cards

Reset full deck and edges Draw a new Edge card @@ -90,7 +90,7 @@

Edge cards :

- {{#each data.edgecard as |card key|}} + {{#each edgecard as |card key|}}
Discard @@ -106,8 +106,8 @@
lock/unlock{{#if data.editStatSkill}}Lock{{else}}Unlock{{/if}} + src="systems/foundryvtt-shadows-over-sol/img/icons/{{#if editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock" + >{{#if editStatSkill}}Lock{{else}}Unlock{{/if}}
Skills @@ -115,11 +115,11 @@
    - {{#each data.skill1 as |skill key|}} + {{#each skill1 as |skill key|}} {{#if skill.data.isLevelUp}} -
  • +
  • {{else}} -
  • +
  • {{/if}} {{#if skill.data.isLevelUp}} @@ -143,11 +143,11 @@
      - {{#each data.skill2 as |skill key|}} + {{#each skill2 as |skill key|}} {{#if skill.data.isLevelUp}} -
    • +
    • {{else}} -
    • +
    • {{/if}} {{#if skill.data.isLevelUp}} @@ -174,24 +174,24 @@ {{!-- Consequences Tab --}}
      lock/unlock{{#if data.editStatSkill}}Lock{{else}}Unlock{{/if}} + src="systems/foundryvtt-shadows-over-sol/img/icons/{{#if editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock" + >{{#if editStatSkill}}Lock{{else}}Unlock{{/if}}

      Wounds & Conséquences

      • Wounds :

      • Light : - +
      • Moderate : - +
      • Severe : - +
      • Critical : - +
      • Total : {{data.currentWounds}} / {{data.totalWounds}} @@ -200,8 +200,8 @@
        - {{#each data.consequences as |conseq key|}} -
      • + {{#each consequences as |conseq key|}} +
      • {{conseq.name}} - {{#select data.subculture}} - {{#each data.subcultureList as |subculture key|}} + {{#select subculture}} + {{#each subcultureList as |subculture key|}} {{/each}} {{/select}} @@ -339,8 +339,8 @@
        Familiar Subcultures
          - {{#each data.subcultureList as |subculture key|}} -
        • + {{#each subcultureList as |subculture key|}} +
        • {{subculture.name}}
          @@ -354,8 +354,8 @@
          Known Languages
            - {{#each data.languageList as |language key|}} -
          • + {{#each languageList as |language key|}} +
          • {{language.name}}
            @@ -369,8 +369,8 @@
            Weaknesses
              - {{#each data.weaknessList as |weakness key|}} -
            • + {{#each weaknessList as |weakness key|}} +
            • {{weakness.name}}
              From 3d23807820d182a5a92fa34bc7329065d36e472d Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 22 May 2021 23:42:53 +0200 Subject: [PATCH 03/12] Start 0.8 support --- module/actor-sheet.js | 4 ++-- module/actor.js | 24 +++++++++++----------- module/item-sheet.js | 29 ++++++++++++++++++++------- templates/actor-sheet.html | 24 +++++++++++----------- templates/item-consequence-sheet.html | 10 ++++----- templates/item-skill-sheet.html | 8 ++++---- 6 files changed, 57 insertions(+), 42 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index d3f261e..e69b79d 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -175,9 +175,9 @@ export class SoSActorSheet extends ActorSheet { }); html.find('.consequence-severity').click((event) => { const li = $(event.currentTarget).parents(".item"); - const item = this.actor.getOwnedItem(li.data("item-id")); + const item = this.actor.items.get(li.data("item-id")); let severity = $(event.currentTarget).val(); - this.actor.updateOwnedItem( { id: item.id, 'data.severity': severity}); + this.actor.updateEmbeddedDocuments( "Item", [ { _id: item.id, 'data.severity': severity} ] ); this.render(true); }); html.find('.lock-unlock-sheet').click((event) => { diff --git a/module/actor.js b/module/actor.js index ce86f31..e648d41 100644 --- a/module/actor.js +++ b/module/actor.js @@ -171,8 +171,8 @@ export class SoSActor extends Actor { async wornObject( itemID) { let item = this.getOwnedItem(itemID); if (item && item.data.data) { - let update = { _id: item._id, "data.worn": !item.data.data.worn }; - await this.updateEmbeddedEntity("OwnedItem", update); + let update = { _id: item.id, "data.worn": !item.data.data.worn }; + await this.updateEmbeddedDocuments("Item", [update]); } } @@ -180,8 +180,8 @@ export class SoSActor extends Actor { async equipObject(itemID) { let item = this.getOwnedItem(itemID); if (item && item.data.data) { - let update = { _id: item._id, "data.equiped": !item.data.data.equiped }; - await this.updateEmbeddedEntity("OwnedItem", update); + let update = { _id: item.id, "data.equiped": !item.data.data.equiped }; + await this.updateEmbeddedDocuments("Item", [update]); } } @@ -222,16 +222,16 @@ export class SoSActor extends Actor { async updateSkill(skillName, value) { let skill = this.data.items.find( item => item.name == skillName); if (skill) { - const update = { _id: skill._id, 'data.value': value }; - const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity + const update = { _id: skill.id, 'data.value': value }; + const updated = await this.updateEmbeddedDocuments("Item", [ update] ); // Updates one EmbeddedEntity } } /* -------------------------------------------- */ async updateSkillExperience(skillName, value) { let skill = this.data.items.find( item => item.name == skillName); if (skill) { - const update = { _id: skill._id, 'data.xp': value }; - const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity + const update = { _id: skill.id, 'data.xp': value }; + const updated = await this.updateEmbeddedDocuments("Item", [update]); // Updates one EmbeddedEntity } } @@ -387,10 +387,10 @@ export class SoSActor extends Actor { if ( alreadyInside.length >= container.data.container ) { ui.notifications.warn("Container is already full !"); } else { - await this.updateOwnedItem( { _id: object._id, 'data.containerid':containerId }); + await this.updateOwnedItem( { _id: object.id, 'data.containerid':containerId }); } } else if ( object && object.data.containerid) { // remove from container - await this.updateOwnedItem( { _id: object._id, 'data.containerid':"" }); + await this.updateOwnedItem( { _id: object.id, 'data.containerid':"" }); } } @@ -416,7 +416,7 @@ export class SoSActor extends Actor { if ( sumWound >= this.data.data.scores.wound.value) { let bleeding = this.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding'); let newSeverity = SoSUtility.increaseConsequenceSeverity( bleeding.severity ); - await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity}); + await this.updateOwnedItem( { _id: bleeding.id, 'data.severity': newSeverity}); flipData.isBleeding = newSeverity; } // Stun consequence @@ -426,7 +426,7 @@ export class SoSActor extends Actor { for(i=0; i foundry.utils.deepClone(e.data)), + limited: this.object.limited, + options: this.options, + owner: this.document.isOwner + }; + + formData.isGM = game.user.isGM; + if ( objectData.type == 'skillexperience') { + formData.skillList = await SoSUtility.loadCompendiumNames("foundryvtt-shadows-over-sol.skills"); } - if ( data.item.type == 'skill' && this.object.options?.actor) { - data.skillExperienceList = this.object.options.actor.getSkillExperience( data.item.name ); + if ( objectData.type == 'skill' && this.object.options?.actor) { + formData.skillExperienceList = this.object.options.actor.getSkillExperience( data.item.name ); } - return data; + return formData; } /* -------------------------------------------- */ diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 1b441f9..b2d1ea9 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -130,8 +130,8 @@ {{else}} {{skill.name}} {{/if}} - - + +
              @@ -158,8 +158,8 @@ {{else}} {{skill.name}} {{/if}} - - + +
              @@ -182,16 +182,16 @@
              • Wounds :

              • Light : - +
              • Moderate : - +
              • Severe : - +
              • Critical : - +
              • Total : {{data.currentWounds}} / {{data.totalWounds}} @@ -204,8 +204,8 @@
              • {{conseq.name}} - + {{#select conseq.data.data.severity}} @@ -390,12 +390,12 @@

                Biography :

                - {{editor content=data.history target="data.history" button=true owner=owner editable=editable}} + {{editor content=data.data.history target="data.history" button=true owner=owner editable=editable}}

                Notes :

                - {{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}} + {{editor content=data.data.notes target="data.notes" button=true owner=owner editable=editable}}

                {{>"systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html"}} diff --git a/templates/item-consequence-sheet.html b/templates/item-consequence-sheet.html index 774bb95..d6cae1d 100644 --- a/templates/item-consequence-sheet.html +++ b/templates/item-consequence-sheet.html @@ -1,8 +1,8 @@
                - +
                -

                +

                @@ -13,8 +13,8 @@
                - + {{#select data.data.severity}} @@ -27,7 +27,7 @@
                - {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} + {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}}
                diff --git a/templates/item-skill-sheet.html b/templates/item-skill-sheet.html index 5061aa5..5e5f07e 100644 --- a/templates/item-skill-sheet.html +++ b/templates/item-skill-sheet.html @@ -1,8 +1,8 @@
                - +
                -

                +

                @@ -11,7 +11,7 @@
                  -
                • +
                  • Experiences list : @@ -27,7 +27,7 @@ {{/each}}
                  - {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} + {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}}
                From b93a29f7fc336772e2d9cd8f646810f1ab07323a Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 23 May 2021 00:03:37 +0200 Subject: [PATCH 04/12] Start 0.8 support --- module/actor-sheet.js | 8 ++++---- module/sos-card-deck.js | 2 +- templates/actor-sheet.html | 18 +++++++++--------- templates/item-armor-sheet.html | 7 +++++-- templates/item-commongear-sheet.html | 3 ++- templates/item-container-sheet.html | 6 +++--- templates/item-gear-sheet.html | 4 ++-- templates/item-geneline-sheet.html | 6 ++++-- templates/item-injury-sheet.html | 6 ++++-- templates/item-language-sheet.html | 6 +++--- templates/item-malady-sheet.html | 8 ++++---- templates/item-skillexperience-sheet.html | 7 ++++--- templates/item-subculture-sheet.html | 6 ++++-- templates/item-vehicle-sheet.html | 8 +++++--- templates/item-weakness-sheet.html | 6 ++++-- templates/item-weapon-sheet.html | 8 +++++--- 16 files changed, 63 insertions(+), 46 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index e69b79d..0537ef1 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -55,10 +55,10 @@ export class SoSActorSheet extends ActorSheet { if ( a.name > b.name ) return 1; return -1; }); - formData.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') ); + formData.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') ); // Build the gear tree - formData.gearsRoot = formData.gears.filter(item => item.data.containerid == ""); + formData.gearsRoot = formData.gears.filter(item => item.data.data.containerid == ""); for ( let container of formData.gearsRoot) { if ( container.type == 'container') { container.data.contains = [] @@ -134,12 +134,12 @@ export class SoSActorSheet extends ActorSheet { }); html.find('.skill-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); - const skill = this.actor.getOwnedItem(li.data("item-id")); + const skill = this.actor.get.items(li.data("item-id")); this.actor.rollSkill(skill); }); html.find('.weapon-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); - const weapon = this.actor.getOwnedItem(li.data("item-id")); + const weapon = this.actor.get.items(li.data("item-id")); this.actor.rollWeapon(weapon); }); html.find('.skill-value').change((event) => { diff --git a/module/sos-card-deck.js b/module/sos-card-deck.js index 3fef1ba..3f1f3a6 100644 --- a/module/sos-card-deck.js +++ b/module/sos-card-deck.js @@ -38,7 +38,7 @@ export class SoSCardDeck { this.cleanCardList(); // Randomize deck while (this.data.deck.length != NB_POKER_CARD) { - let idx = new Roll("1d54").roll().total; + let idx = new Roll("1d54").roll( {async:false} ).total; if (!this.data.cardState[idx - 1]) { if (idx == 53) { // Red Joker this.data.deck.push( { cardName: 'jr' } ); diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index b2d1ea9..326846b 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -227,7 +227,7 @@ {{!-- Gears Tab --}}
                -

                Total Encumbrance : {{totalEncumbrance}} / {{stats.strength.value}}

                +

                Total Encumbrance : {{totalEncumbrance}} / {{data.data.stats.strength.value}}

                Weapons

                Equipment/Gears

                  {{#each gearsRoot as |gear key|}}
                • - {{gear.name}} + {{gear.data.name}}
                  • - {{#each data.contains as |subgear key|}} + {{#each data.data.contains as |subgear key|}}
                  • - {{subgear.name}} + {{subgear.data.name}} diff --git a/templates/item-armor-sheet.html b/templates/item-armor-sheet.html index 3d26f84..556c6c0 100644 --- a/templates/item-armor-sheet.html +++ b/templates/item-armor-sheet.html @@ -1,14 +1,15 @@
                    - +
                    -

                    +

                    {{!-- Sheet Body --}}
                    + {{#with data}}
                    @@ -35,6 +36,8 @@
                    + {{/with}} + {{>"systems/foundryvtt-shadows-over-sol/templates/item-commongear-sheet.html"}}
                    diff --git a/templates/item-commongear-sheet.html b/templates/item-commongear-sheet.html index cc763b7..d122999 100644 --- a/templates/item-commongear-sheet.html +++ b/templates/item-commongear-sheet.html @@ -1,3 +1,4 @@ + {{#with data}}
                    @@ -48,4 +49,4 @@ {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
                - +{{/with}} diff --git a/templates/item-container-sheet.html b/templates/item-container-sheet.html index fd50779..9b7a727 100644 --- a/templates/item-container-sheet.html +++ b/templates/item-container-sheet.html @@ -1,8 +1,8 @@
                - +
                -

                +

                @@ -13,7 +13,7 @@
                - +
                {{>"systems/foundryvtt-shadows-over-sol/templates/item-commongear-sheet.html"}}
                diff --git a/templates/item-gear-sheet.html b/templates/item-gear-sheet.html index 8dd71f5..181a526 100644 --- a/templates/item-gear-sheet.html +++ b/templates/item-gear-sheet.html @@ -1,8 +1,8 @@
                - +
                -

                +

                diff --git a/templates/item-geneline-sheet.html b/templates/item-geneline-sheet.html index 900649c..22154cc 100644 --- a/templates/item-geneline-sheet.html +++ b/templates/item-geneline-sheet.html @@ -1,13 +1,14 @@
                - +
                -

                +

                {{!-- Sheet Body --}}
                + {{#with data}}
                @@ -35,6 +36,7 @@
              + {{/with}} diff --git a/templates/item-injury-sheet.html b/templates/item-injury-sheet.html index 4795cba..76ea621 100644 --- a/templates/item-injury-sheet.html +++ b/templates/item-injury-sheet.html @@ -1,13 +1,14 @@
              - +
              -

              +

              {{!-- Sheet Body --}}
              + {{#with data}}
              @@ -20,6 +21,7 @@
              + {{/with}} diff --git a/templates/item-language-sheet.html b/templates/item-language-sheet.html index 2049b1e..5bfc7b2 100644 --- a/templates/item-language-sheet.html +++ b/templates/item-language-sheet.html @@ -1,8 +1,8 @@
              - +
              -

              +

              @@ -13,7 +13,7 @@
              - {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} + {{editor content=data.ata.description target="data.description" button=true owner=owner editable=editable}}
            diff --git a/templates/item-malady-sheet.html b/templates/item-malady-sheet.html index 0ba4655..b826474 100644 --- a/templates/item-malady-sheet.html +++ b/templates/item-malady-sheet.html @@ -1,14 +1,14 @@
            - +
            -

            +

            {{!-- Sheet Body --}}
            - + {{#with data}}
            @@ -28,6 +28,6 @@
          - + {{/with}} diff --git a/templates/item-skillexperience-sheet.html b/templates/item-skillexperience-sheet.html index 8d8562d..fe3f1c2 100644 --- a/templates/item-skillexperience-sheet.html +++ b/templates/item-skillexperience-sheet.html @@ -1,14 +1,14 @@
          - +
          -

          +

          {{!-- Sheet Body --}}
          - + {{#with data}}
          @@ -29,6 +29,7 @@
          + {{/with}} diff --git a/templates/item-subculture-sheet.html b/templates/item-subculture-sheet.html index cbf062a..5b3b9fa 100644 --- a/templates/item-subculture-sheet.html +++ b/templates/item-subculture-sheet.html @@ -1,13 +1,14 @@
          - +
          -

          +

          {{!-- Sheet Body --}}
          + {{#with data}}
          @@ -23,6 +24,7 @@
        + {{/with}} diff --git a/templates/item-vehicle-sheet.html b/templates/item-vehicle-sheet.html index 24a6c7a..f0204d4 100644 --- a/templates/item-vehicle-sheet.html +++ b/templates/item-vehicle-sheet.html @@ -1,8 +1,8 @@
        - +
        -

        +

        @@ -10,7 +10,7 @@
        - + {{#with data}}
        @@ -35,6 +35,8 @@
        + {{/with}} + {{>"systems/foundryvtt-shadows-over-sol/templates/item-commongear-sheet.html"}}
        diff --git a/templates/item-weakness-sheet.html b/templates/item-weakness-sheet.html index f555679..53d6c61 100644 --- a/templates/item-weakness-sheet.html +++ b/templates/item-weakness-sheet.html @@ -1,13 +1,14 @@
        - +
        -

        +

        {{!-- Sheet Body --}}
        + {{#with data}}
        @@ -30,6 +31,7 @@
      + {{/with}} diff --git a/templates/item-weapon-sheet.html b/templates/item-weapon-sheet.html index 7fe7c14..408a90d 100644 --- a/templates/item-weapon-sheet.html +++ b/templates/item-weapon-sheet.html @@ -1,13 +1,14 @@
      - +
      -

      +

      {{!-- Sheet Body --}}
      + {{#with data}}
      @@ -82,7 +83,8 @@
      - + {{/with}} + {{>"systems/foundryvtt-shadows-over-sol/templates/item-commongear-sheet.html"}}
      From 5ceeefb52255e4a3a03ac97878c23338156b96b6 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 23 May 2021 11:45:50 +0200 Subject: [PATCH 05/12] Fix gears management" --- module/actor-sheet.js | 4 ++-- templates/actor-sheet.html | 2 +- templates/item-armor-sheet.html | 4 ++-- templates/item-commongear-sheet.html | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 0537ef1..cefbf9a 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -134,12 +134,12 @@ export class SoSActorSheet extends ActorSheet { }); html.find('.skill-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); - const skill = this.actor.get.items(li.data("item-id")); + const skill = this.actor.items.get(li.data("item-id")); this.actor.rollSkill(skill); }); html.find('.weapon-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); - const weapon = this.actor.get.items(li.data("item-id")); + const weapon = this.actor.items.get(li.data("item-id")); this.actor.rollWeapon(weapon); }); html.find('.skill-value').change((event) => { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 326846b..290a7d1 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -236,7 +236,7 @@ {{weapon.name}} diff --git a/templates/item-armor-sheet.html b/templates/item-armor-sheet.html index 556c6c0..49b68c2 100644 --- a/templates/item-armor-sheet.html +++ b/templates/item-armor-sheet.html @@ -1,8 +1,8 @@
      - +
      -

      +

      diff --git a/templates/item-commongear-sheet.html b/templates/item-commongear-sheet.html index d122999..09167c7 100644 --- a/templates/item-commongear-sheet.html +++ b/templates/item-commongear-sheet.html @@ -43,10 +43,11 @@
      + {{/with}} +
      - {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} + {{editor content=data.data.description target="data.description" button=true owner=owner editable=editable}}
      -{{/with}} From 142c22d85f8831628d24213cefe8094f6a655de3 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 24 May 2021 09:11:57 +0200 Subject: [PATCH 06/12] Syn for 0.8.0 --- module/actor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/module/actor.js b/module/actor.js index e648d41..0c9a287 100644 --- a/module/actor.js +++ b/module/actor.js @@ -415,18 +415,18 @@ export class SoSActor extends Actor { currentWounds.value = sumWound; if ( sumWound >= this.data.data.scores.wound.value) { let bleeding = this.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding'); - let newSeverity = SoSUtility.increaseConsequenceSeverity( bleeding.severity ); - await this.updateOwnedItem( { _id: bleeding.id, 'data.severity': newSeverity}); + let newSeverity = SoSUtility.increaseConsequenceSeverity( bleeding.data.severity ); + await this.updateEmbeddedDocuments( "Item", [ { _id: bleeding.id, 'data.severity': newSeverity} ] ); flipData.isBleeding = newSeverity; } // Stun consequence if ( flipData.nbStun > 0) { - let stun = this.data.items.find( item => item.type == 'consequence' && item.name == 'Sun'); - let newSeverity = stun.severity; - for(i=0; i item.type == 'consequence' && item.name == 'Stun'); + let newSeverity = stun.data.severity; + for(let i=0; i Date: Sat, 18 Dec 2021 09:49:29 +0100 Subject: [PATCH 07/12] v9 support --- styles/simple.css | 1 + system.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/styles/simple.css b/styles/simple.css index 5da1a63..fcedc08 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -812,6 +812,7 @@ ul, li { /* Sidebar CSS */ #sidebar { font-size: 1rem; + width: min-content; background: rgb(105,85,65) url("../img/ui/sidebar-bg.webp") no-repeat right bottom; background-position: 100%; color: rgba(19, 15, 15, 0.75); diff --git a/system.json b/system.json index c213547..a6bd771 100644 --- a/system.json +++ b/system.json @@ -7,9 +7,9 @@ "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", "license": "LICENSE.txt", "flags": {}, - "version": "2.0.0", + "version": "2.0.1", "minimumCoreVersion": "0.8.0", - "compatibleCoreVersion": "0.8.5", + "compatibleCoreVersion": "0.8.9", "scripts": [], "esmodules": [ "module/sos-main.js" From 6df412b1b30235ef85de21cd040b78275023d46e Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 18 Dec 2021 09:54:39 +0100 Subject: [PATCH 08/12] Sync --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index a6bd771..32869fc 100644 --- a/system.json +++ b/system.json @@ -7,9 +7,9 @@ "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", "license": "LICENSE.txt", "flags": {}, - "version": "2.0.1", + "version": "2.0.2", "minimumCoreVersion": "0.8.0", - "compatibleCoreVersion": "0.8.9", + "compatibleCoreVersion": "9", "scripts": [], "esmodules": [ "module/sos-main.js" From 07ea4477cdc50345f2957120b4ffa04fd5e502bb Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 29 Jan 2022 16:45:09 +0100 Subject: [PATCH 09/12] SoS : Minor v9 update --- module/sos-main.js | 25 +++++++++++++++++++++++-- system.json | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/module/sos-main.js b/module/sos-main.js index d33610a..bfb7df6 100644 --- a/module/sos-main.js +++ b/module/sos-main.js @@ -89,6 +89,28 @@ function welcomeMessage() { ` }); } +/* -------------------------------------------- */ +// Register world usage statistics +function registerUsageCount( registerKey ) { + if ( game.user.isGM ) { + game.settings.register(registerKey, "world-key", { + name: "Unique world key", + scope: "world", + config: false, + type: String + }); + + let worldKey = game.settings.get(registerKey, "world-key") + if ( worldKey == undefined || worldKey == "" ) { + worldKey = randomID(32) + game.settings.set(registerKey, "world-key", worldKey ) + } + // Simple API counter + $.ajax(`https://jdr.lahiette.com/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"`) + /* -------------------------------------------- */ + } +} + /* -------------------------------------------- */ /* Foundry VTT Initialization */ /* -------------------------------------------- */ @@ -102,9 +124,8 @@ Hooks.once("ready", function () { user: game.user._id }); } + registerUsageCount("foundryvtt-shadows-over-sol") - //gearConverter.importgear(); - welcomeMessage(); }); diff --git a/system.json b/system.json index 32869fc..3369b00 100644 --- a/system.json +++ b/system.json @@ -7,7 +7,7 @@ "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", "license": "LICENSE.txt", "flags": {}, - "version": "2.0.2", + "version": "2.0.3", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "9", "scripts": [], From e6089451338a9601ddb18704a447029cc8385014 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 19 Feb 2022 09:30:44 +0100 Subject: [PATCH 10/12] Use another server for measures --- module/sos-main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/sos-main.js b/module/sos-main.js index bfb7df6..b52a6bc 100644 --- a/module/sos-main.js +++ b/module/sos-main.js @@ -106,7 +106,8 @@ function registerUsageCount( registerKey ) { game.settings.set(registerKey, "world-key", worldKey ) } // Simple API counter - $.ajax(`https://jdr.lahiette.com/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"`) + let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"` + $.ajax(regURL) /* -------------------------------------------- */ } } From ae2d926324791cf92368948065d49855ed112978 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 5 Mar 2022 23:39:35 +0100 Subject: [PATCH 11/12] Fix gears and containers --- module/actor-sheet.js | 11 ++++++----- module/actor.js | 19 ++++++++++--------- module/sos-utility.js | 2 +- system.json | 2 +- templates/actor-sheet.html | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index cefbf9a..98c8ad6 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -63,11 +63,12 @@ export class SoSActorSheet extends ActorSheet { if ( container.type == 'container') { container.data.contains = [] container.data.containerEnc = 0; - for (let gear of data.data.gears) { - if ( gear.data.containerid == container.id) { - container.data.contains.push( gear ); - if ( !gear.data.neg && !gear.data.software ) { - container.data.containerEnc += (gear.big > 0) ? gear.big : 1; + for (let gear of formData.gears) { + console.log("GEAR", gear, container) + if ( gear.data.data.containerid == container.id) { + container.data.contains.push( gear ) + if ( !gear.data.data.neg && !gear.data.data.software ) { + container.data.containerEnc += (gear.data.data.big > 0) ? gear.data.data.big : 1; } } } diff --git a/module/actor.js b/module/actor.js index 0c9a287..d1a0d5e 100644 --- a/module/actor.js +++ b/module/actor.js @@ -169,7 +169,7 @@ export class SoSActor extends Actor { /* -------------------------------------------- */ async wornObject( itemID) { - let item = this.getOwnedItem(itemID); + let item = this.items.get(itemID); if (item && item.data.data) { let update = { _id: item.id, "data.worn": !item.data.data.worn }; await this.updateEmbeddedDocuments("Item", [update]); @@ -178,7 +178,7 @@ export class SoSActor extends Actor { /* -------------------------------------------- */ async equipObject(itemID) { - let item = this.getOwnedItem(itemID); + let item = this.items.get(itemID) if (item && item.data.data) { let update = { _id: item.id, "data.equiped": !item.data.data.equiped }; await this.updateEmbeddedDocuments("Item", [update]); @@ -376,21 +376,22 @@ export class SoSActor extends Actor { /* -------------------------------------------- */ async addObjectToContainer( itemId, containerId ) { - let container = this.data.items.find( item => item._id == containerId && item.type == 'container'); - let object = this.data.items.find( item => item._id == itemId ); + let container = this.data.items.find( item => item.id == containerId && item.type == 'container') + let object = this.data.items.find( item => item.id == itemId ) + //console.log("Found", container, object) if ( container ) { if ( object.type == 'container') { ui.notifications.warn("Only 1 level of container... sorry"); return } - let alreadyInside = this.data.items.filter( item => item.data.containerid && item.data.containerid == containerId); - if ( alreadyInside.length >= container.data.container ) { + let alreadyInside = this.data.items.filter( item => item.data.data.containerid && item.data.data.containerid == containerId); + if ( alreadyInside.length >= container.data.data.container ) { ui.notifications.warn("Container is already full !"); } else { - await this.updateOwnedItem( { _id: object.id, 'data.containerid':containerId }); + await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'data.containerid':containerId }]); } - } else if ( object && object.data.containerid) { // remove from container - await this.updateOwnedItem( { _id: object.id, 'data.containerid':"" }); + } else if ( object && object.data.data.containerid) { // remove from container + await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'data.containerid':"" }]); } } diff --git a/module/sos-utility.js b/module/sos-utility.js index d1ccefb..89eadb9 100644 --- a/module/sos-utility.js +++ b/module/sos-utility.js @@ -256,7 +256,7 @@ export class SoSUtility { label: "Yes, delete it", callback: () => { console.log("Delete : ", itemId); - actorSheet.actor.deleteOwnedItem(itemId); + actorSheet.actor.deleteEmbeddedDocuments("Item", [itemId]); li.slideUp(200, () => actorSheet.render(false)); } }, diff --git a/system.json b/system.json index 3369b00..c683147 100644 --- a/system.json +++ b/system.json @@ -7,7 +7,7 @@ "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", "license": "LICENSE.txt", "flags": {}, - "version": "2.0.3", + "version": "2.0.4", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "9", "scripts": [], diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 290a7d1..8099bcd 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -270,7 +270,7 @@
    • - {{#each data.data.contains as |subgear key|}} + {{#each data.contains as |subgear key|}}
    • {{subgear.data.name}} From 633525a9e56be1fb2f8270c6902b822dde1e61bd Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 18 Mar 2022 19:30:18 +0100 Subject: [PATCH 12/12] Fix reset deck in Foundry v9 #9 --- module/actor.js | 2 +- module/sos-card-deck.js | 23 ++++++++++++----------- system.json | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/module/actor.js b/module/actor.js index d1a0d5e..fc3e5d1 100644 --- a/module/actor.js +++ b/module/actor.js @@ -378,7 +378,7 @@ export class SoSActor extends Actor { async addObjectToContainer( itemId, containerId ) { let container = this.data.items.find( item => item.id == containerId && item.type == 'container') let object = this.data.items.find( item => item.id == itemId ) - //console.log("Found", container, object) + console.log("Found", container, object) if ( container ) { if ( object.type == 'container') { ui.notifications.warn("Only 1 level of container... sorry"); diff --git a/module/sos-card-deck.js b/module/sos-card-deck.js index 3f1f3a6..756979f 100644 --- a/module/sos-card-deck.js +++ b/module/sos-card-deck.js @@ -58,21 +58,22 @@ export class SoSCardDeck { /* -------------------------------------------- */ resetDeck() { - let newdeck = duplicate(this.data.deck).concat( duplicate (this.data.discard)); - this.data.discard = []; // Reinit discard pile - this.data.deck = []; - let decklen = newdeck.length; - let cardState = []; + let newdeck = duplicate(this.data.deck).concat( duplicate (this.data.discard) ) + this.data.discard = [] // Reinit discard pile + this.data.deck = [] + let decklen = newdeck.length + let cardState = [] for (let i = 0; i