diff --git a/modules/crucible-actor-sheet.js b/modules/crucible-actor-sheet.js index afecd48..2ffefc9 100644 --- a/modules/crucible-actor-sheet.js +++ b/modules/crucible-actor-sheet.js @@ -119,7 +119,6 @@ export class CrucibleActorSheet extends ActorSheet { let actorId = li.data("actor-id"); this.actor.delSubActor(actorId); }); - html.find('.quantity-minus').click(event => { const li = $(event.currentTarget).parents(".item"); this.actor.incDecQuantity( li.data("item-id"), -1 ); @@ -143,10 +142,11 @@ export class CrucibleActorSheet extends ActorSheet { this.actor.rollAbility(abilityKey); }); html.find('.roll-skill').click((event) => { - const li = $(event.currentTarget).parents(".item"); + const li = $(event.currentTarget).parents(".item") const skillId = li.data("item-id") this.actor.rollSkill(skillId) - }); + }); + html.find('.roll-weapon').click((event) => { const li = $(event.currentTarget).parents(".item"); const skillId = li.data("item-id") diff --git a/modules/crucible-npc-sheet.js b/modules/crucible-npc-sheet.js index 0feb10a..1b22f8e 100644 --- a/modules/crucible-npc-sheet.js +++ b/modules/crucible-npc-sheet.js @@ -24,24 +24,37 @@ export class CrucibleNPCSheet extends ActorSheet { /* -------------------------------------------- */ async getData() { - const objectData = CrucibleUtility.data(this.object); - - this.actor.prepareTraitsAttributes(); - let actorData = duplicate(CrucibleUtility.templateData(this.object)); + const objectData = this.object.system + let actorData = duplicate(objectData) let formData = { title: this.title, - id: objectData.id, - type: objectData.type, - img: objectData.img, - name: objectData.name, + id: this.actor.id, + type: this.actor.type, + img: this.actor.img, + name: this.actor.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", data: actorData, - effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, - equipments: this.actor.getEquipments(), - weapons: this.actor.getWeapons(), + skills: this.actor.getSkills( ), + weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ), + armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())), + shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())), + spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getLore())), + equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ), + equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ), + equippedArmor: this.actor.getEquippedArmor(), + equippedShield: this.actor.getEquippedShield(), + feats: duplicate(this.actor.getFeats()), + subActors: duplicate(this.actor.getSubActors()), + race: duplicate(this.actor.getRace()), + moneys: duplicate(this.actor.getMoneys()), + encCapacity: this.actor.getEncumbranceCapacity(), + saveRolls: this.actor.getSaveRoll(), + conditions: this.actor.getConditions(), + containersTree: this.actor.containersTree, + encCurrent: this.actor.encCurrent, options: this.options, owner: this.document.isOwner, editScore: this.options.editScore, @@ -49,7 +62,7 @@ export class CrucibleNPCSheet extends ActorSheet { } this.formData = formData; - console.log("NPC : ", formData, this.object); + console.log("PC : ", formData, this.object); return formData; } @@ -60,43 +73,97 @@ export class CrucibleNPCSheet extends ActorSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; + + html.bind("keydown", function(e) { // Ignore Enter in actores sheet + if (e.keyCode === 13) return false; + }); // Update Inventory Item html.find('.item-edit').click(ev => { - const li = $(ev.currentTarget).parents(".item"); - let itemId = li.data("item-id"); + const li = $(ev.currentTarget).parents(".item") + let itemId = li.data("item-id") const item = this.actor.items.get( itemId ); item.sheet.render(true); }); // Delete Inventory Item html.find('.item-delete').click(ev => { - const li = $(ev.currentTarget).parents(".item"); - FraggedKingdomUtility.confirmDelete(this, li); - }); + const li = $(ev.currentTarget).parents(".item") + CrucibleUtility.confirmDelete(this, li) + }) + html.find('.item-add').click(ev => { + let dataType = $(ev.currentTarget).data("type") + this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true }) + }) + + html.find('.equip-activate').click(ev => { + const li = $(ev.currentTarget).parents(".item") + let itemId = li.data("item-id") + this.actor.equipActivate( itemId) + }); + html.find('.equip-deactivate').click(ev => { + const li = $(ev.currentTarget).parents(".item") + let itemId = li.data("item-id") + this.actor.equipDeactivate( itemId) + }); - html.find('.trait-link').click((event) => { - const itemId = $(event.currentTarget).data("item-id"); - const item = this.actor.getOwnedItem(itemId); - item.sheet.render(true); - }); - - html.find('.competence-label a').click((event) => { - const li = $(event.currentTarget).parents(".item"); - const competenceId = li.data("item-id"); - this.actor.rollSkill(competenceId); + html.find('.subactor-edit').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + let actorId = li.data("actor-id"); + let actor = game.actors.get( actorId ); + actor.sheet.render(true); }); - html.find('.weapon-label a').click((event) => { + + html.find('.subactor-delete').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + let actorId = li.data("actor-id"); + this.actor.delSubActor(actorId); + }); + html.find('.quantity-minus').click(event => { const li = $(event.currentTarget).parents(".item"); - const armeId = li.data("item-id"); - const statId = li.data("stat-id"); - this.actor.rollWeapon(armeId, statId); + this.actor.incDecQuantity( li.data("item-id"), -1 ); + } ); + html.find('.quantity-plus').click(event => { + const li = $(event.currentTarget).parents(".item"); + this.actor.incDecQuantity( li.data("item-id"), +1 ); + } ); + + html.find('.ammo-minus').click(event => { + const li = $(event.currentTarget).parents(".item") + this.actor.incDecAmmo( li.data("item-id"), -1 ); + } ); + html.find('.ammo-plus').click(event => { + const li = $(event.currentTarget).parents(".item") + this.actor.incDecAmmo( li.data("item-id"), +1 ) + } ); + + html.find('.roll-ability').click((event) => { + const abilityKey = $(event.currentTarget).data("ability-key"); + this.actor.rollAbility(abilityKey); + }); + html.find('.roll-skill').click((event) => { + const li = $(event.currentTarget).parents(".item") + const skillId = li.data("item-id") + this.actor.rollSkill(skillId) }); - html.find('.npc-fight-roll').click((event) => { - this.actor.rollNPCFight(); - }); - html.find('.npc-skill-roll').click((event) => { - this.actor.rollGenericSkill(); - }); + + html.find('.roll-weapon').click((event) => { + const li = $(event.currentTarget).parents(".item"); + const skillId = li.data("item-id") + this.actor.rollWeapon(skillId) + }); + html.find('.roll-armor-die').click((event) => { + this.actor.rollArmorDie() + }); + html.find('.roll-shield-die').click((event) => { + this.actor.rollShieldDie() + }); + + html.find('.roll-save').click((event) => { + const saveKey = $(event.currentTarget).data("save-key") + this.actor.rollSave(saveKey) + }); + + html.find('.lock-unlock-sheet').click((event) => { this.options.editScore = !this.options.editScore; this.render(true); @@ -109,9 +176,15 @@ export class CrucibleNPCSheet extends ActorSheet { html.find('.item-equip').click(ev => { const li = $(ev.currentTarget).parents(".item"); this.actor.equipItem( li.data("item-id") ); - this.render(true); + this.render(true); }); + html.find('.update-field').change(ev => { + const fieldName = $(ev.currentTarget).data("field-name"); + let value = Number(ev.currentTarget.value); + this.actor.update( { [`${fieldName}`]: value } ); + }); + } /* -------------------------------------------- */ diff --git a/system.json b/system.json index 3dcc8de..34d7d93 100644 --- a/system.json +++ b/system.json @@ -199,7 +199,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.7", + "version": "10.0.8", "compatibility": { "minimum": "10", "verified": "10.279", @@ -207,7 +207,7 @@ }, "title": "Crucible RPG", "manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v10.0.7.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v10.0.8.zip", "url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg", "background": "images/ui/crucible_welcome_page.webp", "id": "fvtt-crucible-rpg" diff --git a/template.json b/template.json index 2bb3efd..88d86a4 100644 --- a/template.json +++ b/template.json @@ -98,7 +98,7 @@ "templates": [ "biodata", "core" ] }, "npc": { - "templates": [ "npccore" ] + "templates": [ "biodata", "core" ] } }, "Item": { diff --git a/templates/npc-sheet.html b/templates/npc-sheet.html index 6bfa5f1..970aeca 100644 --- a/templates/npc-sheet.html +++ b/templates/npc-sheet.html @@ -1,184 +1,465 @@