Compare commits

..

2 Commits

Author SHA1 Message Date
macniel fca38ec507 fixes tab alignment 2025-10-27 15:42:43 +01:00
macniel 6b64b0b6db adds reverse inventory mechanic with "zusammenlegen" 2025-10-27 15:42:31 +01:00
8 changed files with 48 additions and 65 deletions

View File

@ -97,7 +97,6 @@ Hooks.once("init", () => {
movementActions.climb.canSelect = (token) => { movementActions.climb.canSelect = (token) => {
const actor = token.actor | null; const actor = token.actor | null;
console.log
return (actor.type === "Character" && actor.system.itemTypes["Skill"].find(p => p.name === "Klettern")?.system.taw > 0) || actor.type === "Creature" return (actor.type === "Character" && actor.system.itemTypes["Skill"].find(p => p.name === "Klettern")?.system.taw > 0) || actor.type === "Creature"
} }

View File

@ -14,7 +14,7 @@ export default {
context.equipments = [] context.equipments = []
context.carryingweight = 0 context.carryingweight = 0
actorData.itemTypes.Equipment.forEach((item, index) => { actorData.itemTypes["Equipment"].sort((a, b) => a.sort - b.sort).forEach((item, index) => {
// worn items are halved weight // worn items are halved weight
@ -41,13 +41,10 @@ export default {
context.wealth = 0 context.wealth = 0
actorData.itemTypes["Equipment"].forEach(coin => { actorData.itemTypes["Equipment"].forEach(coin => {
console.log(coin.name, coin.system.category)
if (coin.system.category.indexOf("Währung") !== -1) { if (coin.system.category.indexOf("Währung") !== -1) {
console.log(context.wealth, coin)
context.wealth += (coin.system.quantity * coin.system.currencyDenominator) context.wealth += (coin.system.quantity * coin.system.currencyDenominator)
} }
}) })
console.log(context.wealth)
const maxSets = 3 const maxSets = 3
const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"] const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]

View File

@ -491,15 +491,13 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
} }
// TODO needs to be fixed once Character Sheet is migrated to ActorSheetV2
async _onDrop(event) { async _onDrop(event) {
const data = TextEditor.implementation.getDragEventData(event); const data = TextEditor.implementation.getDragEventData(event);
const actor = this.actor; const actor = this.actor;
const targetDocument = this.actor.itemTypes["Equipment"].find(p => p._id === event.target.dataset['itemId'])
//const allowed = Hooks.call("dropActorSheetData", actor, this, data); //const allowed = Hooks.call("dropActorSheetData", actor, this, data);
//if (allowed === false) return; //if (allowed === false) return;
console.log("looted or dropped", data)
// Dropped Documents // Dropped Documents
const documentClass = foundry.utils.getDocumentClass(data.type); const documentClass = foundry.utils.getDocumentClass(data.type);
if (documentClass) { if (documentClass) {
@ -507,11 +505,27 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
if (document.type === "Equipment" || document.type === "Advantage" || document.type === "Spell" || document.type === "Liturgy" || document.type === "ActiveEffect" || document.type === "SpecialAbility") { if (document.type === "Equipment" || document.type === "Advantage" || document.type === "Spell" || document.type === "Liturgy" || document.type === "ActiveEffect" || document.type === "SpecialAbility") {
// No duplication by moving items from one actor to another // No duplication by moving items from one actor to another
if (document.parent && document.parent !== this.actor) {
document.parent.items.get(document._id).delete()
}
await this._onDropDocument(event, document); if ((targetDocument?.name ?? false) === document.name && targetDocument._id !== document._id && await foundry.applications.api.DialogV2.confirm({
content: `<span>Gegenstände der Art <strong>${document.name}</strong> (Neue Anzahl: ${targetDocument.system.quantity + document.system.quantity}) zusammenlegen?</span>`,
rejectClose: false,
modal: true,
window: {
title: `Gegenstände zusammenlegen`
}
})) {
// combine
await targetDocument.update({"system.quantity": targetDocument.system.quantity + document.system.quantity})
await this.actor.deleteEmbeddedDocuments('Item', [document._id])
return false
} else {
if (document.parent && document.parent !== this.actor) {
document.parent.items.get(document._id).delete()
}
await this._onDropDocument(event, document)
}
} }
} }
} }

View File

@ -14,6 +14,7 @@ export class CreatureSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
handler: CreatureSheet.#onSubmitForm handler: CreatureSheet.#onSubmitForm
}, },
actions: { actions: {
openEmbeddedDocument: CreatureSheet.#openEmbeddedDocument,
removeAttack: CreatureSheet.#removeAttack, removeAttack: CreatureSheet.#removeAttack,
addAttack: CreatureSheet.#addAttack, addAttack: CreatureSheet.#addAttack,
roll: CreatureSheet.#dieRoll, roll: CreatureSheet.#dieRoll,
@ -82,6 +83,12 @@ export class CreatureSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
await this.document.update(formData.object) // Note: formData.object await this.document.update(formData.object) // Note: formData.object
} }
static #openEmbeddedDocument(event, target) {
const dataset = target.dataset
const id = dataset.itemId ?? dataset.id
this.document.items.get(id).sheet.render(true)
}
static async #removeAttack(evt) { static async #removeAttack(evt) {
const {index} = evt.srcElement.dataset; const {index} = evt.srcElement.dataset;
let sans = Array.from(this.document.system.attacks); let sans = Array.from(this.document.system.attacks);
@ -182,7 +189,6 @@ export class CreatureSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
const actor = this.actor; const actor = this.actor;
//const allowed = Hooks.call("dropActorSheetData", actor, this, data); //const allowed = Hooks.call("dropActorSheetData", actor, this, data);
// if (allowed === false) return; // if (allowed === false) return;
console.log("dropped")
// Dropped Documents // Dropped Documents
const documentClass = foundry.utils.getDocumentClass(data.type); const documentClass = foundry.utils.getDocumentClass(data.type);
if (documentClass) { if (documentClass) {

View File

@ -68,9 +68,6 @@ export class MerchantSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
*/ */
static async #onSubmitForm(event, form, formData) { static async #onSubmitForm(event, form, formData) {
event.preventDefault() event.preventDefault()
console.log(formData.object)
await this.document.update(formData.object) // Note: formData.object await this.document.update(formData.object) // Note: formData.object
} }

View File

@ -338,7 +338,7 @@ export class XmlImport {
} }
async #addSkillFromCompendiumByNameToActor(talentName, taw, actor, combatStatistics, attributes) { async #addSkillFromCompendiumByNameToActor(talentName, taw, actor, combatStatistics, attributes) {
const compendiumOfSkills = game.packs.get('DSA_4-1.talente'); const compendiumOfSkills = game.packs.get('DSA_4-1.Skills');
const talentId = compendiumOfSkills.index.find(skill => skill.name === talentName) const talentId = compendiumOfSkills.index.find(skill => skill.name === talentName)
if (talentId) { if (talentId) {
@ -383,7 +383,7 @@ export class XmlImport {
} }
async #addSpellsFromCompendiumByNameToActor(spellName, zfw, representation, hauszauber, actor) { async #addSpellsFromCompendiumByNameToActor(spellName, zfw, representation, hauszauber, actor) {
const compendiumOfSpells = game.packs.get('DSA_4-1.spells'); const compendiumOfSpells = game.packs.get('DSA_4-1.Spells');
const SCREAMING_NAME = spellName.toUpperCase() const SCREAMING_NAME = spellName.toUpperCase()
const spellId = compendiumOfSpells.index.find(spell => spell.name === SCREAMING_NAME) const spellId = compendiumOfSpells.index.find(spell => spell.name === SCREAMING_NAME)
if (spellId) { if (spellId) {
@ -400,7 +400,7 @@ export class XmlImport {
} }
async #addLiturgiesFromCompendiumByNameToActor(liturgyName, actor) { async #addLiturgiesFromCompendiumByNameToActor(liturgyName, actor) {
const compendiumOfLiturgies = game.packs.get('DSA_4-1.liturgien'); const compendiumOfLiturgies = game.packs.get('DSA_4-1.Liturgies');
const liturgyId = compendiumOfLiturgies.index.find(liturgy => { const liturgyId = compendiumOfLiturgies.index.find(liturgy => {
return liturgy.name === LiturgyData.lookupAlias(liturgyName.split(" (")[0]) return liturgy.name === LiturgyData.lookupAlias(liturgyName.split(" (")[0])
}) })
@ -494,6 +494,7 @@ export class XmlImport {
actor.items.get(e._id).delete() actor.items.get(e._id).delete()
}) })
} }
let i = 100
held.gegenstände?.gegenstand?.forEach(e => { held.gegenstände?.gegenstand?.forEach(e => {
const compendiumOfArmor = game.packs.get('DSA_4-1.Armor'); const compendiumOfArmor = game.packs.get('DSA_4-1.Armor');
const compendiumOfWeapons = game.packs.get('DSA_4-1.Weapons'); const compendiumOfWeapons = game.packs.get('DSA_4-1.Weapons');
@ -525,13 +526,15 @@ export class XmlImport {
{ {
name: e.modallgemein?.name?.value ?? e.name, name: e.modallgemein?.name?.value ?? e.name,
type: "Equipment", type: "Equipment",
sort: (i++) * 100,
system: { system: {
quantity: e.anzahl, quantity: e.anzahl,
price: e.modallgemein?.preis.value, price: e.modallgemein?.preis.value,
weight: e.modallgemein?.gewicht.value, weight: e.modallgemein?.gewicht.value,
} }
})]) })
])
} }
}) })
} }

