diff --git a/lang/en.json b/lang/en.json index 7fce549..277f8f9 100644 --- a/lang/en.json +++ b/lang/en.json @@ -20,9 +20,14 @@ "Mosh.Calm": "Calm", "Mosh.Cargo": "Cargo", "Mosh.CarryingCapacity": "Carrying Capacity", -"Mosh.CharacterGenerator": "Character Generator", -"Mosh.CharacterGeneratorStatOptionPopupTitle": "Class Attribute and Saves option", -"Mosh.CharacterGeneratorStatOptionPopupText":"Choose where to apply the bonus of:", +"Mosh.CharacterGenerator.name": "Character Generator", +"Mosh.CharacterGenerator.StatOption":"Stats & Saves", +"Mosh.CharacterGenerator.StatOptionPopupTitle": "Class Attribute and Saves option", +"Mosh.CharacterGenerator.StatOptionPopupText":"Choose where to apply the bonus of:", +"Mosh.CharacterGenerator.Tables":"Tables", +"Mosh.CharacterGenerator.Table.Loadout":"Loadout Table", +"Mosh.CharacterGenerator.Table.Patch":"Patch Table", +"Mosh.CharacterGenerator.Table.Trinket":"Trinket Table", "Mosh.CLASS": "CLASS", "Mosh.Combat": "Combat", "Mosh.Condition": "Condition", @@ -110,6 +115,8 @@ "Mosh.SkillName": "Skill Name", "Mosh.SkillRank": "Skill Rank", "Mosh.Skills": "Skills", +"Mosh.SkillsFixed": "Fixed Skills", +"Mosh.SkillsOptional": "Optional Skills", "Mosh.SkillTraining": "Skill Training", "Mosh.SpecialAbilities": "Special Abilities", "Mosh.Speed": "Speed", diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index b15cde2..29f33eb 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -643,7 +643,7 @@ export class MothershipActorSheet extends ActorSheet { const canConfigure = game.user.isGM || this.actor.isOwner; if (this.options.editable && canConfigure) { buttons = [{ - label: game.i18n.localize("Mosh.CharacterGenerator"), + label: game.i18n.localize("Mosh.CharacterGenerator.name"), class: 'configure-actor', icon: 'fas fa-cogs', onclick: (ev) => this._onConfigureCreature(ev), diff --git a/module/item/class-sheet.js b/module/item/class-sheet.js new file mode 100644 index 0000000..a1cdfa0 --- /dev/null +++ b/module/item/class-sheet.js @@ -0,0 +1,85 @@ +/** + * Extend the basic MothershipItemSheet with class modification + * @extends {MothershipItemSheet} + */ +import { MothershipItemSheet } from "./item-sheet.js"; +export class MothershipClassSheet extends MothershipItemSheet { + + /** @override */ + static get defaultOptions() { + var options = { + classes: ["mosh", "sheet", "item"], + width: 820, + height: 820, + tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }] + }; + options.dragDrop = [{dragSelector: null, dropSelector: ".dropitem"}]; + + if (game.release.generation >= 12) { + return foundry.utils.mergeObject(super.defaultOptions, options); + } else { + return mergeObject(super.defaultOptions, options); + } + } + + + /** @override */ + getData() { + const data = super.getData(); + if (typeof data.system.base_adjustment.skills_granted == 'undefined'){ + data.system.base_adjustment.skills_granted=[]; + } + return data; + } + + async _onDrop(event){ + await super._onDrop(event); + const droppedUuid = TextEditor.getDragEventData(event); + if (droppedUuid.type != "Item"){ + return; + } + const droppedObject = await fromUuid(droppedUuid.uuid); + if (droppedObject.type == "skill"){ + //this.object.system.base_adjustment.skills_granted.push(droppedObject); + let skills = this.object.system.base_adjustment.skills_granted; + skills.push(droppedObject); + this.object.update({"system.base_adjustment.skills_granted":skills}); + return this.render(false); + } + } + + + /** @override */ + activateListeners(html) { + super.activateListeners(html); + + // Delete Inventory Item + html.find('.item-delete').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + + let skills = this.object.system.base_adjustment.skills_granted.filter(function( obj ) { + return obj._id !== li.data("itemId"); + }); + this.object.update({"system.base_adjustment.skills_granted":skills}); + return this.render(false); + }); + + + } + /**** + async _updateObject(event, formData) { + const item = this.object; + + var updateData; + if (game.release.generation >= 12) { + updateData = foundry.utils.expandObject(formData); + } else { + updateData = expandObject(formData); + } + + await item.update(updateData, { + diff: false + }); + }*/ +} + diff --git a/module/mosh.js b/module/mosh.js index fac2334..dba7210 100644 --- a/module/mosh.js +++ b/module/mosh.js @@ -7,6 +7,8 @@ import { MothershipShipSheetSBT } from "./actor/ship-sheet-sbt.js"; import { MothershipItem } from "./item/item.js"; import { MothershipItemSheet } from "./item/item-sheet.js"; +import { MothershipClassSheet } from "./item/class-sheet.js"; + import { registerSettings } from "./settings.js"; @@ -65,7 +67,18 @@ Hooks.once('init', async function () { }); Items.unregisterSheet("core", ItemSheet); - Items.registerSheet("mosh", MothershipItemSheet, { makeDefault: true }); + Items.registerSheet("mosh", MothershipClassSheet, {types: ['class'], makeDefault: true }); + Items.registerSheet("mosh", MothershipItemSheet, { + types: ["item", + "skill", + "weapon", + "armor", + "ability", + "module", + "condition", + "crew", + "repair",], + makeDefault: true }); // If you need to add Handlebars helpers, here are a few useful examples: Handlebars.registerHelper('concat', function () { diff --git a/module/windows/actor-generator.js b/module/windows/actor-generator.js index df8dc22..7fb2587 100644 --- a/module/windows/actor-generator.js +++ b/module/windows/actor-generator.js @@ -15,7 +15,7 @@ export class DLActorGenerator extends FormApplication { * @type {String} */ get title() { - return `${this.object.name}: ${game.i18n.localize("Mosh.CharacterGenerator")}`; + return `${this.object.name}: ${game.i18n.localize("Mosh.CharacterGenerator.name")}`; } /* -------------------------------------------- */ @@ -189,7 +189,8 @@ export class DLActorGenerator extends FormApplication { this.patchTable = droppedObject.system.roll_tables.patch; this.loadoutTable = droppedObject.system.roll_tables.loadout; - try{ + // Skills + //try{ //let skills = JSON.parse(droppedObject.system.skills.replaceAll("
","").replaceAll("
","").replaceAll("","").replaceAll("
","").replaceAll("${ game.i18n.localize("Mosh.CharacterGeneratorStatOptionPopupTitle")} (${option_stats_and_saves.modification})
`, + title: game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupTitle"), + content: `${ game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupText")} (${option_stats_and_saves.modification})
`, buttons: buttons_options, default: "1", //render: html => console.log("Register interactivity in the rendered dialog"), @@ -269,9 +273,9 @@ export class DLActorGenerator extends FormApplication { d.render(true); } }*/ - }catch{ - ui.notifications.error("Class has invalid stats and saves configuration."); - } + //}catch{ + // ui.notifications.error("Class has invalid stats and saves configuration."); + //} //todo: add robotic flag. return; } @@ -456,7 +460,6 @@ export class DLActorGenerator extends FormApplication { if(formData["system.removepreviousitems"]){ - let itemTypesToDelete = ["item", "armor", "weapon","skill","condition"]; let itemsToDelete = this.object.items.filter(item => itemTypesToDelete.includes(item.type)); await this.object.deleteEmbeddedDocuments("Item", itemsToDelete.map(item => item.id)); diff --git a/templates/dialogs/actor-generator-dialog.html b/templates/dialogs/actor-generator-dialog.html index bfc7a9c..8891279 100644 --- a/templates/dialogs/actor-generator-dialog.html +++ b/templates/dialogs/actor-generator-dialog.html @@ -29,9 +29,17 @@ + +