Begin adding cost to items
This commit is contained in:
parent
dc5bf7aa07
commit
00228d3aae
7 changed files with 56 additions and 2 deletions
|
|
@ -51,6 +51,7 @@
|
|||
"fract": "Fract",
|
||||
"focus": "Focus"
|
||||
},
|
||||
"cost": "Cost",
|
||||
"currency": {
|
||||
"gold": "Gold",
|
||||
"silver": "Silver",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,14 @@ export class AmmoData extends CommonItemData {
|
|||
value: this.quantity,
|
||||
min: 0,
|
||||
},
|
||||
{
|
||||
id: `cost`,
|
||||
type: `cost`,
|
||||
label: `RipCrypt.common.cost`,
|
||||
gold: this.cost.gold,
|
||||
silver: this.cost.silver,
|
||||
copper: this.cost.copper,
|
||||
},
|
||||
{
|
||||
id: `access`,
|
||||
type: `dropdown`,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { optionalInteger, requiredInteger } from "../helpers.mjs";
|
||||
import { gameTerms } from "../../gameTerms.mjs";
|
||||
import { requiredInteger } from "../helpers.mjs";
|
||||
|
||||
const { fields } = foundry.data;
|
||||
|
||||
|
|
@ -14,6 +14,11 @@ export class CommonItemData extends foundry.abstract.TypeDataModel {
|
|||
trim: true,
|
||||
choices: gameTerms.Access,
|
||||
}),
|
||||
cost: new fields.SchemaField({
|
||||
gold: optionalInteger(),
|
||||
silver: optionalInteger(),
|
||||
copper: optionalInteger(),
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
33
module/handlebarHelpers/inputs/currency.mjs
Normal file
33
module/handlebarHelpers/inputs/currency.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { groupInput } from "./groupInput.mjs";
|
||||
|
||||
export function costInput(input, data) {
|
||||
return groupInput({
|
||||
title: input.label,
|
||||
fields: [
|
||||
{
|
||||
id: input.id + `-gold`,
|
||||
type: `integer`,
|
||||
label: `RipCrypt.common.currency.gold`,
|
||||
value: input.gold,
|
||||
path: `system.cost.gold`,
|
||||
limited: input.limited,
|
||||
},
|
||||
{
|
||||
id: input.id + `-silver`,
|
||||
type: `integer`,
|
||||
label: `RipCrypt.common.currency.silver`,
|
||||
value: input.silver,
|
||||
path: `system.cost.silver`,
|
||||
limited: input.limited,
|
||||
},
|
||||
{
|
||||
id: input.id + `-copper`,
|
||||
type: `integer`,
|
||||
label: `RipCrypt.common.currency.copper`,
|
||||
value: input.copper,
|
||||
path: `system.cost.copper`,
|
||||
limited: input.limited,
|
||||
},
|
||||
],
|
||||
}, data);
|
||||
};
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { barInput } from "./barInput.mjs";
|
||||
import { booleanInput } from "./booleanInput.mjs";
|
||||
import { costInput } from "./currency.mjs";
|
||||
import { dropdownInput } from "./dropdownInput.mjs";
|
||||
import { groupInput } from "./groupInput.mjs";
|
||||
import { numberInput } from "./numberInput.mjs";
|
||||
|
|
@ -18,6 +19,7 @@ const inputTypes = {
|
|||
boolean: booleanInput,
|
||||
group: groupInput,
|
||||
text: textInput,
|
||||
cost: costInput,
|
||||
};
|
||||
|
||||
const typesToSanitize = new Set([ `string`, `number` ]);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export function groupInput(input, data) {
|
|||
data-input-type="group"
|
||||
var:border-color="${input.borderColor ?? `var(--accent-1)`}"
|
||||
var:vertical-displacement="${input.verticalDisplacement ?? `12px`}"
|
||||
var:padding-top="${input.paddingTop ?? `16px`}"
|
||||
var:padding-top="${input.paddingTop ?? `20px`}"
|
||||
>
|
||||
<div slot="title">${title}</div>
|
||||
<div slot="content" class="content">
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@
|
|||
margin: 0 auto;
|
||||
}
|
||||
|
||||
hr:has(+ [data-input-type="group"]),
|
||||
[data-input-type="group"] + hr {
|
||||
display: none;
|
||||
};
|
||||
|
||||
label, .label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue