This commit is contained in:
@@ -22,7 +22,7 @@ export default class FTLNomadArmorSheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ export default class FTLNomadActorSheet extends HandlebarsApplicationMixin(found
|
||||
actor: this.document,
|
||||
system: this.document.system,
|
||||
source: this.document.toObject(),
|
||||
isEncumbered: this.document.system.isEncumbered(),
|
||||
enrichedDescription: await TextEditor.enrichHTML(this.document.system.description, { async: true }),
|
||||
isEncumbered: this.document.system.isEncumbered(),
|
||||
enrichedDescription: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true }),
|
||||
isEditMode: this.isEditMode,
|
||||
isPlayMode: this.isPlayMode,
|
||||
isEditable: this.isEditable,
|
||||
@@ -99,7 +99,7 @@ export default class FTLNomadActorSheet extends HandlebarsApplicationMixin(found
|
||||
dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this),
|
||||
}
|
||||
return new DragDrop(d)
|
||||
return new foundry.applications.ux.DragDrop.implementation(d)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export default class FTLNomadActorSheet extends HandlebarsApplicationMixin(found
|
||||
_onDragOver(event) {}
|
||||
|
||||
async _onDropItem(item) {
|
||||
console.log("Dropped item", item)
|
||||
console.log("Dropped item", item)
|
||||
let itemData = item.toObject()
|
||||
await this.document.createEmbeddedDocuments("Item", [itemData], { renderSheet: false })
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export default class FTLNomadItemSheet extends HandlebarsApplicationMixin(foundr
|
||||
item: this.document,
|
||||
system: this.document.system,
|
||||
source: this.document.toObject(),
|
||||
enrichedDescription: await TextEditor.enrichHTML(this.document.system.description, { async: true }),
|
||||
enrichedDescription: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true }),
|
||||
isEditMode: this.isEditMode,
|
||||
isPlayMode: this.isPlayMode,
|
||||
isEditable: this.isEditable,
|
||||
@@ -94,7 +94,7 @@ export default class FTLNomadItemSheet extends HandlebarsApplicationMixin(foundr
|
||||
dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this),
|
||||
}
|
||||
return new DragDrop(d)
|
||||
return new foundry.applications.ux.DragDrop.implementation(d)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
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.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
@@ -103,8 +103,8 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
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 })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
@@ -138,7 +138,7 @@ export default class FTLNomadCharacterSheet extends FTLNomadActorSheet {
|
||||
static #onCreateLanguage(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("FTLNOMAD.Label.newLanguage"), type: "language" }])
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handles the roll action triggered by user interaction.
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class FTLNomadCreatureAbilitySheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ export default class FTLNomadCreatureSheet extends FTLNomadActorSheet {
|
||||
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.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
@@ -80,8 +80,8 @@ export default class FTLNomadCreatureSheet extends FTLNomadActorSheet {
|
||||
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 })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class FTLNomadCreatureTraitSheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class FTLNomadEquipmentSheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class FTLNomadLanguageSheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class FTLNomadPsionicSheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ export default class FTLNomadStarshipSheet extends FTLNomadActorSheet {
|
||||
tabGroups = {
|
||||
sheet: "description",
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare an array of form header tabs.
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
@@ -53,10 +53,10 @@ export default class FTLNomadStarshipSheet extends FTLNomadActorSheet {
|
||||
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.enrichedModifications = await TextEditor.enrichHTML(this.document.system.modifications, { async: true })
|
||||
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
|
||||
context.enrichedModifications = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.modifications, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ export default class FTLNomadStarshipSheet extends FTLNomadActorSheet {
|
||||
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 })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class FTLNomadTalentSheet extends FTLNomadItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class FTLNomadVehicleSheet extends FTLNomadActorSheet {
|
||||
tabGroups = {
|
||||
sheet: "equipment",
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare an array of form header tabs.
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
@@ -59,9 +59,9 @@ export default class FTLNomadVehicleSheet extends FTLNomadActorSheet {
|
||||
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.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ export default class FTLNomadVehicleSheet extends FTLNomadActorSheet {
|
||||
context.weapons.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.equipments = doc.itemTypes.equipment
|
||||
context.equipments.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
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 })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
|
||||
@@ -63,7 +63,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
static updateFullFormula(options) {
|
||||
let fullFormula
|
||||
if ( options.numericModifier >= 0) {
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} + ${options.numericModifier}D`
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} + ${options.numericModifier}D`
|
||||
} else {
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} - ${Math.abs(options.numericModifier)}D`
|
||||
}
|
||||
@@ -100,7 +100,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
});
|
||||
return
|
||||
case "weapon":
|
||||
let actor = game.actors.get(options.actorId)
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.weapon = foundry.utils.duplicate(options.rollItem)
|
||||
options.rollItem = actor.system.skills.combat
|
||||
break
|
||||
@@ -108,7 +108,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
break
|
||||
}
|
||||
|
||||
const rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
@@ -125,7 +125,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
choiceRangeModifier[key] = { label: `${key} (${value}D)`, value: value }
|
||||
if (!rangeModifier && value) {
|
||||
rangeModifier = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
hasTarget: options.hasTarget,
|
||||
modifier,
|
||||
}
|
||||
const content = await renderTemplate("systems/fvtt-ftl-nomad/templates/roll-dialog.hbs", dialogContext)
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-ftl-nomad/templates/roll-dialog.hbs", dialogContext)
|
||||
|
||||
const title = FTLNomadRoll.createTitle(options.rollType, options.rollTarget)
|
||||
const label = game.i18n.localize("FTLNOMAD.Roll.roll")
|
||||
@@ -215,7 +215,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
rollData.targetScore = 8
|
||||
|
||||
if (Hooks.call("fvtt-ftl-nomad.preRoll", options, rollData) === false) return
|
||||
|
||||
|
||||
let diceFormula = `${2+Math.abs(options.numericModifier)}D6`
|
||||
if ( options.numericModifier > 0 ) {
|
||||
diceFormula += `kh2 + ${options.rollItem.value}`
|
||||
@@ -239,12 +239,12 @@ export default class FTLNomadRoll extends Roll {
|
||||
let resultType = "failure"
|
||||
if (this.total >= 8) {
|
||||
resultType = "success"
|
||||
// Detect if decimal == unit in the dire total result
|
||||
// Detect if decimal == unit in the dire total result
|
||||
}
|
||||
|
||||
this.options.resultType = resultType
|
||||
this.options.isSuccess = resultType === "success"
|
||||
this.options.isFailure = resultType === "failure"
|
||||
this.options.isSuccess = resultType === "success"
|
||||
this.options.isFailure = resultType === "failure"
|
||||
this.options.isEncumbered = rollData.isEncumbered
|
||||
this.options.rollData = foundry.utils.duplicate(rollData)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ export default class FTLNomadRoll extends Roll {
|
||||
/** @override */
|
||||
async render(chatOptions = {}) {
|
||||
let chatData = await this._getChatCardData(chatOptions.isPrivate)
|
||||
return await renderTemplate(this.constructor.CHAT_TEMPLATE, chatData)
|
||||
return await foundry.applications.handlebars.renderTemplate(this.constructor.CHAT_TEMPLATE, chatData)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,11 +7,12 @@ export default class FTLNomadImplant extends foundry.abstract.TypeDataModel {
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
|
||||
|
||||
schema.techAge = new fields.StringField({ required: true, choices: SYSTEM.TECH_AGES, initial : "lateatomic" })
|
||||
|
||||
schema.enc = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.loss = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
348
module/utils.mjs
348
module/utils.mjs
@@ -195,4 +195,352 @@ export default class FTLNomadUtils {
|
||||
document.documentElement.style.setProperty('--background-image-base', `linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.8)), url("../assets/ui/${era}_background_main.webp")`);
|
||||
}
|
||||
|
||||
static getTechAgeKeyFromLabel(label) {
|
||||
return Object.keys(SYSTEM.TECH_AGES).find(key => game.i18n.localize(SYSTEM.TECH_AGES[key].label) === label);
|
||||
}
|
||||
|
||||
static async importPsionics() {
|
||||
// Create a psionics folder if it doesn't exist
|
||||
const psionicsFolder = game.folders.getName("Psionics") || await Folder.create({
|
||||
name: "Psionics", type: "Item"
|
||||
})
|
||||
if (!psionicsFolder) {
|
||||
console.error("Failed to create Psionics folder");
|
||||
return;
|
||||
}
|
||||
// Load the psionics JSON file
|
||||
const psionicsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/psionics.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load psionics data:", error);
|
||||
return [];
|
||||
});
|
||||
// Import each psionic ability
|
||||
for (const psionic of psionicsData) {
|
||||
// Check if the psionic already exists
|
||||
const existingPsionic = game.items.find(i => i.name === psionic.name && i.type === "psionic");
|
||||
if (existingPsionic) {
|
||||
console.warn(`Psionic ${psionic.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the psionic item
|
||||
await Item.create({
|
||||
name: psionic.name,
|
||||
type: "psionic",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_psionic.svg",
|
||||
system: {
|
||||
description: psionic.description,
|
||||
},
|
||||
folder: psionicsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importTalents() {
|
||||
// Create a talents folder if it doesn't exist
|
||||
const talentsFolder = game.folders.getName("Talents") || await Folder.create({
|
||||
name: "Talents", type: "Item"
|
||||
})
|
||||
if (!talentsFolder) {
|
||||
console.error("Failed to create Talents folder");
|
||||
return;
|
||||
}
|
||||
// Load the talents JSON file
|
||||
const talentsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/talents.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load talents data:", error);
|
||||
return [];
|
||||
});
|
||||
// Import each talent
|
||||
for (const talent of talentsData) {
|
||||
// Check if the talent already exists
|
||||
const existingTalent = game.items.find(i => i.name === talent.name && i.type === "talent");
|
||||
if (existingTalent) {
|
||||
console.warn(`Talent ${talent.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
talent.advantage = false;
|
||||
if (talent.description.includes(" +1D")) {
|
||||
talent.advantage = true
|
||||
}
|
||||
// Create the talent item
|
||||
await Item.create({
|
||||
name: talent.name,
|
||||
type: "talent",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_talent.svg",
|
||||
system: {
|
||||
description: talent.description,
|
||||
isAdvantage: talent.advantage,
|
||||
},
|
||||
folder: talentsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importImplants() {
|
||||
// Create a implants folder if it doesn't exist
|
||||
const implantsFolder = game.folders.getName("Implants") || await Folder.create({
|
||||
name: "Implants", type: "Item"
|
||||
})
|
||||
if (!implantsFolder) {
|
||||
console.error("Failed to create Implants folder");
|
||||
return;
|
||||
}
|
||||
// Load the implants JSON file
|
||||
const implantsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/implants.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load implants data:", error);
|
||||
return [];
|
||||
});
|
||||
// Import each implant
|
||||
for (const implant of implantsData) {
|
||||
// Check if the implant already exists
|
||||
const existingImplant = game.items.find(i => i.name === implant.name && i.type === "implant");
|
||||
if (existingImplant) {
|
||||
console.warn(`Implant ${implant.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
if (!Number(implant.cost)) {
|
||||
implant.cost = 1000000;
|
||||
}
|
||||
// Create the implant item
|
||||
await Item.create({
|
||||
name: implant.name,
|
||||
type: "implant",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_implant.svg",
|
||||
system: {
|
||||
cost: implant.cost,
|
||||
loss: implant.loss,
|
||||
techAge: this.getTechAgeKeyFromLabel(implant.tech_age),
|
||||
description: implant.description,
|
||||
},
|
||||
folder: implantsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importDrugs() {
|
||||
// Create a drugs folder if it doesn't exist
|
||||
const drugsFolder = game.folders.getName("Drugs") || await Folder.create({
|
||||
name: "Drugs", type: "Item"
|
||||
})
|
||||
if (!drugsFolder) {
|
||||
console.error("Failed to create Drugs folder");
|
||||
return;
|
||||
}
|
||||
// Load the drugs JSON file
|
||||
const drugsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/drugs.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load drugs data:", error);
|
||||
return [];
|
||||
});
|
||||
// Import each drug
|
||||
for (const drug of drugsData) {
|
||||
// Check if the drug already exists
|
||||
const existingDrug = game.items.find(i => i.name === drug.name && i.type === "drug");
|
||||
if (existingDrug) {
|
||||
console.warn(`Drug ${drug.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the drug item
|
||||
await Item.create({
|
||||
name: drug.name,
|
||||
type: "equipment",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_equipment.svg",
|
||||
system: {
|
||||
description: drug.description,
|
||||
cost: drug.cost,
|
||||
techAge: this.getTechAgeKeyFromLabel(drug.tech_age),
|
||||
},
|
||||
folder: drugsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importEquipments() {
|
||||
// Create a equipments folder if it doesn't exist
|
||||
const equipmentsFolder = game.folders.getName("Equipments") || await Folder.create({
|
||||
name: "Equipments", type: "Item"
|
||||
})
|
||||
if (!equipmentsFolder) {
|
||||
console.error("Failed to create Equipments folder");
|
||||
return;
|
||||
}
|
||||
// Load the equipments JSON file
|
||||
const equipmentsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/exploration_equipment.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load equipments data:", error);
|
||||
return [];
|
||||
});
|
||||
// Import each equipment
|
||||
for (const equipment of equipmentsData) {
|
||||
// Check if the equipment already exists
|
||||
const existingEquipment = game.items.find(i => i.name === equipment.name && i.type === "equipment");
|
||||
if (existingEquipment) {
|
||||
console.warn(`Equipment ${equipment.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
if (!Number(equipment.cost)) {
|
||||
equipment.cost = 1000000;
|
||||
}
|
||||
|
||||
// Create the equipment item
|
||||
await Item.create({
|
||||
name: equipment.name,
|
||||
type: "equipment",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_equipment.svg",
|
||||
system: {
|
||||
description: equipment.description,
|
||||
cost: equipment.cost,
|
||||
techAge: this.getTechAgeKeyFromLabel(equipment.tech_age),
|
||||
},
|
||||
folder: equipmentsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importDistanceWeapons() {
|
||||
// Create a distance weapons folder if it doesn't exist
|
||||
const distanceWeaponsFolder = game.folders.getName("Vehicle Weapons") || await Folder.create({
|
||||
name: "Vehicle Weapons", type: "Item"
|
||||
})
|
||||
if (!distanceWeaponsFolder) {
|
||||
console.error("Failed to create Distance Weapons folder");
|
||||
return;
|
||||
}
|
||||
// Load the distance weapons JSON file
|
||||
const distanceWeaponsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/vehicle_weapons.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load distance weapons data:", error);
|
||||
return [];
|
||||
});
|
||||
|
||||
// Import each distance weapon
|
||||
for (const weapon of distanceWeaponsData) {
|
||||
// Check if the weapon already exists
|
||||
const existingWeapon = game.items.find(i => i.name === weapon.name && i.type === "weapon");
|
||||
if (existingWeapon) {
|
||||
console.warn(`Weapon ${weapon.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the weapon item
|
||||
await Item.create({
|
||||
name: weapon.name,
|
||||
type: "weapon",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_weapon.svg",
|
||||
system: {
|
||||
description: weapon.description,
|
||||
damage: weapon.damage,
|
||||
techAge: this.getTechAgeKeyFromLabel(weapon.tech_age),
|
||||
weaponType: SYSTEM.WEAPON_TYPES.vehicle.id,
|
||||
rangeType: weapon.range.toLowerCase(),
|
||||
enc: 0,
|
||||
aspect: weapon.aspects.join(", "),
|
||||
cost: weapon.cost || 0,
|
||||
ammoCost: weapon.ammo_cost || 0,
|
||||
magazine: weapon.mag || 1,
|
||||
},
|
||||
folder: distanceWeaponsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importGrenadeWeapons() {
|
||||
// Create a grenade weapons folder if it doesn't exist
|
||||
const grenadeWeaponsFolder = game.folders.getName("Grenade") || await Folder.create({
|
||||
name: "Grenade", type: "Item"
|
||||
})
|
||||
if (!grenadeWeaponsFolder) {
|
||||
console.error("Failed to create Grenade Weapons folder");
|
||||
return;
|
||||
}
|
||||
// Load the grenade weapons JSON file
|
||||
const grenadeWeaponsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/grenades.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load grenade weapons data:", error);
|
||||
return [];
|
||||
});
|
||||
|
||||
// Import each grenade weapon
|
||||
for (const weapon of grenadeWeaponsData) {
|
||||
// Check if the weapon already exists
|
||||
const existingWeapon = game.items.find(i => i.name === weapon.name && i.type === "weapon");
|
||||
if (existingWeapon) {
|
||||
console.warn(`Weapon ${weapon.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the weapon item
|
||||
await Item.create({
|
||||
name: weapon.name,
|
||||
type: "weapon",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_weapon.svg",
|
||||
system: {
|
||||
description: weapon.description,
|
||||
damage: weapon.damage,
|
||||
techAge: this.getTechAgeKeyFromLabel(weapon.tech_age),
|
||||
weaponType: SYSTEM.WEAPON_TYPES.grenade.id,
|
||||
rangeType: SYSTEM.WEAPON_RANGE.thrownweapon.id,
|
||||
enc: 0,
|
||||
aspect: weapon.aspects.join(", "),
|
||||
cost: weapon.cost || 0,
|
||||
ammoCost: 0,
|
||||
},
|
||||
folder: grenadeWeaponsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importMeleeWeapons() {
|
||||
// Create a melee weapons folder if it doesn't exist
|
||||
const meleeWeaponsFolder = game.folders.getName("Melee Weapons") || await Folder.create({
|
||||
name: "Melee Weapons", type: "Item"
|
||||
})
|
||||
if (!meleeWeaponsFolder) {
|
||||
console.error("Failed to create Melee Weapons folder");
|
||||
return;
|
||||
}
|
||||
// Load the melee weapons JSON file
|
||||
const meleeWeaponsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/weapon_melee.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load melee weapons data:", error);
|
||||
return [];
|
||||
});
|
||||
|
||||
console.log("Melee Weapons Data", meleeWeaponsData);
|
||||
// Import each melee weapon
|
||||
for (const weapon of meleeWeaponsData) {
|
||||
// Check if the weapon already exists
|
||||
const existingWeapon = game.items.find(i => i.name === weapon.name && i.type === "weapon");
|
||||
if (existingWeapon) {
|
||||
console.warn(`Weapon ${weapon.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the weapon item
|
||||
await Item.create({
|
||||
name: weapon.name,
|
||||
type: "weapon",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_weapon.svg",
|
||||
system: {
|
||||
description: weapon.description,
|
||||
damage: weapon.damage,
|
||||
techAge: this.getTechAgeKeyFromLabel(weapon.tech_age),
|
||||
weaponType: SYSTEM.WEAPON_TYPES.melee.id,
|
||||
rangeType: SYSTEM.WEAPON_RANGE.melee.id,
|
||||
enc: 0,
|
||||
aspect: weapon.aspects.join(", "),
|
||||
cost: weapon.cost || 0,
|
||||
ammoCost: 0,
|
||||
},
|
||||
folder: meleeWeaponsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user