diff --git a/lang/en.json b/lang/en.json index 38515df..7fce549 100644 --- a/lang/en.json +++ b/lang/en.json @@ -20,6 +20,9 @@ "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.CLASS": "CLASS", "Mosh.Combat": "Combat", "Mosh.Condition": "Condition", @@ -28,6 +31,7 @@ "Mosh.CreateItem": "Create Item", "Mosh.CreateSkill": "Create Skill", "Mosh.CreateWeapon": "Create Weapon", +"Mosh.CreatureSettings": "Creature Settings", "Mosh.Credits": "Credits", "Mosh.Crew": "Crew", "Mosh.CriticalDamage": "Critical Damage", diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index c3a6679..b15cde2 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: 'Character Generator', + label: game.i18n.localize("Mosh.CharacterGenerator"), class: 'configure-actor', icon: 'fas fa-cogs', onclick: (ev) => this._onConfigureCreature(ev), diff --git a/module/actor/creature-sheet.js b/module/actor/creature-sheet.js index de9018b..6ecdb21 100644 --- a/module/actor/creature-sheet.js +++ b/module/actor/creature-sheet.js @@ -32,7 +32,7 @@ export class MothershipCreatureSheet extends ActorSheet { const canConfigure = game.user.isGM || this.actor.isOwner; if (this.options.editable && canConfigure) { buttons = [{ - label: 'Creature Settings', + label: game.i18n.localize("Mosh.CreatureSettings"), class: 'configure-actor', icon: 'fas fa-tasks', onclick: (ev) => this._onConfigureCreature(ev), diff --git a/module/windows/actor-generator.js b/module/windows/actor-generator.js index 7c37418..51c2b40 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}: Character Generator`; + return `${this.object.name}: ${game.i18n.localize("Mosh.CharacterGenerator")}`; } /* -------------------------------------------- */ @@ -23,12 +23,29 @@ export class DLActorGenerator extends FormApplication { * Construct and return the data object used to render the HTML template for this form application. * @return {Object} */ - getData() { + async getData() { //if (this.object.system.class.uuid != null){ // this.updateClass(this.object.system.class.uuid); //} let data=this.object; data.class_options = game.items.filter(i => i.type=="class"); + + let compendium = game.packs; + //loop through each compendium + //TODO: this is not working, the page is rendered before this data is retrieved. + //maybe have it as a triget on ready and manualy/hard replace the html selector ¿? + await compendium.forEach(async function(pack){ + //is this a pack of items? + if (pack.metadata.type === 'Item') { + //get classes: + let classes = await pack.getDocuments({ type: "class" }) + //loop through class + classes.forEach(function(item) { + data.class_options.push(item); + }); + } + }); + data.system.class.value = ""; return data; } @@ -184,40 +201,64 @@ export class DLActorGenerator extends FormApplication { } this._element.find(`input[id="system.class.uuid"]`).prop("value", classUuid); - this._element.find(`input[id="system.class.traumaresponse"]`).prop("value", droppedObject.system.trauma); - this.trinketTable = droppedObject.system.TrinketTable; - this.patchTable = droppedObject.system.PatchTable; - this.loadoutTable = droppedObject.system.loadoutTable; + this._element.find(`input[id="system.class.traumaresponse"]`).prop("value", droppedObject.system.trauma_response); + this.trinketTable = droppedObject.system.roll_tables.trinket; + this.patchTable = droppedObject.system.roll_tables.patch; + this.loadoutTable = droppedObject.system.roll_tables.loadout; try{ - let skills = JSON.parse(droppedObject.system.skills.replaceAll("
","").replaceAll("
","").replaceAll("","").replaceAll("
","").replaceAll("","").replaceAll("
","").replaceAll("","").replaceAll("
","").replaceAll("${ game.i18n.localize("Mosh.CharacterGeneratorStatOptionPopupTitle")} (${obj.value})
`, + buttons: buttons_options, + default: "1", + //render: html => console.log("Register interactivity in the rendered dialog"), + //close: html => console.log("This always is logged no matter which option is chosen") + }); + d.render(true); + /* for(let i = 0; i < statsandsaves.length; i++) { let obj = statsandsaves[i]; @@ -244,10 +285,11 @@ export class DLActorGenerator extends FormApplication { }); d.render(true); } - } + }*/ }catch{ ui.notifications.error("Class has invalid stats and saves configuration."); } + //todo: add robotic flag. return; } @@ -366,8 +408,10 @@ export class DLActorGenerator extends FormApplication { "system.stats.fear.value": formData["system.stats.fear.value"] + (formData["system.stats.fear.bonus"] || 0), "system.stats.body.value": formData["system.stats.body.value"] + (formData["system.stats.body.bonus"] || 0), } - if (formData["system.hits.bonus"]){ - data["system.hits.max"] = 2+formData["system.hits.bonus"]; + if (formData["system.stats.max_wounds.bonus"]){ + //todo: check if max_wounds represent the total ammount or just the bonus, + //I am going to asume is the total ammount, so for android is gona be a 3, + data["system.hits.max"] = formData["system.stats.max_wounds.bonus"]; } else{ data["system.hits.max"] = 2; @@ -393,7 +437,7 @@ export class DLActorGenerator extends FormApplication { Body: ${data["system.stats.body.value"]} = ${formData["system.stats.body.value"]}+${formData["system.stats.body.bonus"]}