Various items fixes and enhancements
This commit is contained in:
@ -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)}`;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user