Initial import with skill sheet worning

This commit is contained in:
2024-11-30 08:38:13 +01:00
parent 2e96b256fb
commit df8995f8b7
52 changed files with 6986 additions and 2189 deletions

View File

@ -1,8 +1,9 @@
export { default as LethalFantasyCharacter } from "./character.mjs"
export { default as LethalFantasyOpponent } from "./opponent.mjs"
export { default as LethalFantasyPath } from "./path.mjs"
export { default as LethalFantasyTalent } from "./talent.mjs"
export { default as LethalFantasyArmor } from "./armor.mjs"
export { default as LethalFantasyWeapon } from "./weapon.mjs"
export { default as LethalFantasySpell } from "./spell.mjs"
export { default as LethalFantasyAttack } from "./attack.mjs"
export { default as LethalFantasySkill } from "./skill.mjs"
export { default as LethalFantasyArmor } from "./armor.mjs"
export { default as LethalFantasyGift } from "./gift.mjs"
export { default as LethalFantasyVulnerability } from "./vulnerability.mjs"
export { default as LethalFantasySave } from "./save.mjs"

View File

@ -1,34 +1,25 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/armor.mjs"
export default class LethalFantasyArmor 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: true, textSearch: true })
schema.categorie = new fields.StringField({ required: true, initial: "sommaire", choices: SYSTEM.ARMOR_CATEGORY })
schema.valeur = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.malus = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.category = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.ARMOR_CATEGORY })
schema.protection = new fields.StringField({
required: true,
initial: ""
})
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Armor"]
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Armor"]
get armorCategory() {
return game.i18n.localize(CATEGORY[this.categorie].label)
}
get details() {
return game.i18n.format("TENEBRIS.Armor.details", {
valeur: this.valeur,
malus: this.malus,
})
get weaponCategory() {
return game.i18n.localize(CATEGORY[this.category].label)
}
}

View File

@ -1,18 +0,0 @@
export default class LethalFantasy extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.degats = new fields.StringField({ required: false, nullable: true, blank: true })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Attack"]
get toolTip() {
return this.description || ""
}
}

View File

