Importers ready
This commit is contained in:
@@ -62,11 +62,9 @@ export default class FTLNomadRoll extends Roll {
|
||||
|
||||
static updateFullFormula(options) {
|
||||
let fullFormula
|
||||
if ( options.numericModifier >= 0) {
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} + ${options.numericModifier}D`
|
||||
} else {
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} - ${Math.abs(options.numericModifier)}D`
|
||||
}
|
||||
fullFormula = `${options.formula} + ${options.rollItem.value} + ${options.skillModifier}D + ${options.rangeModifier}D + ${options.numericModifier}D`
|
||||
// Replace all the "+ -" with "-"
|
||||
fullFormula = fullFormula.replace(/\+\s*-/g, "- ")
|
||||
$('#roll-dialog-full-formula').text(fullFormula)
|
||||
options.fullFormula = fullFormula
|
||||
}
|
||||
@@ -130,14 +128,12 @@ export default class FTLNomadRoll extends Roll {
|
||||
}
|
||||
|
||||
let modifier = "0"
|
||||
options.numericModifier = rangeModifier
|
||||
options.skillModifier = 0
|
||||
options.numericModifier = 0
|
||||
options.rangeModifier = rangeModifier
|
||||
let fullFormula = `${formula} + ${options.rollItem.value}`
|
||||
if (options.isEncumbered) {
|
||||
options.numericModifier += -1
|
||||
fullFormula += ` - ${options.numericModifier}D`
|
||||
} else {
|
||||
options.numericModifier += 0
|
||||
fullFormula += ` + ${options.numericModifier}D`
|
||||
fullFormula += ` - 1D`
|
||||
}
|
||||
options.fullFormula = fullFormula
|
||||
options.formula = formula
|
||||
@@ -184,16 +180,16 @@ export default class FTLNomadRoll extends Roll {
|
||||
},
|
||||
rejectClose: false, // Click on Close button will not launch an error
|
||||
render: (event, dialog) => {
|
||||
FTLNomadRoll.updateFullFormula(options)
|
||||
$(".roll-skill-modifier").change(event => {
|
||||
options.numericModifier += Number(event.target.value)
|
||||
options.skillModifier = Number(event.target.value)
|
||||
FTLNomadRoll.updateFullFormula(options)
|
||||
})
|
||||
$(".roll-skill-range-modifier").change(event => {
|
||||
options.numericModifier += Number(event.target.value)
|
||||
options.rangeModifier = Number(event.target.value)
|
||||
FTLNomadRoll.updateFullFormula(options)
|
||||
})
|
||||
$(".select-combat-option").change(event => {
|
||||
console.log(event)
|
||||
let field = $(event.target).data("field")
|
||||
let modifier = SYSTEM.ATTACK_MODIFIERS[field]
|
||||
if ( event.target.checked) {
|
||||
|
||||
@@ -11,16 +11,16 @@ export default class FTLNomadStarship extends foundry.abstract.TypeDataModel {
|
||||
schema.hullType = new fields.StringField({ required: true, initial: "small", choices: SYSTEM.STARSHIP_HULL })
|
||||
schema.endurance = new fields.StringField({ required: true, initial: "" })
|
||||
schema.armor = new fields.StringField({ required: true, initial: "" })
|
||||
schema.crew = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 })
|
||||
schema.cargo = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
schema.crew = new fields.StringField({ required: true, initial: "" })
|
||||
schema.cargo = new fields.StringField({ required: true, initial: "" })
|
||||
schema.guns = new fields.StringField({ required: true, initial: "1d6" })
|
||||
schema.travelMultiplier = new fields.NumberField({ required: true, initial: 1, min: 0 })
|
||||
schema.travelMultiplier = new fields.StringField({ required: true, initial: "" })
|
||||
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.monthlyCost = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.damages = new fields.StringField({ required: true, initial: "" })
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.modifications = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.modifications = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.notes = new fields.HTMLField({ required: true, textSearch: true })
|
||||
|
||||
return schema
|
||||
@@ -32,5 +32,5 @@ export default class FTLNomadStarship extends foundry.abstract.TypeDataModel {
|
||||
isEncumbered() {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@ export default class FTLNomadVehicle extends foundry.abstract.TypeDataModel {
|
||||
|
||||
schema.agility = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
schema.armor = new fields.StringField({ required: true, initial: "" })
|
||||
schema.cargo = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
schema.crew = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 })
|
||||
schema.cargo = new fields.StringField({ required: true, initial: "" })
|
||||
schema.crew = new fields.StringField({ required: true, initial: "" })
|
||||
schema.force = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 })
|
||||
schema.range = new fields.StringField({ required: true, initial: "1d6" })
|
||||
schema.speed = new fields.StringField({ required: true, initial: "1d6" })
|
||||
schema.techAge = new fields.StringField({ required: true, initial: "1d6" })
|
||||
schema.tonnage = new fields.NumberField({ required: true, initial: 1, min: 0 })
|
||||
schema.tonnage = new fields.StringField({ required: true, initial: "" })
|
||||
schema.damages = new fields.StringField({ required: true, initial: "" })
|
||||
|
||||
schema.cost = 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 })
|
||||
|
||||
@@ -36,7 +36,7 @@ export default class FTLNomadVehicle extends foundry.abstract.TypeDataModel {
|
||||
async roll(rollType, rollItem) {
|
||||
let opponentTarget
|
||||
const hasTarget = opponentTarget !== undefined
|
||||
|
||||
|
||||
let roll = await FTLNomadRoll.prompt({
|
||||
rollType,
|
||||
rollItem,
|
||||
@@ -48,8 +48,8 @@ export default class FTLNomadVehicle extends foundry.abstract.TypeDataModel {
|
||||
target: opponentTarget
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
140
module/utils.mjs
140
module/utils.mjs
@@ -450,6 +450,146 @@ export default class FTLNomadUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static async importStarships() {
|
||||
// Create a starships folder if it doesn't exist
|
||||
const starshipsFolder = game.folders.getName("Starships") || await Folder.create({
|
||||
name: "Starships", type: "Actor"
|
||||
})
|
||||
if (!starshipsFolder) {
|
||||
console.error("Failed to create Starships folder");
|
||||
return;
|
||||
}
|
||||
// Load the starships JSON file
|
||||
const starshipsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/starships.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load starships data:", error);
|
||||
return [];
|
||||
});
|
||||
|
||||
// Import each starship
|
||||
for (const starship of starshipsData) {
|
||||
// Check if the starship already exists
|
||||
const existingStarship = game.actors.find(a => a.name === starship.name && a.type === "starship");
|
||||
if (existingStarship) {
|
||||
console.warn(`Starship ${starship.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the starship actor
|
||||
await Actor.create({
|
||||
name: starship.name,
|
||||
type: "starship",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_starship.svg",
|
||||
system: {
|
||||
description: starship.description,
|
||||
agility: starship.agility,
|
||||
hullType: starship.hullType.toLowerCase(),
|
||||
endurance: starship.endurance,
|
||||
armor: starship.armor,
|
||||
crew: starship.crew,
|
||||
cargo: starship.cargo,
|
||||
guns: starship.guns,
|
||||
travelMultiplier: starship.travelMultiplier,
|
||||
cost: starship.cost || 0,
|
||||
monthlyCost: starship.monthlyCost || 0,
|
||||
damages: starship.damages,
|
||||
},
|
||||
folder: starshipsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importVehicles() {
|
||||
// Create a vehicles folder if it doesn't exist
|
||||
const vehiclesFolder = game.folders.getName("Vehicles") || await Folder.create({
|
||||
name: "Vehicles", type: "Actor"
|
||||
})
|
||||
if (!vehiclesFolder) {
|
||||
console.error("Failed to create Vehicles folder");
|
||||
return;
|
||||
}
|
||||
// Load the vehicles JSON file
|
||||
const vehiclesData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/vehicles.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load vehicles data:", error);
|
||||
return [];
|
||||
});
|
||||
|
||||
// Import each vehicle
|
||||
for (const vehicle of vehiclesData) {
|
||||
// Check if the vehicle already exists
|
||||
const existingVehicle = game.items.find(i => i.name === vehicle.name && i.type === "vehicle");
|
||||
if (existingVehicle) {
|
||||
console.warn(`Vehicle ${vehicle.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the vehicle item
|
||||
await Actor.create({
|
||||
name: vehicle.name,
|
||||
type: "vehicle",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_vehicle.svg",
|
||||
system: {
|
||||
description: vehicle.description,
|
||||
agility: vehicle.agility,
|
||||
armor: vehicle.armor,
|
||||
cargo: vehicle.cargo,
|
||||
crew: vehicle.crew,
|
||||
force: vehicle.force,
|
||||
range: vehicle.range,
|
||||
speed: vehicle.speed,
|
||||
techAge: this.getTechAgeKeyFromLabel(vehicle.tech_age),
|
||||
tonnage: vehicle.tonnage,
|
||||
damages: vehicle.damages,
|
||||
cost: vehicle.cost || 0,
|
||||
},
|
||||
folder: vehiclesFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importArmors() {
|
||||
// Create an armors folder if it doesn't exist
|
||||
const armorsFolder = game.folders.getName("Armors") || await Folder.create({
|
||||
name: "Armors", type: "Item"
|
||||
})
|
||||
if (!armorsFolder) {
|
||||
console.error("Failed to create Armors folder");
|
||||
return;
|
||||
}
|
||||
// Load the armors JSON file
|
||||
const armorsData = await fetch("systems/fvtt-ftl-nomad/assets/json_data/armors.json")
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error("Failed to load armors data:", error);
|
||||
return [];
|
||||
});
|
||||
|
||||
// Import each armor
|
||||
for (const armor of armorsData) {
|
||||
// Check if the armor already exists
|
||||
const existingArmor = game.items.find(i => i.name === armor.name && i.type === "armor");
|
||||
if (existingArmor) {
|
||||
console.warn(`Armor ${armor.name} already exists, skipping import.`);
|
||||
continue;
|
||||
}
|
||||
// Create the armor item
|
||||
await Item.create({
|
||||
name: armor.name,
|
||||
type: "armor",
|
||||
img: "systems/fvtt-ftl-nomad/assets/icons/icon_armor.svg",
|
||||
system: {
|
||||
description: armor.description,
|
||||
enc: armor.enc || 0,
|
||||
techAge: this.getTechAgeKeyFromLabel(armor.tech_age),
|
||||
cost: armor.cost || 0,
|
||||
protection: armor.protection || 0,
|
||||
},
|
||||
folder: armorsFolder.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async importGrenadeWeapons() {
|
||||
// Create a grenade weapons folder if it doesn't exist
|
||||
const grenadeWeaponsFolder = game.folders.getName("Grenade") || await Folder.create({
|
||||
|
||||
Reference in New Issue
Block a user