View File

@ -4,47 +4,6 @@
.dsa41.sheet { .dsa41.sheet {
nav.sheet-tabs.tabs {
position: relative;
display: flow;
border-top: unset;
border-bottom: unset;
margin-bottom: 0;
a.item[data-tab] {
background-color: colours.$tab-inactive-background-color;
&.active {
border-left: numbers.$tab-border-width solid colours.$tab-border-color;
border-top: numbers.$tab-border-width solid colours.$tab-border-color;
border-right: numbers.$tab-border-width solid colours.$tab-border-color;
border-bottom: 0;
top: numbers.$tab-border-width*2*2;
background: assets.$tab-background;
position: relative;
z-index: 2;
}
}
}
section.sheet-body {
border: numbers.$tab-border-width solid colours.$tab-border-color;
background: assets.$tab-pane-background;
div.tab {
overflow: auto;
}
}
// Tabs v2 // Tabs v2
.sheet-tabs { .sheet-tabs {
@ -54,6 +13,7 @@
border-top: unset; border-top: unset;
border-bottom: unset; border-bottom: unset;
margin-bottom: 0; margin-bottom: 0;
top: 1px;
a[data-action="tab"] { a[data-action="tab"] {
@ -74,14 +34,21 @@
border-top: numbers.$tab-border-width solid colours.$tab-border-color; border-top: numbers.$tab-border-width solid colours.$tab-border-color;
border-right: numbers.$tab-border-width solid colours.$tab-border-color; border-right: numbers.$tab-border-width solid colours.$tab-border-color;
border-bottom: 0; border-bottom: 0;
top: numbers.$tab-border-width*2;
background: assets.$tab-background; background: assets.$tab-background;
position: relative; position: relative;
z-index: 2;
box-shadow: numbers.$tab-shadow-right numbers.$tab-shadow-bottom numbers.$tab-shadow-blur-radius colours.$tab-shadow; box-shadow: numbers.$tab-shadow-right numbers.$tab-shadow-bottom numbers.$tab-shadow-blur-radius colours.$tab-shadow;
span {
&::after {
position: absolute;
content: '';
left: 0;
right: 0;
bottom: 0;
height: 3px;
background: assets.$tab-background;
z-index: 5;
} }

View File

@ -92,7 +92,7 @@
"label": "Rüstzeug", "label": "Rüstzeug",
"system": "DSA_4-1", "system": "DSA_4-1",
"type": "Item", "type": "Item",
"path": "packs/ruestzeug", "path": "packs/Ruestzeug",
"private": false "private": false
}, },
{ {