Skip to content

Commit

Permalink
Merge branch 'itemsheetv2'
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Nov 29, 2024
2 parents 2a773c2 + 88a87c9 commit ba80851
Show file tree
Hide file tree
Showing 89 changed files with 2,043 additions and 204 deletions.
2 changes: 2 additions & 0 deletions modules/hooks/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ export default function() {
rangedWeapons: "systems/wfrp4e/templates/sheets/partials/ranged-weapons.hbs",
armourLocation: "systems/wfrp4e/templates/sheets/partials/armour-location.hbs",
creatureArmour: "systems/wfrp4e/templates/sheets/partials/creature-armour.hbs",
itemProperties: "systems/wfrp4e/templates/sheets/partials/item-properties.hbs",
extraOvercast: "systems/wfrp4e/templates/sheets/partials/extra-overcast.hbs",
});

// Load name construction from files
Expand Down
4 changes: 2 additions & 2 deletions modules/model/actor/components/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ export class VehicleDetailsModel extends foundry.abstract.DataModel {
value: new fields.NumberField({min: 1, initial : 25})
});
schema.description = new fields.SchemaField({
value: new fields.StringField({ initial: "" })
value: new fields.HTMLField()
});
schema.gmdescription = new fields.SchemaField({
value: new fields.StringField({ initial: "" }),
value: new fields.HTMLField()
});
schema.price = new fields.SchemaField({
gc: new fields.NumberField({initial : 0})
Expand Down
8 changes: 4 additions & 4 deletions modules/model/item/ammunition.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ let fields = foundry.data.fields;

export class AmmunitionModel extends PropertiesMixin(PhysicalItemModel)
{
static LOCALIZATION_PREFIXES = ["WH.Models.ammunition"];

static defineSchema()
{
let schema = super.defineSchema();
schema.ammunitionType = new fields.SchemaField({
value: new fields.StringField()
value: new fields.StringField({choices : game.wfrp4e.config.ammunitionGroups})
});
schema.range = new fields.SchemaField({
value: new fields.StringField()
Expand All @@ -17,9 +19,7 @@ export class AmmunitionModel extends PropertiesMixin(PhysicalItemModel)
value: new fields.StringField(),
dice: new fields.StringField({ initial: "" })
});
schema.ammunitionType = new fields.SchemaField({
value: new fields.StringField()
});

schema.special = new fields.SchemaField({
value: new fields.StringField()
});
Expand Down
5 changes: 3 additions & 2 deletions modules/model/item/armour.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ let fields = foundry.data.fields;
* @mixes PropertiesMixin
*/
export class ArmourModel extends PropertiesMixin(EquippableItemModel) {
static defineSchema() {
static LOCALIZATION_PREFIXES = ["WH.Models.armour"];
static defineSchema() {
let schema = super.defineSchema();
schema.armorType = new fields.SchemaField({ // TODO migrate this to the "correct" spelling
value: new fields.StringField()
value: new fields.StringField({}),//choices : game.wfrp4e.config.armorTypes})
});
schema.penalty = new fields.SchemaField({
value: new fields.StringField()
Expand Down
52 changes: 49 additions & 3 deletions modules/model/item/career.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let fields = foundry.data.fields;

export class CareerModel extends BaseItemModel
{
static LOCALIZATION_PREFIXES = ["WH.Models.career"];
static defineSchema()
{
let schema = super.defineSchema();
Expand All @@ -19,13 +20,26 @@ export class CareerModel extends BaseItemModel
value: new fields.BooleanField()
});
schema.level = new fields.SchemaField({
value: new fields.NumberField({min: 1})
// value: new fields.NumberField({min: 1, choices : [1, 2, 3, 4], initial : 1})
value: new fields.NumberField({min: 1, choices : {1 : "1", 2 : "2", 3 : "3", 4 : "4"}, initial : 1})
});
schema.status = new fields.SchemaField({
standing: new fields.NumberField({min: 1}),
tier: new fields.StringField({choices: ["b", "s", "g"]})
tier: new fields.StringField({choices: game.wfrp4e.config.statusTiers})
});
schema.characteristics = new fields.ArrayField(new fields.StringField());
schema.characteristics = new fields.SchemaField({
ws: new fields.BooleanField(),
bs: new fields.BooleanField(),
s: new fields.BooleanField(),
t: new fields.BooleanField(),
i: new fields.BooleanField(),
ag: new fields.BooleanField(),
dex: new fields.BooleanField(),
int: new fields.BooleanField(),
wp: new fields.BooleanField(),
fel: new fields.BooleanField(),
})

schema.skills = new fields.ArrayField(new fields.StringField());
schema.addedSkills = new fields.ArrayField(new fields.StringField());
schema.talents = new fields.ArrayField(new fields.StringField());
Expand Down Expand Up @@ -185,4 +199,36 @@ export class CareerModel extends BaseItemModel
properties.push(`<b>${game.i18n.localize("Income")}</b>: ${this.incomeSkill.map(i => " " + this.skills[i])}`);
return properties;
}

static migrateData(data)
{
if (data.characteristics instanceof Array)
{
data.characteristics = {
ws : data.characteristics.includes("ws"),
bs : data.characteristics.includes("bs"),
s : data.characteristics.includes("s"),
t : data.characteristics.includes("t"),
i : data.characteristics.includes("i"),
ag : data.characteristics.includes("ag"),
dex : data.characteristics.includes("dex"),
int : data.characteristics.includes("int"),
wp : data.characteristics.includes("wp"),
fel : data.characteristics.includes("fel")
}
}

// if (data.skills instanceof Array)
// {
// data.skills = {list : data.skills};
// }
// if (data.talents instanceof Array)
// {
// data.talents = {list : data.talents};
// }
// if (data.trappings instanceof Array)
// {
// data.trappings = {list : data.trappings};
// }
}
}
6 changes: 4 additions & 2 deletions modules/model/item/cargo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ let fields = foundry.data.fields;

export class CargoModel extends PhysicalItemModel
{
static LOCALIZATION_PREFIXES = ["WH.Models.cargo"];
static defineSchema()
{

let schema = super.defineSchema();
schema.cargoType = new fields.SchemaField({
value: new fields.StringField()
value: new fields.StringField({})
});
schema.unitPrice = new fields.SchemaField({
value: new fields.NumberField()
Expand All @@ -18,7 +20,7 @@ export class CargoModel extends PhysicalItemModel
schema.quality = new fields.SchemaField({
value: new fields.StringField({initial : "average"})
});
schema.tradeType = new fields.StringField({initial : "river"})
schema.tradeType = new fields.StringField({initial : "river", choices : {river : "River", maritime : "Maritime"}})
return schema;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/model/item/components/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ let fields = foundry.data.fields;
{
return {
description : new fields.SchemaField({
value: new fields.StringField()
value: new fields.HTMLField()
}),
gmdescription : new fields.SchemaField({
value: new fields.StringField()
value: new fields.HTMLField()
}),
}
}
Expand Down
4 changes: 4 additions & 0 deletions modules/model/item/components/locational.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { BaseItemModel } from "./base";
let fields = foundry.data.fields;

export class LocationalItemModel extends BaseItemModel {

static LOCALIZATION_PREFIXES = ["WH.Components.Locational"];


static defineSchema() {
let schema = super.defineSchema();
schema.prompt = new fields.BooleanField();
Expand Down
2 changes: 2 additions & 0 deletions modules/model/item/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ let fields = foundry.data.fields;
* @extends EquippableItemModel
*/
export class ContainerModel extends EquippableItemModel {
static LOCALIZATION_PREFIXES = ["WH.Models.container"];

static defineSchema() {
let schema = super.defineSchema();
schema.wearable = new fields.SchemaField({
Expand Down
22 changes: 0 additions & 22 deletions modules/model/item/corruption.js

This file was deleted.

3 changes: 3 additions & 0 deletions modules/model/item/critical.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { LocationalItemModel } from "./components/locational";
let fields = foundry.data.fields;

export class CriticalModel extends LocationalItemModel {

static LOCALIZATION_PREFIXES = ["WH.Models.critical"];

static defineSchema() {
let schema = super.defineSchema();
schema.wounds = new fields.SchemaField({
Expand Down
9 changes: 8 additions & 1 deletion modules/model/item/disease.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ let fields = foundry.data.fields;
*/
export class DiseaseModel extends BaseItemModel {

static LOCALIZATION_PREFIXES = ["WH.Models.disease"];

static defineSchema() {
let schema = super.defineSchema();
schema.contraction = new fields.SchemaField({
Expand Down Expand Up @@ -44,6 +46,11 @@ export class DiseaseModel extends BaseItemModel {
{
this.start("duration");
}

if (foundry.utils.hasProperty(options, "changed.system.symptoms.value") && !options.skipSymptomHandling)
{
this.updateSymptoms(this.symptoms.value);
}
}

async _onCreate(data, options, user)
Expand Down Expand Up @@ -136,7 +143,7 @@ export class DiseaseModel extends BaseItemModel {
// Add symptoms from input
await this.parent.createEmbeddedDocuments("ActiveEffect", symptomEffects)

return this.parent.update({ "system.symptoms.value": text })
return this.parent.update({ "system.symptoms.value": text }, {skipSymptomHandling : true})
}

async start(type, update=false)
Expand Down
7 changes: 5 additions & 2 deletions modules/model/item/extendedTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { BaseItemModel } from "./components/base";
let fields = foundry.data.fields;

export class ExtendedTestModel extends BaseItemModel {
static LOCALIZATION_PREFIXES = ["WH.Models.extendedTest"];


static defineSchema() {
let schema = super.defineSchema();

Expand All @@ -23,7 +26,7 @@ export class ExtendedTestModel extends BaseItemModel {
});

schema.completion = new fields.SchemaField({
value: new fields.StringField({ initial: "none" })
value: new fields.StringField({ initial: "none", choices : game.wfrp4e.config.extendedTestCompletion})
});

schema.hide = new fields.SchemaField({
Expand All @@ -32,7 +35,7 @@ export class ExtendedTestModel extends BaseItemModel {
});

schema.difficulty = new fields.SchemaField({
value: new fields.StringField({ initial: "challenging" })
value: new fields.StringField({ initial: "challenging", choices : game.wfrp4e.config.difficultyLabels })
});

return schema;
Expand Down
4 changes: 4 additions & 0 deletions modules/model/item/injury.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ let fields = foundry.data.fields;

export class InjuryModel extends LocationalItemModel
{

static LOCALIZATION_PREFIXES = ["WH.Models.injury"];


static defineSchema()
{
let schema = super.defineSchema();
Expand Down
2 changes: 2 additions & 0 deletions modules/model/item/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ let fields = foundry.data.fields;

export class MoneyModel extends PhysicalItemModel
{
static LOCALIZATION_PREFIXES = ["WH.Models.money"];

static defineSchema()
{
// Patron Fields
Expand Down
9 changes: 3 additions & 6 deletions modules/model/item/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ let fields = foundry.data.fields;

export class MutationModel extends BaseItemModel
{
static LOCALIZATION_PREFIXES = ["WH.Models.mutation"];

static defineSchema()
{
// Patron Fields
let schema = super.defineSchema();
schema.mutationType = new fields.SchemaField({
value : new fields.StringField(),
value : new fields.StringField({choices : game.wfrp4e.config.mutationTypes}),
});

schema.modifier = new fields.SchemaField({
value : new fields.StringField(),
})

schema.modifiesSkills = new fields.SchemaField({
value : new fields.BooleanField(),
});

return schema;
}

Expand Down
4 changes: 3 additions & 1 deletion modules/model/item/prayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ let fields = foundry.data.fields;

export class PrayerModel extends OvercastItemModel
{
static LOCALIZATION_PREFIXES = ["WH.Models.prayer"];

static defineSchema()
{
let schema = super.defineSchema();

schema.type = new fields.SchemaField({
value : new fields.StringField(),
value : new fields.StringField({initial : "blessing", choices : game.wfrp4e.config.prayerTypes}),
});
schema.god = new fields.SchemaField({
value : new fields.StringField(),
Expand Down
10 changes: 6 additions & 4 deletions modules/model/item/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { BaseItemModel } from "./components/base";
let fields = foundry.data.fields;

export class SkillModel extends BaseItemModel {
static LOCALIZATION_PREFIXES = ["WH.Models.skill"];

static defineSchema() {
let schema = super.defineSchema();
schema.advanced = new fields.SchemaField({
value: new fields.StringField(),
value: new fields.StringField({initial : "bsc", choices : game.wfrp4e.config.skillTypes}),
});
schema.grouped = new fields.SchemaField({
value: new fields.StringField({ initial: "noSpec" })
value: new fields.StringField({ initial: "noSpec", choices : game.wfrp4e.config.skillGroup })
});
schema.characteristic = new fields.SchemaField({
value: new fields.StringField({ initial: "ws" }),
value: new fields.StringField({ initial: "ws", choices : game.wfrp4e.config.characteristics }),
});
schema.advances = new fields.SchemaField({
value: new fields.NumberField(),
Expand Down Expand Up @@ -80,7 +82,7 @@ export class SkillModel extends BaseItemModel {
if (this.parent.isEmbedded)
{
// If skill has (any) or (), ask for a specialisation
if (this.parent.specifier.toLowerCase() == game.i18n.localize("SPEC.Any").toLowerCase() || this.grouped.value && !this.parent.specifier)
if (this.parent.specifier.toLowerCase() == game.i18n.localize("SPEC.Any").toLowerCase() || (this.grouped.value == "isSpec" && !(this.parent.specifier)))
{
let skills = await warhammer.utility.findAllItems("skill", "Loading Skills", true);
let specialisations = skills.filter(i => i.name.split("(")[0]?.trim() == this.parent.baseName);
Expand Down
2 changes: 2 additions & 0 deletions modules/model/item/spell.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { OvercastItemModel } from "./components/overcast";
let fields = foundry.data.fields;

export class SpellModel extends OvercastItemModel {
static LOCALIZATION_PREFIXES = ["WH.Models.spell"];

static defineSchema() {
let schema = super.defineSchema();

Expand Down
Loading

0 comments on commit ba80851

Please sign in to comment.