Various items fixes and enhancements
This commit is contained in:
@@ -9,3 +9,4 @@ export { default as LethalFantasyGift } from "./gift.mjs"
|
||||
export { default as LethalFantasyVulnerability } from "./vulnerability.mjs"
|
||||
export { default as LethalFantasySave } from "./save.mjs"
|
||||
export { default as LethalFantasyEquipment } from "./equipment.mjs"
|
||||
export { default as LethalFantasyMiracle } from "./miracle.mjs"
|
||||
|
||||
@@ -52,6 +52,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
bonus: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
schema.grit = new fields.SchemaField({
|
||||
starting: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
earned: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
@@ -87,6 +88,17 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
/** @override */
|
||||
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Character"]
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
let grit = 0
|
||||
for (let c in this.characteristics) {
|
||||
if (SYSTEM.CHARACTERISTICS_MAJOR[c.id]) {
|
||||
grit += this.characteristics[c].value
|
||||
}
|
||||
}
|
||||
this.grit.starting = Math.round(grit / 6)
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls a dice for a character.
|
||||
* @param {("save"|"resource|damage")} rollType The type of the roll.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import { CATEGORY } from "../config/weapon.mjs"
|
||||
|
||||
export default class LethalFantasyEquipment extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields
|
||||
|
||||
38
module/models/miracle.mjs
Normal file
38
module/models/miracle.mjs
Normal file
@@ -0,0 +1,38 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
export default class LethalFantasyMiracle extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
const schema = {}
|
||||
|
||||
schema.description = new fields.HTMLField({
|
||||
required: false,
|
||||
blank: true,
|
||||
initial: "",
|
||||
textSearch: true,
|
||||
})
|
||||
schema.level = new fields.NumberField({
|
||||
...requiredInteger,
|
||||
initial: 1,
|
||||
min: 1,
|
||||
max: 20,
|
||||
})
|
||||
schema.components = new fields.SchemaField({
|
||||
verbal: new fields.BooleanField(),
|
||||
somatic: new fields.BooleanField(),
|
||||
material: new fields.BooleanField(),
|
||||
catalyst: new fields.BooleanField(),
|
||||
religious: new fields.BooleanField()
|
||||
})
|
||||
schema.prayerTime = new fields.StringField({ required: true, initial: "" })
|
||||
schema.miracleRange = new fields.StringField({ required: true, initial: "" })
|
||||
schema.areaAffected = new fields.StringField({ required: true, initial: "" })
|
||||
schema.duration = new fields.StringField({ required: true, initial: "" })
|
||||
schema.savingThrow = new fields.StringField({ required: true, initial: "" })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Miracle"]
|
||||
}
|
||||
@@ -12,6 +12,13 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.cost = new fields.NumberField({ ...requiredInteger,required: true, initial: 0, min: 0 })
|
||||
|
||||
schema.weaponClass = new fields.StringField({ required: true, initial: "shortblade", choices: SYSTEM.WEAPON_CLASS })
|
||||
schema.weaponBonus = new fields.SchemaField({
|
||||
attack: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
defense: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
damage: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
})
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
@@ -21,10 +28,30 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
get skillCategory() {
|
||||
return game.i18n.localize(CATEGORY[this.category].label)
|
||||
}
|
||||
|
||||
validate(options) {
|
||||
let isError = super.validate(options)
|
||||
console.log(this)
|
||||
let bonus = this._source.weaponBonus.attack + this._source.weaponBonus.defense + this._source.weaponBonus.damage
|
||||
console.log(bonus, this._source.skillTotal)
|
||||
if ( bonus > Math.floor(this._source.skillTotal / 10) ) {
|
||||
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Skill.error.weaponBonus"))
|
||||
isError = true
|
||||
}
|
||||
return isError
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
this.skillTotal = this.computeBase();
|
||||
if( this.category === "weapon" ) {
|
||||
this.totalBonus = this.weaponBonus.attack + this.weaponBonus.defense + this.weaponBonus.damage;
|
||||
if ( Number(this.skillTotal) ) {
|
||||
this.availableBonus = Math.max( Math.floor(this.skillTotal / 10) - 1, 0 )
|
||||
} else {
|
||||
this.availableBonus = "N/A"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
computeBase() {
|
||||
@@ -47,7 +74,7 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
maxStat = statValue;
|
||||
}
|
||||
}
|
||||
return maxStat;
|
||||
return maxStat + this.bonus
|
||||
} else {
|
||||
// Split with + calculate the total
|
||||
baseSplit = base.split("+");
|
||||
@@ -59,9 +86,9 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
const statValue = actor.system.characteristics[stat.toLowerCase()]?.value || 0;
|
||||
total += statValue;
|
||||
}
|
||||
return total
|
||||
return total + this.bonus
|
||||
}
|
||||
}
|
||||
return `${this.base } + ${ String(this.bonus)}`;
|
||||
return `${this.base} + ${String(this.bonus)}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
|
||||
material: new fields.BooleanField(),
|
||||
})
|
||||
schema.castingTime = new fields.StringField({ required: true, initial: "" })
|
||||
schema.range = new fields.StringField({ required: true, initial: "" })
|
||||
schema.spellRange = new fields.StringField({ required: true, initial: "" })
|
||||
schema.areaAffected = new fields.StringField({ required: true, initial: "" })
|
||||
schema.duration = new fields.StringField({ required: true, initial: "" })
|
||||
schema.savingThrow = new fields.StringField({ required: true, initial: "" })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import { CATEGORY } from "../config/weapon.mjs"
|
||||
|
||||
export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields
|
||||
@@ -8,6 +8,8 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.weaponType = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_TYPE })
|
||||
schema.weaponClass = new fields.StringField({ required: true, initial: "shortblade", choices: SYSTEM.WEAPON_CLASS })
|
||||
|
||||
schema.damageType = new fields.SchemaField({
|
||||
typeP: new fields.BooleanField(),
|
||||
typeB: new fields.BooleanField(),
|
||||
@@ -29,7 +31,7 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
})
|
||||
|
||||
schema.defense = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.range = new fields.SchemaField({
|
||||
schema.weaponRange = new fields.SchemaField({
|
||||
pointBlank: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
short: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
medium: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
@@ -49,6 +51,6 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Weapon"]
|
||||
|
||||
get weaponCategory() {
|
||||
return game.i18n.localize(CATEGORY[this.category].label)
|
||||
return game.i18n.localize(CATEGORY[this.weaponType].label)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user