RC-98 | Add quantity to items
This commit is contained in:
parent
aa05cdde46
commit
3cff9fda7d
8 changed files with 57 additions and 4 deletions
|
|
@ -17,6 +17,7 @@
|
|||
"HeroSkillsCardV1": "Hero Skill Card"
|
||||
},
|
||||
"common": {
|
||||
"quantity": "Quantity",
|
||||
"equipped": "Equipped",
|
||||
"edit": "Edit",
|
||||
"delete": "Delete",
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ export class HeroSkillsCardV1 extends GenericAppMixin(HandlebarsApplicationMixin
|
|||
ctx.gear.push({
|
||||
index: ctx.gear.length,
|
||||
uuid: item.uuid,
|
||||
name: item.name,
|
||||
name: item.quantifiedName,
|
||||
empty: false,
|
||||
});
|
||||
|
||||
|
|
|
|||
20
module/data/Item/Common.mjs
Normal file
20
module/data/Item/Common.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { requiredInteger } from "../helpers.mjs";
|
||||
|
||||
export class CommonItemData extends foundry.abstract.TypeDataModel {
|
||||
// MARK: Schema
|
||||
static defineSchema() {
|
||||
return {
|
||||
quantity: requiredInteger({ min: 0, initial: 1 }),
|
||||
};
|
||||
};
|
||||
|
||||
// MARK: Base Data
|
||||
prepareBaseData() {
|
||||
super.prepareBaseData();
|
||||
};
|
||||
|
||||
// MARK: Derived Data
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
};
|
||||
};
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
import { CommonItemData } from "./Common.mjs";
|
||||
import { gameTerms } from "../../gameTerms.mjs";
|
||||
import { requiredInteger } from "../helpers.mjs";
|
||||
|
||||
const { fields } = foundry.data;
|
||||
|
||||
/** Used for Armour and Shields */
|
||||
export class ProtectorData extends foundry.abstract.TypeDataModel {
|
||||
export class ProtectorData extends CommonItemData {
|
||||
// MARK: Schema
|
||||
static defineSchema() {
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
protection: requiredInteger({ min: 0, initial: 1 }),
|
||||
location: new fields.SetField(
|
||||
new fields.StringField({
|
||||
|
|
@ -48,6 +50,14 @@ export class ProtectorData extends foundry.abstract.TypeDataModel {
|
|||
// #region Sheet Data
|
||||
getFormFields(_ctx) {
|
||||
const fields = [
|
||||
{
|
||||
id: `quantity`,
|
||||
type: `integer`,
|
||||
label: `RipCrypt.Apps.quantity`,
|
||||
path: `system.quantity`,
|
||||
value: this.quantity,
|
||||
min: 0,
|
||||
},
|
||||
{
|
||||
id: `location`,
|
||||
type: `string-set`,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import { barAttribute, optionalInteger, requiredInteger } from "../helpers.mjs";
|
||||
import { CommonItemData } from "./Common.mjs";
|
||||
import { gameTerms } from "../../gameTerms.mjs";
|
||||
|
||||
const { fields } = foundry.data;
|
||||
|
||||
export class WeaponData extends foundry.abstract.TypeDataModel {
|
||||
export class WeaponData extends CommonItemData {
|
||||
// MARK: Schema
|
||||
static defineSchema() {
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
traits: new fields.SetField(
|
||||
new fields.StringField({
|
||||
blank: false,
|
||||
|
|
@ -59,6 +61,14 @@ export class WeaponData extends foundry.abstract.TypeDataModel {
|
|||
// #region Sheet Data
|
||||
getFormFields(_ctx) {
|
||||
const fields = [
|
||||
{
|
||||
id: `quantity`,
|
||||
type: `integer`,
|
||||
label: `RipCrypt.common.quantity`,
|
||||
path: `system.quantity`,
|
||||
value: this.quantity,
|
||||
min: 0,
|
||||
},
|
||||
{
|
||||
id: `traits`,
|
||||
type: `string-set`,
|
||||
|
|
|
|||
8
module/documents/item.mjs
Normal file
8
module/documents/item.mjs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export class RipCryptItem extends Item {
|
||||
get quantifiedName() {
|
||||
if (this.system.quantity != null && this.system.quantity !== 1) {
|
||||
return `${this.name} (${this.system.quantity})`;
|
||||
}
|
||||
return this.name;
|
||||
};
|
||||
};
|
||||
|
|
@ -12,6 +12,9 @@ import { WeaponData } from "../data/Item/Weapon.mjs";
|
|||
// Class Overrides
|
||||
import { CryptDie } from "../dice/CryptDie.mjs";
|
||||
|
||||
// Documents
|
||||
import { RipCryptItem } from "../documents/item.mjs";
|
||||
|
||||
// Misc
|
||||
import helpers from "../handlebarHelpers/_index.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
|
|
@ -37,6 +40,7 @@ Hooks.once(`init`, () => {
|
|||
// #endregion
|
||||
|
||||
// #region Class Changes
|
||||
CONFIG.Item.documentClass = RipCryptItem;
|
||||
CONFIG.Dice.terms.d = CryptDie;
|
||||
// #endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@
|
|||
data-action="editItem"
|
||||
></rc-icon> --}}
|
||||
<span class="ellipses">
|
||||
{{ slot.data.name }}
|
||||
{{ slot.data.quantifiedName }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue