Add rituals and tomes and creatures
All checks were successful
Release Creation / build (release) Successful in 48s
All checks were successful
Release Creation / build (release) Successful in 48s
This commit is contained in:
@ -11,4 +11,5 @@ export { default as CthulhuEternalMotivationSheet } from "./sheets/motivation-sh
|
||||
export { default as CthulhuEternalArchetypeSheet } from "./sheets/archetype-sheet.mjs"
|
||||
export { default as CthulhuEternalRitualSheet } from "./sheets/ritual-sheet.mjs"
|
||||
export { default as CthulhuEternalVehicleSheet } from "./sheets/vehicle-sheet.mjs"
|
||||
export { default as CthulhuEternalCreatureSheet } from "./sheets/creature-sheet.mjs"
|
||||
export { default as CthulhuEternalTomeSheet } from "./sheets/tome-sheet.mjs"
|
||||
|
175
module/applications/sheets/creature-sheet.mjs
Normal file
175
module/applications/sheets/creature-sheet.mjs
Normal file
@ -0,0 +1,175 @@
|
||||
import CthulhuEternalActorSheet from "./base-actor-sheet.mjs"
|
||||
|
||||
export default class CthulhuEternalCreatureSheet extends CthulhuEternalActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["creature"],
|
||||
position: {
|
||||
width: 860,
|
||||
height: 620,
|
||||
},
|
||||
window: {
|
||||
contentClasses: ["creature-content"],
|
||||
},
|
||||
actions: {
|
||||
createArmor: CthulhuEternalCreatureSheet.#onCreateArmor,
|
||||
createWeapon: CthulhuEternalCreatureSheet.#onCreateWeapon,
|
||||
createSkill: CthulhuEternalCreatureSheet.#onCreateSkill,
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/fvtt-cthulhu-eternal/templates/creature-main.hbs",
|
||||
},
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs",
|
||||
},
|
||||
skills: {
|
||||
template: "systems/fvtt-cthulhu-eternal/templates/creature-skills.hbs",
|
||||
},
|
||||
biography: {
|
||||
template: "systems/fvtt-cthulhu-eternal/templates/creature-biography.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = {
|
||||
sheet: "skills",
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare an array of form header tabs.
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
*/
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
skills: { id: "skills", group: "sheet", icon: "fa-solid fa-shapes", label: "CTHULHUETERNAL.Label.skills" },
|
||||
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "CTHULHUETERNAL.Label.biography" },
|
||||
}
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] === v.id
|
||||
v.cssClass = v.active ? "active" : ""
|
||||
}
|
||||
return tabs
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.tabs = this.#getTabs()
|
||||
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
context.tooltipsCharacteristic = {
|
||||
str: game.i18n.localize("CTHULHUETERNAL.Characteristic.Str"),
|
||||
dex: game.i18n.localize("CTHULHUETERNAL.Characteristic.Dex"),
|
||||
con: game.i18n.localize("CTHULHUETERNAL.Characteristic.Con"),
|
||||
int: game.i18n.localize("CTHULHUETERNAL.Characteristic.Int"),
|
||||
pow: game.i18n.localize("CTHULHUETERNAL.Characteristic.Pow"),
|
||||
cha: game.i18n.localize("CTHULHUETERNAL.Characteristic.Cha")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
break
|
||||
case "skills":
|
||||
context.tab = context.tabs.skills
|
||||
context.skills = doc.itemTypes.skill
|
||||
context.skills.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.weapons = doc.itemTypes.weapon
|
||||
context.weapons.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.armors = doc.itemTypes.armor
|
||||
context.armors.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new attack item directly from the sheet and embeds it into the document.
|
||||
* @param {Event} event The initiating click event.
|
||||
* @param {HTMLElement} target The current target of the event listener.
|
||||
*/
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newWeapon"), type: "weapon" }])
|
||||
}
|
||||
|
||||
static #onCreateArmor(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newArmor"), type: "armor" }])
|
||||
}
|
||||
|
||||
static #onCreateSkill(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newSkill"), type: "skill" }])
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the roll action triggered by user interaction.
|
||||
*
|
||||
* @param {PointerEvent} event The event object representing the user interaction.
|
||||
* @param {HTMLElement} target The target element that triggered the roll.
|
||||
*
|
||||
* @returns {Promise<void>} A promise that resolves when the roll action is complete.
|
||||
*
|
||||
* @throws {Error} Throws an error if the roll type is not recognized.
|
||||
*
|
||||
* @description This method checks the current mode (edit or not) and determines the type of roll
|
||||
* (save, resource, or damage) based on the target element's data attributes. It retrieves the
|
||||
* corresponding value from the document's system and performs the roll.
|
||||
*/
|
||||
async _onRoll(event, target) {
|
||||
const rollType = $(event.currentTarget).data("roll-type")
|
||||
let item
|
||||
let li
|
||||
// Debug : console.log(">>>>", event, target, rollType)
|
||||
// Deprecated : if (this.isEditMode) return
|
||||
switch (rollType) {
|
||||
case "char":
|
||||
let charId = $(event.currentTarget).data("char-id")
|
||||
item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
|
||||
item.name = game.i18n.localize(`CTHULHUETERNAL.Label.${charId}Long`)
|
||||
item.targetScore = item.value * 5
|
||||
break
|
||||
case "skill":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
break
|
||||
case "weapon":
|
||||
case "damage":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
item.damageBonus = this.actor.system.damageBonus
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unknown roll type ${rollType}`)
|
||||
}
|
||||
await this.document.system.roll(rollType, item)
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
const data = TextEditor.getDragEventData(event)
|
||||
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
case "Item":
|
||||
const item = await fromUuid(data.uuid)
|
||||
return super._onDropItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -178,16 +178,22 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
console.log("WP Not found", era, options.rollItem.system.weaponType)
|
||||
return
|
||||
}
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.weapon = options.rollItem
|
||||
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
|
||||
if (!options.rollItem) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponSkill"))
|
||||
return
|
||||
if (options.rollItem.system.hasDirectSkill) {
|
||||
let skillName = options.rollItem.name
|
||||
options.rollItem = {type: "skill", name: skillName, system: {base: 0, bonus: options.weapon.system.directSkillValue} }
|
||||
options.initialScore = options.weapon.system.directSkillValue
|
||||
} else {
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
|
||||
if (!options.rollItem) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponSkill"))
|
||||
return
|
||||
}
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
console.log("WEAPON", skillName, era, options.rollItem)
|
||||
}
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
console.log("WEAPON", skillName, era, options.rollItem)
|
||||
break
|
||||
default:
|
||||
options.initialScore = 50
|
||||
|
@ -11,5 +11,6 @@ export { default as CthulhuEternalMotivation } from "./motivation.mjs"
|
||||
export { default as CthulhuEternalArchetype } from "./archetype.mjs"
|
||||
export { default as CthulhuEternalRitual } from "./ritual.mjs"
|
||||
export { default as CthulhuEternalVehicle } from "./vehicle.mjs"
|
||||
export { default as CthulhuEternalCreature } from "./creature.mjs"
|
||||
export { default as CthulhuEternalTome } from "./tome.mjs"
|
||||
|
||||
|
80
module/models/creature.mjs
Normal file
80
module/models/creature.mjs
Normal file
@ -0,0 +1,80 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import CthulhuEternalRoll from "../documents/roll.mjs"
|
||||
|
||||
export default class CthulhuEternalCreature extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
const schema = {}
|
||||
|
||||
// Carac
|
||||
const characteristicField = (label) => {
|
||||
const schema = {
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 3, min: 0 }),
|
||||
feature: new fields.StringField({ required: true, nullable: false, initial: "" })
|
||||
}
|
||||
return new fields.SchemaField(schema, { label })
|
||||
}
|
||||
|
||||
schema.characteristics = new fields.SchemaField(
|
||||
Object.values(SYSTEM.CHARACTERISTICS).reduce((obj, characteristic) => {
|
||||
obj[characteristic.id] = characteristicField(characteristic.label)
|
||||
return obj
|
||||
}, {}),
|
||||
)
|
||||
|
||||
schema.wp = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 3, min: 0 }),
|
||||
exhausted: new fields.BooleanField({ required: true, initial: false })
|
||||
})
|
||||
|
||||
schema.hp = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 })
|
||||
})
|
||||
schema.movement = new fields.StringField({ required: true, initial: "" })
|
||||
schema.sanLoss = new fields.StringField({ required: true, initial: "1/1D6" })
|
||||
|
||||
schema.armor = new fields.StringField({ required: true, initial: "" })
|
||||
schema.size = new fields.StringField({ required: true, initial: "medium", choices: SYSTEM.CREATURE_SIZE })
|
||||
schema.damageBonus = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.notes = new fields.HTMLField({ required: true, textSearch: true })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static LOCALIZATION_PREFIXES = ["CTHULHUETERNAL.Creature"]
|
||||
|
||||
/** */
|
||||
/**
|
||||
* Rolls a dice for a character.
|
||||
* @param {("save"|"resource|damage")} rollType The type of the roll.
|
||||
* @param {number} rollItem The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
|
||||
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
|
||||
*/
|
||||
async roll(rollType, rollItem) {
|
||||
let opponentTarget
|
||||
const hasTarget = opponentTarget !== undefined
|
||||
|
||||
let roll = await CthulhuEternalRoll.prompt({
|
||||
rollType,
|
||||
rollItem,
|
||||
isLowWP: false,
|
||||
isZeroWP: false,
|
||||
isExhausted: false,
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
hasTarget,
|
||||
target: opponentTarget
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,9 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
schema.settings = new fields.StringField({ required: true, initial: setting, choices: SYSTEM.AVAILABLE_SETTINGS })
|
||||
|
||||
schema.weaponType = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_TYPE })
|
||||
schema.hasDirectSkill = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.directSkillValue = new fields.NumberField({ required: true, initial: 0, min: 0, max:99 })
|
||||
|
||||
schema.damage = new fields.StringField({required: true, initial: "1d6"})
|
||||
schema.baseRange = new fields.StringField({required: true, initial: ""})
|
||||
schema.rangeUnit = new fields.StringField({ required: true, initial: "yard", choices: SYSTEM.WEAPON_RANGE_UNIT })
|
||||
|
Reference in New Issue
Block a user