Skip to content

Commit

Permalink
Merge branch 'datamodels'
Browse files Browse the repository at this point in the history
  • Loading branch information
juanferrer committed Jan 7, 2024
2 parents eb0a797 + cc63de5 commit e5cf585
Show file tree
Hide file tree
Showing 95 changed files with 1,343 additions and 88 deletions.
9 changes: 9 additions & 0 deletions src/module/active-effects/item-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ export class DLActiveEffects {
addEffect('system.attributes.intellect.value', dataL0.attributes.intellect.value - 10, priority),
addEffect('system.attributes.will.value', dataL0.attributes.will.value - 10, priority),
addEffect('system.attributes.perception.value', dataL0.characteristics.perceptionmodifier, priority),
addEffect('system.attributes.strength.immune', dataL0.attributes.strength.immune, priority),
addEffect('system.attributes.agility.immune', dataL0.attributes.agility.immune, priority),
addEffect('system.attributes.intellect.immune', dataL0.attributes.intellect.immune, priority),
addEffect('system.attributes.will.immune', dataL0.attributes.will.immune, priority),

addEffect('system.characteristics.insanity.value', dataL0.characteristics.insanity.value, priority),
addEffect('system.characteristics.corruption.value', dataL0.characteristics.corruption.value, priority),
addEffect('system.characteristics.insanity.immune', dataL0.characteristics.insanity.immune, priority),
addEffect('system.characteristics.corruption.immune', dataL0.characteristics.corruption.immune, priority),
addEffect('system.characteristics.defense', dataL0.characteristics.defensemodifier, priority),
addEffect('system.characteristics.health.max', dataL0.characteristics.healthmodifier, priority),
addEffect('system.characteristics.health.healingrate', dataL0.characteristics.healingratemodifier, priority),
Expand Down
3 changes: 2 additions & 1 deletion src/module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,14 @@ export class DemonlordActor extends Actor {
// Adjust size here
const originalSize = this._source.system.characteristics.size
let modifiedSize = 0
let newSize = "1"
let newSize = originalSize
if (originalSize.includes("/")) {
const [numerator, denominator] = originalSize.split("/")
modifiedSize = parseInt(numerator) / parseInt(denominator)
} else {
modifiedSize = parseInt(originalSize)
}

for (let change of effectChanges.filter(e => e.key.includes("size"))) {
let sizeMod = 0

Expand Down
77 changes: 77 additions & 0 deletions src/module/data/actor/CharacterDataModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {
attributes,
characteristics,
} from '../common.js'

import {
makeIntField,
makeBoolField,
makeStringField,
makeHtmlField
} from '../helpers.js'

export default class CharacterDataModel extends foundry.abstract.DataModel {
static defineSchema() {
const type = 'character'

return {
description: makeHtmlField(),
enrichedDescription: makeHtmlField(),
attributes: attributes(),
characteristics: characteristics(type),
isPC: makeBoolField(true),
level: makeIntField(),
ancestry: makeStringField(), // Unused
religion: new foundry.data.fields.SchemaField({
edit: makeBoolField(),
value: makeStringField(),
image: makeStringField('systems/demonlord/assets/icons/bird.webp')
}),
languages: new foundry.data.fields.SchemaField({
edit: makeBoolField(),
value: makeStringField()
}),
wealth: new foundry.data.fields.SchemaField({
edit: makeBoolField(),
lifestyle: makeStringField(),
description: makeStringField(),
bits: makeIntField(),
cp: makeIntField(),
ss: makeIntField(),
gc: makeIntField()
}),
// Unused
professions: new foundry.data.fields.SchemaField({
edit: makeBoolField(),
value: makeStringField()
}),
// Unused
features: new foundry.data.fields.SchemaField({
edit: makeBoolField()
}),
// Unused
paths: new foundry.data.fields.SchemaField({
edit: makeBoolField(),
novice: makeStringField(),
expert: makeStringField(),
master: makeStringField(),
legendary: makeStringField()
}),
appearance: new foundry.data.fields.SchemaField({
age: makeStringField(),
sex: makeStringField(),
eyes: makeStringField(),
hair: makeStringField(),
height: makeStringField(),
weight: makeStringField(),
feature: makeStringField(),
}),
gmnote: makeStringField(),
gmnoteedit: makeBoolField(),
}
}

get type() {
return 'character'
}
}
37 changes: 37 additions & 0 deletions src/module/data/actor/CreatureDataModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
attributes,
characteristics,
} from '../common.js'

import {
makeIntField,
makeBoolField,
makeStringField,
makeHtmlField
} from '../helpers.js'

export default class CreatureDataModel extends foundry.abstract.DataModel {
static defineSchema() {
const type = 'creature'

return {
description: makeHtmlField(),
enrichedDescription: makeHtmlField(),
attributes: attributes(),
characteristics: characteristics(type),

difficulty: makeIntField(),
frightening: makeBoolField(),
horrifying: makeBoolField(),
descriptor: makeStringField(),
perceptionsenses: makeStringField(),
speedtraits: makeStringField(),
armor: makeStringField(),
roles: new foundry.data.fields.ArrayField(makeStringField()) // ?
}
}

get type() {
return 'creature'
}
}
32 changes: 32 additions & 0 deletions src/module/data/actor/VehicleDataModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
attributes,
characteristics,
} from '../common.js'

import {
makeIntField,
makeStringField,
makeHtmlField
} from '../helpers.js'

export default class VehicleDataModel extends foundry.abstract.DataModel {
static defineSchema() {
const type = 'vehicle'

return {
description: makeHtmlField(),
enrichedDescription: makeHtmlField(),
attributes: attributes(),
characteristics: characteristics(type),

descriptor: makeStringField(),
speedtraits: makeStringField(),
price: makeStringField(),
cargo: makeIntField()
}
}

get type() {
return 'vehicle'
}
}
110 changes: 110 additions & 0 deletions src/module/data/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { makeBoolField, makeIntField, makeStringField, makeAttribute, makeHealth, makeInsanity, makeCorruption } from './helpers.js'

export function attributes() {
return new foundry.data.fields.SchemaField({
strength: makeAttribute('strength'),
agility: makeAttribute('agility'),
intellect: makeAttribute('intellect'),
will: makeAttribute('will'),
perception: makeAttribute('perception')
})
}

export function characteristics() {
return new foundry.data.fields.SchemaField({
defense: makeIntField(),
health: makeHealth(),
insanity: makeInsanity(),
corruption: makeCorruption(),
power: makeIntField(),
size: makeStringField(),
speed: makeIntField(10),
fortune: makeIntField()
})
}

export function action() {
return new foundry.data.fields.SchemaField({
active: makeBoolField(true),
attribute: makeStringField(),
against: makeStringField(),
damageactive: makeBoolField(true),
damage: makeStringField(),
damagetype: makeStringField(),
boonsbanesactive: makeBoolField(true),
boonsbanes: makeStringField(),
plus20active: makeBoolField(true),
plus20: makeStringField(),
plus20damage: makeStringField(),
defense: makeStringField(),
defenseboonsbanes: makeStringField(),
damagetypes: new foundry.data.fields.ArrayField(makeStringField()),
strengthboonsbanesselect: makeBoolField(),
agilityboonsbanesselect: makeBoolField(),
intellectboonsbanesselect: makeBoolField(),
willboonsbanesselect: makeBoolField(),
perceptionboonsbanesselect: makeBoolField(),
extraboonsbanes: makeStringField(),
extradamage: makeStringField(),
extraplus20damage: makeStringField(),
extraeffect: makeStringField()
})
}

export function activatedEffect() {
return new foundry.data.fields.SchemaField({
activation: new foundry.data.fields.SchemaField({
type: makeStringField(),
cost: makeIntField()
}),
duration: new foundry.data.fields.SchemaField({
value: makeIntField(),
type: makeStringField()
}),
target: new foundry.data.fields.SchemaField({
value: makeStringField(),
type: makeStringField()
}),
texture: makeStringField(),
range: makeStringField(),
uses: new foundry.data.fields.SchemaField({
value: makeIntField(),
max: makeIntField(),
per: makeStringField()
})
})
}

export function enchantment() {
return new foundry.data.fields.SchemaField({
attackbonus: makeIntField(),
challengebonuse: makeIntField(),
damage: makeStringField(),
defense: makeIntField(),
speed: makeIntField(),
perception: makeIntField(),
effect: makeStringField(),
uses: new foundry.data.fields.SchemaField({
value: makeIntField(),
max: makeIntField()
})
})
}

export function contents() {
return new foundry.data.fields.ArrayField(makeStringField())
}

export function levelItem(makeDataSchema) {
return new foundry.data.fields.SchemaField({
system: makeDataSchema(),
description: new foundry.data.fields.SchemaField({
value: makeStringField()
}),
id: makeStringField(),
name: makeStringField(),
pack: makeStringField(),
selected: makeBoolField(),
uuid: makeStringField()
})
}
72 changes: 72 additions & 0 deletions src/module/data/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { capitalize } from "../utils/utils"

export const makeBoolField = (init = false) => new foundry.data.fields.BooleanField({
initial: init
})

export const makeNumberField = (init = 1, max = 20, min = 0) => new foundry.data.fields.NumberField({
required: true,
initial: init,
//positive: true
min: min,
max: max,
})

export const makeIntField = (init = 0, max = 20, min = 0) => new foundry.data.fields.NumberField({
required: true,
initial: init,
min: min,
max: max,
integer: true,
clean: true
})

export const makeStringField = (init = '', blank = true) => new foundry.data.fields.StringField({
initial: init,
blank: blank
})

export const makeHtmlField = (init = '') => new foundry.data.fields.SchemaField({
value: new foundry.data.fields.HTMLField({
initial: init,
textSearch: true // Allow it to be searched in the Search Bar
})
})

export function makeAttribute(attribute) {
return new foundry.data.fields.SchemaField({
key: makeStringField(attribute),
label: makeStringField(game.i18n.localize(`DL.Attribute${capitalize(attribute)}`)),
value: makeIntField(10),
modifier: makeIntField(),
min: makeIntField(),
max: makeIntField(20),
immune: makeBoolField()
})
}

export function makeHealth() {
return new foundry.data.fields.SchemaField({
max: makeIntField(),
value: makeIntField(),
injured: makeBoolField(),
healingrate: makeIntField()
})
}

export function makeInsanity() {
return new foundry.data.fields.SchemaField({
min: makeIntField(),
max: makeIntField(20),
value: makeIntField(),
immune: makeBoolField()
})
}

export function makeCorruption() {
return new foundry.data.fields.SchemaField({
min: makeIntField(),
value: makeIntField(),
immune: makeBoolField()
})
}
19 changes: 19 additions & 0 deletions src/module/data/item/AmmoDataModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import {
makeIntField,
makeStringField,
makeHtmlField,
} from '../helpers.js'

export default class AmmoDataModel extends foundry.abstract.DataModel {
static defineSchema() {
return {
description: makeHtmlField(),
enrichedDescription: makeHtmlField(),
properties: makeStringField(),
quantity: makeIntField(5),
availability: makeStringField(),
value: makeStringField()
}
}
}
Loading

0 comments on commit e5cf585

Please sign in to comment.