diff --git a/src/main.mjs b/src/main.mjs index 3ea748a5..1db263e8 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -21,6 +21,7 @@ async function preloadHandlebarsTemplates() { 'systems/DSA_4-1/templates/ui/partial-die.hbs', 'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs', 'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs', + 'systems/DSA_4-1/templates/ui/partial-equipment-group-button.hbs', 'systems/DSA_4-1/templates/ui/partial-array-editor.hbs' ]); } diff --git a/src/module/data/character.mjs b/src/module/data/character.mjs index ed203d49..bbe64078 100644 --- a/src/module/data/character.mjs +++ b/src/module/data/character.mjs @@ -132,12 +132,22 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { notiz: new StringField(), })), - heldenausruestung: new SchemaField({ - links: new DocumentIdField(), - rechts: new DocumentIdField(), - ruestung: new DocumentIdField(), - munition: new DocumentIdField() - }) + heldenausruestung: new ArrayField( + new SchemaField({ + links: new DocumentIdField(), + rechts: new DocumentIdField(), + brust: new DocumentIdField(), + ruecken: new DocumentIdField(), + kopf: new DocumentIdField(), + fernkampf: new DocumentIdField(), + munition: new DocumentIdField(), + armlinks: new DocumentIdField(), + armrechts: new DocumentIdField(), + bauch: new DocumentIdField(), + beinlinks: new DocumentIdField(), + beinrechts: new DocumentIdField(), + }), {min: 0, max: 3} + ) } } @@ -145,9 +155,52 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { super._initialize(options); } - async _onCreate(data, options, userId) { + _initializeSource(data, options) { + + if (data.heldenausruestung.length === 0) { + let sets = []; + + for (let i = 0; i < 3; i++) { + + const preppedSet = {} + + PlayerCharacterDataModel.getSlots().forEach(slot => { + preppedSet[slot] = null; + }) + + sets.push(preppedSet); + + } + data.heldenausruestung = sets + + } + + console.log(data) + return super._initializeSource(data, options); + } + + async _onCreate(data, options, userId) { + + } + + static getSlots() { + return [ + "links", + "rechts", + "brust", + "ruecken", + "kopf", + "fernkampf", + "munition", + "armlinks", + "armrechts", + "bauch", + "beinlinks", + "beinrechts", + + ] } } diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index bcd71d4e..149c0db9 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -1,3 +1,6 @@ +import {Character} from "../documents/character.mjs"; +import {PlayerCharacterDataModel} from "../data/character.mjs"; + export class CharacterSheet extends ActorSheet { /**@override */ static get defaultOptions() { @@ -153,6 +156,20 @@ export class CharacterSheet extends ActorSheet { } + #isWorn(itemId, setId) { + + const slots = PlayerCharacterDataModel.getSlots() + const set = this.object.system.heldenausruestung[setId] + for ( const slot of slots) { + const equipmentSlotId = set[slot] + if (equipmentSlotId === itemId) { + return slot + } + } + + return false + } + #addEquipmentsToContext(context) { context.equipments = []; const actorData = context.data; @@ -164,6 +181,9 @@ export class CharacterSheet extends ActorSheet { id: item._id, quantity: item.system.quantity, name: item.name, + icon: item.img ?? "", + weight: item.system.weight ?? 0, + worn: this.#isWorn(item._id, 0) }) context.carryingweight += item.system.quantity * item.system.weight; } @@ -171,27 +191,90 @@ export class CharacterSheet extends ActorSheet { context.maxcarryingcapacity = actorData.system.attribute.kk.aktuell context.carryingpercentage = Math.min((context.carryingweight / context.maxcarryingcapacity)*100, 100); - context.heldenausruestung = { - links: { - id: this.object.system.heldenausruestung.links, - name: this.object.items.get(actorData.system.heldenausruestung.links)?.name, - icon: this.object.items.get(actorData.system.heldenausruestung.links)?.img - }, - rechts: { - id: this.object.system.heldenausruestung.rechts, - name: this.object.items.get(actorData.system.heldenausruestung.rechts)?.name, - icon: this.object.items.get(actorData.system.heldenausruestung.rechts)?.img - }, - ruestung: { - id: this.object.system.heldenausruestung.ruestung, - name: this.object.items.get(actorData.system.heldenausruestung.ruestung)?.name, - icon: this.object.items.get(actorData.system.heldenausruestung.ruestung)?.img - }, - munition: { - id: this.object.system.heldenausruestung.munition, - name: this.object.items.get(actorData.system.heldenausruestung.munition)?.name, - icon: this.object.items.get(actorData.system.heldenausruestung.munition)?.img - } + const maxSets = 3 + const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"] + context.sets = [] + for (let setIndex = 0; setIndex { this._onAttributeRoll(evt); }); @@ -355,52 +441,36 @@ export class CharacterSheet extends ActorSheet { }) html.on('dragstart', '.equipment', (evt) => { - evt.originalEvent.dataTransfer.setData("text/plain", evt.currentTarget.dataset.id); + evt.originalEvent.dataTransfer.setData("application/json", JSON.stringify({ + documentId: evt.currentTarget.dataset.id + })); }) html.on('drop', '.equipped', async (evt) => { - const {actor, target} = evt.currentTarget.dataset; - const documentId = evt.originalEvent.dataTransfer.getData("text"); + const {actor, target, setId} = evt.currentTarget.dataset; + const {documentId} = JSON.parse(evt.originalEvent.dataTransfer.getData("application/json")); + if (actor === this.object._id && documentId) { // managing equipped items - switch(target) { - case "links": - this.object.update({ - system: { - heldenausruestung: { - links: documentId - } - } - }) - break; - case "rechts": - this.object.update({ - system: { - heldenausruestung: { - rechts: documentId - } - } - }) - break; - case "ruestung": - this.object.update({ - system: { - heldenausruestung: { - ruestung: documentId - } - } - }) - break; - case "munition": - this.object.update({ - system: { - heldenausruestung: { - munition: documentId - } - } - }) - break; - } + //const slot = this.#isWorn(documentId, setId) + const equipmentSet = this.object.system.heldenausruestung[setId] + const updateObject = {} + updateObject[`system.heldenausruestung.${setId}.links`] = equipmentSet.links; + updateObject[`system.heldenausruestung.${setId}.rechts`] = equipmentSet.rechts; + updateObject[`system.heldenausruestung.${setId}.brust`] = equipmentSet.brust; + updateObject[`system.heldenausruestung.${setId}.ruecken`] = equipmentSet.ruecken; + updateObject[`system.heldenausruestung.${setId}.kopf`] = equipmentSet.kopf; + updateObject[`system.heldenausruestung.${setId}.fernkampf`] = equipmentSet.fernkampf; + updateObject[`system.heldenausruestung.${setId}.munition`] = equipmentSet.munition; + updateObject[`system.heldenausruestung.${setId}.armlinks`] = equipmentSet.armlinks; + updateObject[`system.heldenausruestung.${setId}.armrechts`] = equipmentSet.armrechts; + updateObject[`system.heldenausruestung.${setId}.beinlinks`] = equipmentSet.beinlinks; + updateObject[`system.heldenausruestung.${setId}.beinrechts`] = equipmentSet.beinrechts; + + updateObject[`system.heldenausruestung.${setId}.${target}`] = documentId; + console.log(updateObject); + + await this.object.update(updateObject); } evt.stopPropagation(); @@ -442,6 +512,7 @@ export class CharacterSheet extends ActorSheet { name: "Aus dem Inventar entfernen", icon: '', callback: (event) => { + // TODO find id on heldenausruestung to remove the worn items as well this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id]) }, condition: () => true diff --git a/src/module/sheets/groupSheet.mjs b/src/module/sheets/groupSheet.mjs index 6be64bcc..5db59065 100644 --- a/src/module/sheets/groupSheet.mjs +++ b/src/module/sheets/groupSheet.mjs @@ -76,6 +76,7 @@ export class GroupSheet extends ActorSheet { id: item._id, quantity: item.system.quantity, name: item.name, + icon: item.img }) } }) diff --git a/src/packs/__source/waffen/spitzhacke.json b/src/packs/__source/waffen/spitzhacke.json index e10cd3c0..1409d362 100644 --- a/src/packs/__source/waffen/spitzhacke.json +++ b/src/packs/__source/waffen/spitzhacke.json @@ -2,7 +2,7 @@ "_id": "MeGrzCf8ljnWPq7U", "_key": "!items!MeGrzCf8ljnWPq7U", "type": "Equipment", - "img": "systems/DSA_4-1/assets/arsenal/hammer1.png", + "img": "systems/DSA_4-1/assets/arsenal/pickaxe.png", "name": "Spitzhacke", "system": { "name": "Spitzhacke", @@ -31,4 +31,4 @@ "armorHandicap": 0, "description": "" } -} \ No newline at end of file +} diff --git a/src/packs/_source/waffen/spitzhacke.json b/src/packs/_source/waffen/spitzhacke.json index 2347e3c2..aaad28b3 100644 --- a/src/packs/_source/waffen/spitzhacke.json +++ b/src/packs/_source/waffen/spitzhacke.json @@ -1,6 +1,6 @@ { "name": "Spitzhacke", - "image": "systems/DSA_4-1/assets/arsenal/hammer1.png", + "image": "systems/DSA_4-1/assets/arsenal/pickaxe.png", "category": ["Gegenstand", "Nahkampfwaffe"], "weight": 5, "price": 20, @@ -25,4 +25,4 @@ "armorHandicap": 0, "description": "" -} \ No newline at end of file +} diff --git a/src/style/_character-sheet.scss b/src/style/_character-sheet.scss index 34a39fec..4870454e 100644 --- a/src/style/_character-sheet.scss +++ b/src/style/_character-sheet.scss @@ -53,16 +53,12 @@ } .backpack.active { - position: relative; - left: 0; - top: 0; - bottom: 0; - right: 0; padding: 8px; display: grid; - grid-template-columns: 1fr 280px; + grid-template-columns: 1fr 320px; grid-template-rows: 64px 1fr; - gap: 0px 0px; + gap: 10px; + height: 100%; grid-template-areas: "capacity capacity" "inventory equipment"; @@ -98,51 +94,7 @@ } } } - - .paperdoll { - - grid-area: equipment; - position: relative; - - .paperdoll-image { - fill: rgba(0,0,0,0.5); - } - - .equipped { - - background-color: rgba(0,0,0,0.2); - - border: 1px inset #ccc; - width: 34px; - height: 34px; - - &.links { - position: absolute; - top: 230px; - left: 250px; - } - - &.rechts { - position: absolute; - top: 230px; - left: 20px; - } - - &.ruestung { - position: absolute; - top: 180px; - left: 130px; - } - - &.munition { - position: absolute; - top: 270px; - left: 20px; - } - } - - } - } +} } diff --git a/src/style/_paperdoll.scss b/src/style/_paperdoll.scss new file mode 100644 index 00000000..156d63bf --- /dev/null +++ b/src/style/_paperdoll.scss @@ -0,0 +1,124 @@ +.dsa41.sheet.actor.character .window-content { + .sheet-tabs.paperdoll-tabs.tabs { + + position: absolute; + top: 30px; + left: 0; + right: 0; + height: 26px; + + .item.active[data-tab] { + padding-left: 12px; + padding-right: 12px; + padding-top: 8px; + padding-bottom: 3px; + + } + } + + .sheet-body.paperdoll-sets { + left: 0; + top: 55px; + bottom: 0; + right: 0; + overflow: hidden; + + div.tab { + overflow: hidden; + } + + } + + .paperdoll { + + grid-area: equipment; + position: relative; + + .paperdoll-image { + fill: rgba(0, 0, 0, 0.5); + } + + .equipped { + + background-color: rgba(0, 0, 0, 0.2); + + border: 1px inset #ccc; + width: 34px; + height: 34px; + + &.links { + position: absolute; + top: 230px; + left: 250px; + } + + &.rechts { + position: absolute; + top: 230px; + left: 20px; + } + + &.brust { + position: absolute; + top: 120px; + left: 110px; + } + + &.armlinks { + position: absolute; + top: 180px; + left: 210px; + } + + &.armrechts { + position: absolute; + top: 180px; + left: 60px; + } + + &.beinlinks { + position: absolute; + top: 380px; + left: 210px; + } + + &.beinrechts { + position: absolute; + top: 380px; + left: 60px; + } + + &.bauch { + position: absolute; + top: 200px; + left: 136px; + } + + &.kopf { + position: absolute; + top: 40px; + left: 136px + } + + &.fernkampf { + position: absolute; + top: 40px; + left: 240px; + } + + &.ruecken { + position: absolute; + top: 120px; + left: 160px; + } + + &.munition { + position: absolute; + top: 80px; + left: 240px; + } + } + + } + +} diff --git a/src/style/styles.scss b/src/style/styles.scss index ce171464..0810ee93 100644 --- a/src/style/styles.scss +++ b/src/style/styles.scss @@ -6,3 +6,4 @@ @use "_group-sheet"; @use "_tabs"; @use "_equipment-sheet"; +@use "_paperdoll"; diff --git a/src/templates/actor/actor-character-sheet.hbs b/src/templates/actor/actor-character-sheet.hbs index 33795879..e8bca370 100644 --- a/src/templates/actor/actor-character-sheet.hbs +++ b/src/templates/actor/actor-character-sheet.hbs @@ -22,10 +22,16 @@ - + - - + + @@ -50,20 +56,21 @@ -
+
+ value="{{system.meta.profession}}"/>
+ value="{{system.meta.geschlecht}}"/>
@@ -71,77 +78,77 @@
-
-

Körperliche Talente

-
    -
  • - {{#each skills.Körperlich}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} -
-
-
-

Gesellschaftliche Talente

-
    -
  • - {{#each skills.Gesellschaft}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} -
-
-
-

Natur Talente

-
    -
  • - {{#each skills.Natur}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} -
-
-
-

Wissenstalente

-
    -
  • - {{#each skills.Wissen}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} -
-
-
-

Schriften & Sprachen

-
    -
  • - {{#each skills.Schriften}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} - {{#each skills.Schriften}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} -
-
-
-

Handwerkliche Talente

-
    -
  • - {{#each skills.Handwerk}} -
  • - {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} -
  • - {{/each}} -
-
+
+

Körperliche Talente

+
    +
  • + {{#each skills.Körperlich}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} +
+
+
+

Gesellschaftliche Talente

+
    +
  • + {{#each skills.Gesellschaft}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} +
+
+
+

Natur Talente

+
    +
  • + {{#each skills.Natur}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} +
+
+
+

Wissenstalente

+
    +
  • + {{#each skills.Wissen}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} +
+
+
+

Schriften & Sprachen

+
    +
  • + {{#each skills.Schriften}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} + {{#each skills.Schriften}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} +
+
+
+

Handwerkliche Talente

+
    +
  • + {{#each skills.Handwerk}} +
  • + {{> "systems/DSA_4-1/templates/ui/partial-rollable-button.hbs" this}} +
  • + {{/each}} +
+
@@ -154,31 +161,47 @@
-

Inventar

- {{#each equipments}} - {{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" this}} - {{/each}} + + {{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" equipments}} +

Ausrüstung

-
- - + {{!-- Set Tab Navigation --}} + + {{!-- Set Body --}} +
+ {{#each this.sets}} +
- - - - +
+ + + -
+ {{#each this.slots}} +
+ {{/each}} + + +
+
+ {{/each}} + +
diff --git a/src/templates/actor/group-sheet.hbs b/src/templates/actor/group-sheet.hbs index cea13336..c8382212 100644 --- a/src/templates/actor/group-sheet.hbs +++ b/src/templates/actor/group-sheet.hbs @@ -68,11 +68,7 @@ {{/if}}
- + {{> 'systems/DSA_4-1/templates/ui/partial-equipment-group-button.hbs' equipments}}
diff --git a/src/templates/ui/partial-equipment-button.hbs b/src/templates/ui/partial-equipment-button.hbs index 66f3b77a..f0cc39dd 100644 --- a/src/templates/ui/partial-equipment-button.hbs +++ b/src/templates/ui/partial-equipment-button.hbs @@ -1,4 +1,22 @@ -
- {{this.quantity}} - {{this.name}} -
+ + + + + + + + + + + + +{{#each this}} + + + + + + +{{/each}} + +
AnzahlGewicht
{{this.name}}{{this.quantity}}{{this.weight}}
diff --git a/src/templates/ui/partial-equipment-group-button.hbs b/src/templates/ui/partial-equipment-group-button.hbs new file mode 100644 index 00000000..f0cc39dd --- /dev/null +++ b/src/templates/ui/partial-equipment-group-button.hbs @@ -0,0 +1,22 @@ + + + + + + + + + + + + +{{#each this}} + + + + + + +{{/each}} + +
AnzahlGewicht
{{this.name}}{{this.quantity}}{{this.weight}}