Files
fvtt-hellborn/module/models/weapon.mjs
LeRatierBretonnien 0ee42aef99
All checks were successful
Release Creation / build (release) Successful in 58s
Various changes
2025-05-29 22:41:15 +02:00

41 lines
1.8 KiB
JavaScript

import { SYSTEM } from "../config/system.mjs"
export default class HellbornWeapon extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
const requiredInteger = { required: true, nullable: false, integer: true }
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.stat = new fields.StringField({ required: true, initial: "skin", choices: {"skin": "Skin", "flesh": "Flesh" }})
schema.weaponType = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_TYPES })
schema.subType = new fields.StringField({ required: false, initial: "pistols", choices: SYSTEM.RANGED_SUBTYPES })
schema.properties = new fields.StringField({required: true, initial: ""})
schema.damage = new fields.StringField({required: true, initial: "1d6"})
schema.damageStat = new fields.StringField({ required: true, initial: "none", choices: {"none": "None", "skin": "Skin", "flesh": "Flesh", "heart": "Heart", "mind": "Mind", "soul": "Soul" }})
schema.damageType = new fields.StringField({ required: false, initial : "Physical" })
schema.ammo = new fields.StringField({ required: false, initial: "" })
schema.range = new fields.StringField({ required: false, initial: "" })
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["HELLBORN.Weapon"]
prepareDerivedData() {
super.prepareDerivedData();
let actor = this.parent?.actor;
if (actor) {
this.damageFormula = this.damage + (this.damageStat !== "none" ? `+${actor.system.stats[this.damageStat].value}` : "");
} else {
this.damageFormula = this.damage;
}
}
}