@ -9,108 +9,83 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.langues = new fields.HTMLField({ required: true, textSearch: true })
schema.notes = new fields.HTMLField({ required: true, textSearch: true })
schema.biens = new fields.HTMLField({ required: true, textSearch: true })
// Caractéristiques
// Carac
const characteristicField = (label) => {
const schema = {
valeur: new fields.NumberField({ ...requiredInteger, initial: 10, min: 0 }),
progression: new fields.SchemaField({
experience: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
progres: new fields.BooleanField(),
}),
value: new fields.NumberField({ ...requiredInteger, initial: 3, min: 0 }),
percent: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 100 }),
attackMod: new fields.NumberField({ ...requiredInteger, initial: 0 }),
defenseMod: new fields.NumberField({ ...requiredInteger, initial: 0 })
}
return new fields.SchemaField(schema, { label })
}
schema.caracteristiques = new fields.SchemaField(
schema.characteristics = new fields.SchemaField(
Object.values(SYSTEM.CHARACTERISTICS).reduce((obj, characteristic) => {
obj[characteristic.id] = characteristicField(characteristic.label)
return obj
}, {}),
)
// Ressources
const resourceField = (label) => {
// Carac
const saveField = (label) => {
const schema = {
valeur: new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
blank: true,
}),
max: new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
blank: true,
}),
experience: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
}
return new fields.SchemaField(schema, { label })
}
schema.ressources = new fields.SchemaField(
Object.values(SYSTEM.RESOURCES).reduce((obj, resource) => {
obj[resource.id] = resourceField(resource.label)
schema.saves = new fields.SchemaField(
Object.values(SYSTEM.SAVES).reduce((obj, save) => {
obj[save.id] = saveField(save.label)
return obj
}, {}),
)
schema.commanditaire = new fields.StringField({})
schema.dv = new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
})
schema.pv = new fields.SchemaField({
schema.hp = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
})
schema.dmax = new fields.SchemaField({
valeur: new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
}),
experience: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
schema.perception = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
bonus: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.voies = new fields.SchemaField({
majeure: new fields.SchemaField({
id: new fields.DocumentIdField(),
key: new fields.StringField({ required: true }),
nom: new fields.StringField({ required: true }),
}),
mineure: new fields.SchemaField({
id: new fields.DocumentIdField(),
key: new fields.StringField({ required: true }),
nom: new fields.StringField({ required: true }),
}),
schema.grit = new fields.SchemaField({
earned: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.luck = new fields.SchemaField({
earned: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.movement = new fields.SchemaField({
walk: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
jog: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
sprint: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
run: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
armorAdjust: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
})
schema.biodata = new fields.SchemaField({
class: new fields.StringField({ required: true, nullable: false, initial: "" }),
level: new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 }),
mortal: new fields.StringField({ required: true, nullable: false, initial: "" }),
alignment: new fields.StringField({ required: true, nullable: false, initial: "" }),
age: new fields.NumberField({ ...requiredInteger, initial: 15, min: 6 }),
height: new fields.NumberField({ ...requiredInteger, initial: 170, min: 50 }),
eyes: new fields.StringField({ required: true, nullable: false, initial: "" }),
hair: new fields.StringField({ required: true, nullable: false, initial: "" })
})
schema.developmentPoints = new fields.SchemaField({
total: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
remaining: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Character"]
get hasVoieMajeure() {
return !!this.voies.majeure.id
}
get hasVoieMineure() {
return !!this.voies.mineure.id
}
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Character"]
/**
* Rolls a dice for a character.
@ -127,9 +102,6 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
rollValue = this.caracteristiques[rollTarget].valeur
opponentTarget = game.user.targets.first()
break
case ROLL_TYPE.RESOURCE:
rollValue = this.ressources[rollTarget].valeur
break
case ROLL_TYPE.DAMAGE:
rollValue = this.parent.items.get(rollTarget).system.degats
opponentTarget = game.user.targets.first()
@ -165,12 +137,6 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
})
if (!roll) return null
// Perte de ressouces
if (rollType === ROLL_TYPE.RESOURCE && roll.resultType === "failure") {
const value = this.ressources[rollTarget].valeur
const newValue = LethalFantasyUtils.findLowerDice(value)
await this.parent.update({ [`system.ressources.${rollTarget}.valeur`]: newValue })
}
await roll.toMessage({}, { rollMode: roll.options.rollMode })
}
}

View File

@ -0,0 +1,27 @@
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
const schema = {}
const requiredInteger = { required: true, nullable: false, integer: true }
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.category = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_CATEGORY })
schema.damages = new fields.StringField({
required: true,
initial: ""
})
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Equipment"]
get weaponCategory() {
return game.i18n.localize(CATEGORY[this.category].label)
}
}

16
module/models/gift.mjs Normal file
View File

@ -0,0 +1,16 @@
export default class LethalFantasyGift 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: true, textSearch: true })
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Gift"]
}

View File

@ -22,7 +22,7 @@ export default class LethalFantasyOpponent extends foundry.abstract.TypeDataMode
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Opponent"]
static LOCALIZATION_PREFIXES = ["LETHALFANTSY.Opponent"]
/**
* Rolls a dice attack for an opponent.

View File

@ -1,83 +0,0 @@
import { SYSTEM } from "../config/system.mjs"
export default class LethalFantasyPath extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.key = new fields.StringField({ required: true, nullable: false, initial: "" })
// Caractéristiques
const characteristicField = (label) => {
const schema = {
valeur: new fields.NumberField({
required: true,
nullable: false,
integer: true,
initial: 10,
min: 0,
}),
}
return new fields.SchemaField(schema, { label })
}
schema.caracteristiques = new fields.SchemaField(
Object.values(SYSTEM.CHARACTERISTICS).reduce((obj, characteristic) => {
obj[characteristic.id] = characteristicField(characteristic.label)
return obj
}, {}),
)
// Ressources
const resourceField = (label) => {
const schema = {
valeur: new fields.StringField({
required: true,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
}),
}
return new fields.SchemaField(schema, { label })
}
schema.ressources = new fields.SchemaField(
Object.values(SYSTEM.RESOURCES).reduce((obj, resource) => {
obj[resource.id] = resourceField(resource.label)
return obj
}, {}),
)
schema.dv = new fields.StringField({
required: true,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
})
schema.dmax = new fields.StringField({
required: true,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
})
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.biens = new fields.HTMLField({ required: true, textSearch: true })
schema.langues = new fields.HTMLField({ required: true, textSearch: true })
schema.talents = new fields.ArrayField(new fields.DocumentUUIDField())
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Path"]
async getAllTalents() {
const talents = []
this.talents.forEach(async (element) => {
const talent = await fromUuid(element)
if (talent) talents.push(talent)
})
return talents
}
}

17
module/models/save.mjs Normal file
View File

@ -0,0 +1,17 @@
export default class LethalFantasySave 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: true, textSearch: true })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.value = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Save"]
}

24
module/models/skill.mjs Normal file
View File

@ -0,0 +1,24 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/skill.mjs"
export default class LethalFantasySkill 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.category = new fields.StringField({ required: true, initial: "layperson", choices: SYSTEM.SKILL_CATEGORY })
schema.base = new fields.StringField({ required: true, initial: "WIS" })
schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.cost = new fields.NumberField({ ...requiredInteger,required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Skill"]
get skillCategory() {
return game.i18n.localize(CATEGORY[this.category].label)
}
}

View File

@ -11,17 +11,16 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
initial: "",
textSearch: true,
})
schema.preparation = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.cible = new fields.StringField({ required: true })
schema.portee = new fields.StringField({ required: true, initial: "contact", choices: SYSTEM.SPELL_RANGE })
schema.duree = new fields.StringField({ required: true })
schema.consequenceA = new fields.StringField({ required: true })
schema.consequenceB = new fields.StringField({ required: true })
schema.level = new fields.NumberField({
...requiredInteger,
initial: 1,
min: 1,
max: 20,
})
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Spell"]
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Spell"]
}

View File

@ -1,44 +0,0 @@
export default class LethalFantasyTalent 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: true, textSearch: true })
schema.appris = new fields.BooleanField()
schema.progression = new fields.BooleanField()
schema.niveau = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 3 })
schema.path = new fields.DocumentUUIDField()
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Talent"]
get canProgress() {
return this.progression
}
get isLearned() {
return this.appris
}
get improvedDescription() {
return this.description.replace(/#niveau\b/g, this.niveau)
}
get details() {
if (this.progression)
return game.i18n.format("TENEBRIS.Talent.details", {
niveau: this.niveau,
})
return ""
}
async getPathName() {
const path = await fromUuid(this.path)
return path ? path.name : ""
}
}

View File

@ -0,0 +1,16 @@
export default class LethalFantasyVulnerability 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: true, textSearch: true })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Vulnerability"]
}

View File

@ -1,24 +1,27 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/weapon.mjs"
export default class LethalFantasyWeapon extends foundry.abstract.TypeDataModel {
export default class LethalFantasySkill 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.categorie = new fields.StringField({ required: true, initial: "mains", choices: SYSTEM.WEAPON_CATEGORY })
schema.degats = new fields.StringField({
schema.category = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_CATEGORY })
schema.damages = new fields.StringField({
required: true,
initial: SYSTEM.WEAPON_DAMAGE.UN,
choices: Object.fromEntries(Object.entries(SYSTEM.WEAPON_DAMAGE).map(([key, value]) => [value, { label: `${value}` }])),
initial: ""
})
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Weapon"]
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Weapon"]
get weaponCategory() {
return game.i18n.localize(CATEGORY[this.categorie].label)
return game.i18n.localize(CATEGORY[this.category].label)
}
}