adds currency to compendia.

Also fixes skittish hover-behavior of equipment items.
pull/61/head
macniel 2025-10-26 21:11:49 +01:00
parent e7a1e3d3cf
commit 8cf8a61730
13 changed files with 113 additions and 2 deletions

View File

@ -113,6 +113,7 @@ async function prepareDB() {
convert("./src/packs/_source/nachteile", "./src/packs/__source/vorteile", "Advantage", false);
convert("./src/packs/_source/sonderfertigkeiten", "./src/packs/__source/sonderfertigkeiten", "SpecialAbility");
convert("./src/packs/_source/waffen", "./src/packs/__source/waffen", "Equipment");
convert("./src/packs/_source/waehrungen", "./src/packs/__source/waehrungen", "Equipment");
convert("./src/packs/_source/munition", "./src/packs/__source/munition", "Equipment");
convert("./src/packs/_source/ruestzeug", "./src/packs/__source/ruestzeug", "Equipment");
convert("./src/packs/_source/liturgien-und-segnungen", "./src/packs/__source/liturgien", "Liturgy");

View File

@ -52,6 +52,9 @@ export class EquipmentDataModel extends BaseItem {
max: new NumberField({required: true, initial: 1}),
count: new NumberField({required: true, initial: 1}),
}, {required: false}),
currencyName: new StringField({required: false}),
currencyDenominator: new NumberField({required: false}),
}
}

View File

@ -38,6 +38,17 @@ export default {
context.maxcarryingcapacity = actorData.system.attribute.kk.aktuell
context.carryingpercentage = Math.min((context.carryingweight / context.maxcarryingcapacity) * 100, 100);
context.wealth = 0
actorData.itemTypes["Equipment"].forEach(coin => {
console.log(coin.name, coin.system.category)
if (coin.system.category.indexOf("Währung") !== -1) {
console.log(context.wealth, coin)
context.wealth += (coin.system.quantity * coin.system.currencyDenominator)
}
})
console.log(context.wealth)
const maxSets = 3
const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
context.sets = []

View File

@ -62,6 +62,9 @@ export class EquipmentSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
ammunition: {
template: `systems/DSA_4-1/templates/item/equipment/tab-ammunition.hbs`
},
currency: {
template: 'systems/DSA_4-1/templates/item/equipment/tab-currency.hbs'
},
armor: {
template: `systems/DSA_4-1/templates/item/equipment/tab-armor.hbs`
},
@ -101,6 +104,8 @@ export class EquipmentSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
delete normalisedFormData.isAmmunition
if (normalisedFormData.isArmor) normalisedFormData['system.category'].push("Rüstung")
delete normalisedFormData.isArmor
if (normalisedFormData.isCurrency) normalisedFormData['system.category'].push("Währung")
delete normalisedFormData.isCurrency
await this.document.update(normalisedFormData) // Note: formData.object
}
@ -119,6 +124,12 @@ export class EquipmentSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
case 'armor':
this.#prepareArmorContext(context)
break;
case 'ammunition':
this.#prepareAmmunitionContext(context)
break;
case 'currency':
this.#prepareCurrencyContext(context)
break;
case 'settings':
this.#prepareSettingsContext(context)
break;
@ -196,11 +207,16 @@ export class EquipmentSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
}
#prepareCurrencyContext(context) {
}
#prepareSettingsContext(context) {
context.isMelee = this.document.system.category.includes("Nahkampfwaffe")
context.isRanged = this.document.system.category.includes("Fernkampfwaffe")
context.isAmmunition = this.document.system.category.includes("Munition")
context.isArmor = this.document.system.category.includes("Rüstung")
context.isCurrency = this.document.system.category.includes("Währung")
}
/**
@ -234,6 +250,11 @@ export class EquipmentSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
id: 'armor', group: group, label: 'Rüstung'
})
}
if (category.includes("Währung")) {
tabs.tabs.push({
id: 'currency', group: group, label: 'Währung'
})
}
tabs.tabs.push({
id: 'settings', group: group, label: 'Einstellungen'

View File

@ -0,0 +1,12 @@
{
"name": "Dukate",
"image": "icons/commodities/currency/coin-embossed-cobra-gold.webp",
"category": [
"Gegenstand",
"Währung"
],
"weight": 0,
"price": 10,
"currencyDenominator": 10,
"currencyName": "Mittelreich"
}

View File

@ -0,0 +1,12 @@
{
"name": "Heller",
"image": "icons/commodities/currency/coin-inset-copper-axe.webp",
"category": [
"Gegenstand",
"Währung"
],
"weight": 0,
"price": 0.01,
"currencyDenominator": 0.01,
"currencyName": "Mittelreich"
}

View File

@ -0,0 +1,12 @@
{
"name": "Kreuzer",
"image": "icons/commodities/currency/coin-inset-compass-silver.webp",
"category": [
"Gegenstand",
"Währung"
],
"weight": 0,
"price": 0.1,
"currencyDenominator": 0.1,
"currencyName": "Mittelreich"
}

View File

@ -0,0 +1,12 @@
{
"name": "Silbertaler",
"image": "icons/commodities/currency/coins-engraved-face-silver.webp",
"category": [
"Gegenstand",
"Währung"
],
"weight": 0,
"price": 1,
"currencyDenominator": 1,
"currencyName": "Mittelreich"
}

View File

@ -48,7 +48,7 @@
border: 1px solid #ccc;
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
margin: -4px 4px 4px -4px;
padding: 0 0 0 0;
padding: 0 4px 4px 0;
z-index: 2;
}
}

View File

@ -63,6 +63,14 @@
"path": "packs/vorteile",
"private": false
},
{
"name": "Currency",
"label": "Währung",
"system": "DSA_4-1",
"type": "Item",
"path": "packs/waehrungen",
"private": false
},
{
"name": "Weapons",
"label": "Waffen",

View File

@ -11,7 +11,7 @@
<div class="inventory">
<h3>Inventar</h3>
<h3>Inventar {{currency this.wealth}}</h3>
{{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" equipments}}

View File

@ -0,0 +1,15 @@
<section class="tab {{tabs.currency.id}} {{tabs.currency.cssClass}}"
data-tab="{{tabs.currency.id}}"
data-group="{{tabs.currency.group}}">
<div>
<div>
<label>Nenner einer Währung
<input type="text" name="system.currencyDenominator" value="{{system.currencyDenominator}}"/>
</label>
<label>
Name der Währung
<input type="text" name="system.currencyName" value="{{system.currencyName}}"/>
</label>
</div>
</div>
</section>

View File

@ -16,6 +16,10 @@
<input type="checkbox" name="isAmmunition" {{checked isAmmunition}}>
<span>Munition</span>
</label>
<label>
<input type="checkbox" name="isCurrency" {{checked isCurrency}}>
<span>Währung</span>
</label>
<label>
<input type="checkbox" name="isArmor" {{checked isArmor}}>
<span>Rüstzeug</span>