Add vehicle type
This commit is contained in:
@@ -9,3 +9,4 @@ export { default as CthulhuEternalMentalDisorderSheet } from "./sheets/mentaldis
|
||||
export { default as CthulhuEternalGearSheet } from "./sheets/gear-sheet.mjs"
|
||||
export { default as CthulhuEternalMotivationSheet } from "./sheets/motivation-sheet.mjs"
|
||||
export { default as CthulhuEternalArchetypeSheet } from "./sheets/archetype-sheet.mjs"
|
||||
export { default as CthulhuEternalVehicleSheet } from "./sheets/vehicle-sheet.mjs"
|
||||
|
@@ -85,23 +85,9 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
cha: game.i18n.localize("CTHULHUETERNAL.Characteristic.Cha")
|
||||
}
|
||||
|
||||
context.tooltipsRessources = {
|
||||
}
|
||||
|
||||
context.rollType = {
|
||||
str: "characteristic",
|
||||
dex: "characteristic",
|
||||
con: "characteristic",
|
||||
int: "characteristic",
|
||||
pow: "characteristic",
|
||||
cha: "characteristic"
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
_generateTooltip(type, target) {
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
|
117
module/applications/sheets/vehicle-sheet.mjs
Normal file
117
module/applications/sheets/vehicle-sheet.mjs
Normal file
@@ -0,0 +1,117 @@
|
||||
import CthulhuEternalActorSheet from "./base-actor-sheet.mjs"
|
||||
|
||||
export default class CthulhuEternalVehicleSheet extends CthulhuEternalActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["vehicle"],
|
||||
position: {
|
||||
width: 680,
|
||||
height: 540,
|
||||
},
|
||||
window: {
|
||||
contentClasses: ["vehicle-content"],
|
||||
},
|
||||
actions: {
|
||||
createGear: CthulhuEternalVehicleSheet.#onCreateGear,
|
||||
createWeapon: CthulhuEternalVehicleSheet.#onCreateWeapon,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/fvtt-cthulhu-eternal/templates/vehicle-main.hbs",
|
||||
},
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs",
|
||||
},
|
||||
equipment: {
|
||||
template: "systems/fvtt-cthulhu-eternal/templates/vehicle-equipment.hbs",
|
||||
},
|
||||
description: {
|
||||
template: "systems/fvtt-cthulhu-eternal/templates/vehicle-description.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = {
|
||||
sheet: "equipment",
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare an array of form header tabs.
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
*/
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-shapes", label: "CTHULHUETERNAL.Label.equipment" },
|
||||
description: { id: "description", group: "sheet", icon: "fa-solid fa-book", label: "CTHULHUETERNAL.Label.description" },
|
||||
}
|
||||
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 })
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
_generateTooltip(type, target) {
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
break
|
||||
case "equipment":
|
||||
context.tab = context.tabs.equipment
|
||||
context.weapons = doc.itemTypes.weapon
|
||||
context.gears = doc.itemTypes.gear
|
||||
break
|
||||
case "description":
|
||||
context.tab = context.tabs.description
|
||||
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 #onCreateGear(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newGear"), type: "gear" }])
|
||||
}
|
||||
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newWeapon"), type: "weapon" }])
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -113,6 +113,19 @@ export const RESOURCE_BREAKDOWN = [
|
||||
{ value: 20, hand: 6, stowed: 6, storage: 8, checks: 3}
|
||||
]
|
||||
|
||||
export const VEHICLE_SPEED = {
|
||||
"none": "CTHULHUETERNAL.Label.None",
|
||||
"slow": "CTHULHUETERNAL.Label.Slow",
|
||||
"average": "CTHULHUETERNAL.Label.Average",
|
||||
"fast": "CTHULHUETERNAL.Label.Fast"
|
||||
}
|
||||
|
||||
export const EQUIPMENT_STATES = {
|
||||
"pristine": "CTHULHUETERNAL.Label.Pristine",
|
||||
"worn": "CTHULHUETERNAL.Label.Worn",
|
||||
"junk": "CTHULHUETERNAL.Label.Junk"
|
||||
}
|
||||
|
||||
export const MENTAL_ILLNESS_CURE_SKILL = {
|
||||
jazz: "CTHULHUETERNAL.Skill.Psychoanalyze",
|
||||
modern: "CTHULHUETERNAL.Skill.Psychoanalyze",
|
||||
@@ -213,6 +226,8 @@ export const SYSTEM = {
|
||||
MENTAL_ILLNESS_CURE_SKILL,
|
||||
ERA_CSS,
|
||||
INSANITY,
|
||||
EQUIPMENT_STATES,
|
||||
RESOURCE_BREAKDOWN,
|
||||
VEHICLE_SPEED,
|
||||
ASCII
|
||||
}
|
||||
|
@@ -9,3 +9,5 @@ export { default as CthulhuEternalBond } from "./bond.mjs"
|
||||
export { default as CthulhuEternalGear } from "./gear.mjs"
|
||||
export { default as CthulhuEternalMotivation } from "./motivation.mjs"
|
||||
export { default as CthulhuEternalArchetype } from "./archetype.mjs"
|
||||
export { default as CthulhuEternalVehicle } from "./vehicle.mjs"
|
||||
|
||||
|
@@ -9,6 +9,7 @@ export default class CthulhuEternalGHear extends foundry.abstract.TypeDataModel
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.settings = new fields.StringField({ required: true, initial: "modern", choices: SYSTEM.AVAILABLE_SETTINGS })
|
||||
schema.resourceLevel = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.state = new fields.StringField({ required: true, initial: "pristine", choices: SYSTEM.EQUIPMENT_STATES })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
@@ -33,8 +33,8 @@ 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 }),
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
stunned: new fields.BooleanField({ required: true, initial: false })
|
||||
})
|
||||
|
||||
@@ -146,20 +146,23 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
updates[`system.hp.value`] = this.hp.max
|
||||
}
|
||||
|
||||
if ( this.resources.permanentRating <= 20) {
|
||||
let breakdown = SYSTEM.RESOURCE_BREAKDOWN[this.resources.permanentRating]
|
||||
if (this.resources.hand !== breakdown.hand) {
|
||||
updates[`system.resources.hand`] = breakdown.hand
|
||||
}
|
||||
if (this.resources.stowed !== breakdown.stowed) {
|
||||
updates[`system.resources.stowed`] = breakdown.stowed
|
||||
}
|
||||
if (this.resources.storage !== breakdown.storage) {
|
||||
updates[`system.resources.storage`] = breakdown.storage
|
||||
}
|
||||
if (this.resources.nbValidChecks !== breakdown.checks) {
|
||||
updates[`system.resources.nbValidChecks`] = breakdown.checks
|
||||
}
|
||||
if (this.resources.permanentRating < 0) {
|
||||
updates[`system.resources.permanentRating`] = 0
|
||||
}
|
||||
|
||||
let resourceIndex = Math.max(Math.min(this.resources.permanentRating, 20), 0)
|
||||
let breakdown = SYSTEM.RESOURCE_BREAKDOWN[this.resources.resourceIndex]
|
||||
if (this.resources.hand !== breakdown.hand) {
|
||||
updates[`system.resources.hand`] = breakdown.hand
|
||||
}
|
||||
if (this.resources.stowed !== breakdown.stowed) {
|
||||
updates[`system.resources.stowed`] = breakdown.stowed
|
||||
}
|
||||
if (this.resources.storage !== breakdown.storage) {
|
||||
updates[`system.resources.storage`] = breakdown.storage + (this.resources.permanentRating - resourceIndex)
|
||||
}
|
||||
if (this.resources.nbValidChecks !== breakdown.checks) {
|
||||
updates[`system.resources.nbValidChecks`] = breakdown.checks
|
||||
}
|
||||
|
||||
if (Object.keys(updates).length > 0) {
|
||||
|
34
module/models/vehicle.mjs
Normal file
34
module/models/vehicle.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import CthulhuEternalRoll from "../documents/roll.mjs"
|
||||
|
||||
export default class CthulhuEternalVehicle extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
const schema = {}
|
||||
|
||||
schema.settings = new fields.StringField({ required: true, initial: "modern", choices: SYSTEM.AVAILABLE_SETTINGS })
|
||||
|
||||
schema.hp = new fields.SchemaField({
|
||||
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
|
||||
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 })
|
||||
})
|
||||
|
||||
schema.armor = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
schema.surfaceSpeed = new fields.StringField({ required: true, initial: "slow", choices: SYSTEM.VEHICLE_SPEED })
|
||||
schema.airSpeed = new fields.StringField({ required: true, initial: "none", choices: SYSTEM.VEHICLE_SPEED })
|
||||
schema.state = new fields.StringField({ required: true, initial: "pristine", choices: SYSTEM.EQUIPMENT_STATES })
|
||||
|
||||
schema.crew = new fields.ArrayField(new fields.StringField(), { required: false, initial: [], min:0 })
|
||||
schema.resourceLevel = new fields.NumberField({ required: true, 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.Vehicle"]
|
||||
|
||||
}
|
@@ -17,6 +17,7 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
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.state = new fields.StringField({ required: true, initial: "pristine", choices: SYSTEM.EQUIPMENT_STATES })
|
||||
|
||||
schema.resourceLevel = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
|
||||
|
Reference in New Issue
Block a user