Skip to content

Commit

Permalink
Merge pull request #151 from juanferrer/master
Browse files Browse the repository at this point in the history
3.7.1 Hotfix
  • Loading branch information
ClipplerBlood committed Jan 18, 2024
2 parents b2c69f0 + 34da3cf commit 0c58231
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/module/data/actor/CharacterDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class CharacterDataModel extends foundry.abstract.DataModel {
attributes: attributes(),
characteristics: characteristics(type),
isPC: makeBoolField(true),
fastturn: makeBoolField(),
level: makeIntField(),
ancestry: makeStringField(), // Unused
religion: new foundry.data.fields.SchemaField({
Expand Down
2 changes: 1 addition & 1 deletion src/module/data/actor/CreatureDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class CreatureDataModel extends foundry.abstract.DataModel {
enrichedDescription: makeHtmlField(),
attributes: attributes(),
characteristics: characteristics(type),

fastturn: makeBoolField(),
difficulty: makeIntField(),
frightening: makeBoolField(),
horrifying: makeBoolField(),
Expand Down
3 changes: 2 additions & 1 deletion src/module/data/actor/VehicleDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '../common.js'

import {
makeBoolField,
makeIntField,
makeStringField,
makeHtmlField
Expand All @@ -18,7 +19,7 @@ export default class VehicleDataModel extends foundry.abstract.DataModel {
enrichedDescription: makeHtmlField(),
attributes: attributes(),
characteristics: characteristics(type),

fastturn: makeBoolField(),
descriptor: makeStringField(),
speedtraits: makeStringField(),
price: makeStringField(),
Expand Down
8 changes: 4 additions & 4 deletions src/module/data/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function attributes() {
agility: makeAttribute('agility'),
intellect: makeAttribute('intellect'),
will: makeAttribute('will'),
perception: makeAttribute('perception')
perception: makeAttribute('perception', 25)
})
}

Expand All @@ -19,7 +19,7 @@ export function characteristics(actorType) {
insanity: makeInsanity(),
corruption: makeCorruption(),
power: makeIntField(),
size: makeStringField(),
size: makeStringField("1"),
speed: makeIntField(10),
fortune: makeIntField()
})
Expand All @@ -30,7 +30,7 @@ export function characteristics(actorType) {
insanity: makeInsanity(),
corruption: makeCorruption(),
power: makeIntField(),
size: makeStringField(),
size: makeStringField("1"),
speed: makeIntField(10),
speedtraits: makeStringField(),
difficulty: makeIntField(),
Expand All @@ -44,7 +44,7 @@ export function characteristics(actorType) {
return new foundry.data.fields.SchemaField({
defense: makeIntField(),
health: makeHealth(),
size: makeStringField(),
size: makeStringField("1"),
speed: makeIntField(10),
speedtraits: makeStringField(),
descriptor: makeStringField("object (vehicle)"),
Expand Down
12 changes: 6 additions & 6 deletions src/module/data/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function makeBoolField(init = false) {
})
}

export function makeNumberField(init = 1, max = 20, min = 0) {
export function makeNumberField(init = 1, max, min) {
return new foundry.data.fields.NumberField({
required: true,
initial: init,
Expand All @@ -16,7 +16,7 @@ export function makeNumberField(init = 1, max = 20, min = 0) {
})
}

export function makeIntField(init = 0, max = 20, min = 0) {
export function makeIntField(init = 0, max, min) {
return new foundry.data.fields.NumberField({
required: true,
initial: init,
Expand Down Expand Up @@ -46,22 +46,22 @@ export function makeObjectField() {
})
}

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

export function makeHealth() {
return new foundry.data.fields.SchemaField({
max: makeIntField(),
value: makeIntField(),
value: makeIntField(0),
injured: makeBoolField(),
healingrate: makeIntField()
})
Expand Down
4 changes: 1 addition & 3 deletions src/module/data/item/AncestryDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class AncestryDataModel extends foundry.abstract.DataModel {
})
}),
level4: new foundry.data.fields.SchemaField({
healthbonuses: makeIntField(),
healthbonus: makeIntField(),
option1: makeBoolField(true),
option1text: makeStringField(),
talent: new foundry.data.fields.ArrayField(levelItem(makeTalentSchema)),
Expand All @@ -81,8 +81,6 @@ export default class AncestryDataModel extends foundry.abstract.DataModel {
}

static migrateData(source) {
console.log(source)

if (parseInt(source.characteristics?.insanity)) {
const insanity = parseInt(source.characteristics.insanity)
source.characteristics.insanity = {
Expand Down
8 changes: 5 additions & 3 deletions src/module/data/item/EndOfTheRoundDataModel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { action } from '../common.js'
import { action, activatedEffect } from '../common.js'

import {
makeHtmlField,
Expand All @@ -10,7 +10,8 @@ export default class EndOfTheRoundDataModel extends foundry.abstract.DataModel {
return {
description: makeHtmlField(),
enrichedDescription: makeHtmlField(),
action: action()
action: action(),
activatedEffect: activatedEffect(),
}
}
}
Expand All @@ -19,6 +20,7 @@ export function makeEndOfTheRoundSchema() {
return new foundry.data.fields.SchemaField({
description: makeHtmlField(),
enrichedDescription: makeHtmlField(),
action: action()
action: action(),
activatedEffect: activatedEffect(),
})
}
4 changes: 3 additions & 1 deletion src/module/data/item/WeaponDataModel.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { action } from '../common.js'
import { action, activatedEffect } from '../common.js'
import { makeBoolField, makeHtmlField, makeIntField, makeStringField } from '../helpers.js'

export default class WeaponDataModel extends foundry.abstract.DataModel {
static defineSchema() {
return {
description: makeHtmlField(),
action: action(),
activatedEffect: activatedEffect(),
enrichedDescription: makeHtmlField(),
hands: makeStringField(),
properties: makeStringField(),
Expand All @@ -25,6 +26,7 @@ export function makeWeaponSchema() {
return new foundry.data.fields.SchemaField({
description: makeHtmlField(),
action: action(),
activatedEffect: activatedEffect(),
enrichedDescription: makeHtmlField(),
hands: makeStringField(),
properties: makeStringField(),
Expand Down
2 changes: 2 additions & 0 deletions src/module/demonlord.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Hooks.once('setup', function () {
* Set default values for new actors' tokens
*/
Hooks.on('createActor', async (actor, _options, _id) => {
if (!actor.isOwner) return
let disposition = CONST.TOKEN_DISPOSITIONS.NEUTRAL
if (actor.type === 'creature') disposition = CONST.TOKEN_DISPOSITIONS.HOSTILE

Expand All @@ -231,6 +232,7 @@ Hooks.on('createToken', async _tokenDocument => {
})

Hooks.on('updateActor', async (actor, updateData) => {
if (!actor.isOwner) return
// Update the combat initiative if the actor has changed its turn speed
const isUpdateTurn = typeof updateData?.system?.fastturn !== 'undefined' && updateData?.system?.fastturn !== null
if (!(isUpdateTurn && (game.user.isGM || actor.isOwner) && game.combat)) return
Expand Down
2 changes: 1 addition & 1 deletion src/module/pixi/token-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TokenManager {
}

getTokenByActorId(actorId) {
return canvas.tokens.placeables.find(token => token.actor.id === actorId)
return canvas.tokens.placeables.find(token => token?.actor?.id === actorId)
}

warnNotSelected() {
Expand Down

0 comments on commit 0c58231

Please sign in to comment.