Update sheets and fix basic bugs
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
|
||||
export default class CthulhuEternalEquipment extends foundry.abstract.TypeDataModel {
|
||||
export default class CthulhuEternalGHear extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields
|
||||
const schema = {}
|
||||
@ -14,6 +14,6 @@ export default class CthulhuEternalEquipment extends foundry.abstract.TypeDataMo
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static LOCALIZATION_PREFIXES = ["CTHULHUETERNAL.Equipment"]
|
||||
static LOCALIZATION_PREFIXES = ["CTHULHUETERNAL.Gear"]
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
schema.hp = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
stunned: new fields.BooleanField({ required: true, initial: false })
|
||||
})
|
||||
|
||||
schema.san = new fields.SchemaField({
|
||||
|
@ -27,39 +27,21 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
|
||||
computeBase() {
|
||||
let actor = this.parent?.actor;
|
||||
if (Number(this.base)) {
|
||||
return Number(this.base) + this.bonus;
|
||||
}
|
||||
if (!actor) {
|
||||
return `${this.base } + ${ String(this.bonus)}`;
|
||||
return `${this.base} + ${ String(this.bonus)}`;
|
||||
}
|
||||
|
||||
// Split the base value per stat : WIS,DEX,STR,INT,CHA (example)
|
||||
const base = this.base;
|
||||
let baseSplit = base.split(",");
|
||||
let baseSplitLength = baseSplit.length;
|
||||
if ( baseSplitLength > 0) {
|
||||
// Select the max stat value from the parent actor
|
||||
let maxStat = 0;
|
||||
for (let i = 0; i < baseSplitLength; i++) {
|
||||
const stat = baseSplit[i];
|
||||
const statValue = actor.system.characteristics[stat.toLowerCase()]?.value || 0;
|
||||
if (statValue > maxStat) {
|
||||
maxStat = statValue;
|
||||
}
|
||||
}
|
||||
return maxStat;
|
||||
} else {
|
||||
// Split with + calculate the total
|
||||
baseSplit = base.split("+");
|
||||
baseSplitLength = baseSplit.length;
|
||||
if ( baseSplitLength > 0) {
|
||||
let total = 0;
|
||||
for (let i = 0; i < baseSplitLength; i++) {
|
||||
const stat = baseSplit[i];
|
||||
const statValue = actor.system.characteristics[stat.toLowerCase()]?.value || 0;
|
||||
total += statValue;
|
||||
}
|
||||
return total
|
||||
}
|
||||
let base = this.base.toLowerCase();
|
||||
let char = actor.system.characteristics[base];
|
||||
if (!char) {
|
||||
ui.notifications.error(`The characteristic ${base} is wrong for actor ${actor.name}`);
|
||||
return `${this.base } + ${ String(this.bonus)}`;
|
||||
}
|
||||
return `${this.base } + ${ String(this.bonus)}`;
|
||||
let charValue = char.value;
|
||||
return charValue + this.bonus
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
schema.rangeUnit = new fields.StringField({ required: true, initial: "yard", choices: SYSTEM.WEAPON_RANGE_UNIT })
|
||||
schema.lethality = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.killRadius = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.armorPiercing = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.weaponSubtype = new fields.StringField({ required: true, initial: "basicfirearm", choices: SYSTEM.WEAPON_SUBTYPE })
|
||||
|
||||
schema.resourceLevel = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
|
||||
|
Reference in New Issue
Block a user