diff --git a/lang/en.json b/lang/en.json index 0079d6b..e540fdc 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,6 +1,8 @@ { "Mosh.Add": "Add", "Mosh.AddOr":"Add Or", + "Mosh.AddOption":"Add Option", + "Mosh.AddGroup":"Add Group", "Mosh.Advantage": "Advantage", "Mosh.Ammo": "Ammo", "Mosh.Ammunition": "Ammunition", @@ -33,7 +35,9 @@ "Mosh.CharacterGenerator.SkillOption.PopupTrainedDescription": "Choose 1 Trained skill", "Mosh.CharacterGenerator.SkillOption.PopupExpertDescription": "Choose 1 Expert skill", "Mosh.CharacterGenerator.SkillOption.PopupMasterDescription": "Choose 1 Master skill", + "Mosh.CharacterGenerator.SkillOption.PopupFullMasterName": "Master Set", "Mosh.CharacterGenerator.SkillOption.PopupFullMasterDescription": "Choose 1 Master skill, and an Expert and Trained Skill prerequisite.", + "Mosh.CharacterGenerator.SkillOption.PopupFullExpertName": "Expert Set", "Mosh.CharacterGenerator.SkillOption.PopupFullExperDescription": "Choose 1 Expert skill, and Trained Skill prerequisite.", "Mosh.CharacterGenerator.SkillOption.ChoiceWord": "Option", "Mosh.CharacterGenerator.SkillOption.ChoiceText":"Choose 1 from these skill bonus options", @@ -43,6 +47,8 @@ "Mosh.CharacterGenerator.Table.Trinket": "Trinket Table", "Mosh.CharacterGenerator.Error.NoClass": "You need to select a class first.", "Mosh.CLASS": "CLASS", + "Mosh.classNewStatOptionEmptyError":"You must select at least two stat or saves", + "Mosh.classNewSkillOptionSkillTip":"Save first.", "Mosh.Combat": "Combat", "Mosh.Condition": "Condition", "Mosh.Cost": "Cost", @@ -64,6 +70,8 @@ "Mosh.DeleteItem": "Delete Item", "Mosh.DeleteSkill": "Delete Skill", "Mosh.DeleteWeapon": "Delete Weapon", + "Mosh.DeleteGroup": "Delete Group", + "Mosh.DeleteOption": "Delete Option", "Mosh.Description": "Description", "Mosh.Disabled": "Disabled", "Mosh.Disadvantage": "Disadvantage", @@ -142,7 +150,8 @@ "Mosh.Skills": "Skills", "Mosh.SkillsFixed": "Fixed Skills", "Mosh.SkillsPrerequisite": "Prerequisite Skills", - "Mosh.SkillsOptional": "Optional Skills", + "Mosh.SkillsOptionalAnd": "Selected Skills", + "Mosh.SkillsOptionalOr": "Optional Skills", "Mosh.SkillTraining": "Skill Training", "Mosh.SpecialAbilities": "Special Abilities", "Mosh.Speed": "Speed", diff --git a/module/item/class-sheet.js b/module/item/class-sheet.js index e1676e8..1365afd 100644 --- a/module/item/class-sheet.js +++ b/module/item/class-sheet.js @@ -29,28 +29,36 @@ export class MothershipClassSheet extends MothershipItemSheet { if (typeof data.system.base_adjustment.skills_granted == 'undefined'){ data.system.base_adjustment.skills_granted=[]; } + + //Create placeholder for the skills object, to get the info of the skill data.system.base_adjustment.skills_granted_object = []; for (const skill of data.system.base_adjustment.skills_granted){ - if(Array.isArray(skill)){ - let option_skills = []; - for (const option of skill){ - option_skills.push(await fromUuid(option)); - } - data.system.base_adjustment.skills_granted_object.push(option_skills); - }else{ data.system.base_adjustment.skills_granted_object.push(await fromUuid(skill)); - } }; - + console.log(data.system.selected_adjustment.choose_skill_or); + let choose_skill_or = data.system.selected_adjustment.choose_skill_or; + for (const [ig, group] of choose_skill_or.entries()){ + for (const [io, option] of group.entries()){ + let names = []; + data.system.selected_adjustment.choose_skill_or[ig][io].from_list_names = []; + for(const [is, skill] of option.from_list.entries()){ + names.push((await fromUuid(skill)).name); + } + data.system.selected_adjustment.choose_skill_or[ig][io].from_list_names = names; + } + console.log(data.system.selected_adjustment.choose_skill_or); + } + data.system.common_skills_object = []; for (const skill of data.system.common_skills){ data.system.common_skills_object.push(await fromUuid(skill)); }; + /* if (typeof data.system.selected_adjustment.choose_stat.stats == 'undefined'){ data.system.selected_adjustment.choose_stat.stats=[]; - } + }*/ data.enriched=[]; data.enriched.description = await TextEditor.enrichHTML(data.system.description, {async: true}); @@ -64,13 +72,11 @@ export class MothershipClassSheet extends MothershipItemSheet { if (droppedUuid.type != "Item"){ return; } - console.log(event); - console.log(event.currentTarget); - console.log(event.target); - console.log(event.target.parentNode); + const droppedObject = await fromUuid(droppedUuid.uuid); if (droppedObject.type == "skill"){ //todo: add a check if the skill already exist in the list and dont add it, (by id or by name?) + console.log(event.currentTarget.id); if(event.currentTarget.id == "skills.fixed"){ let parent_fixed_or = event.target.closest('div[id="skills.fixed.or"]'); @@ -94,6 +100,20 @@ export class MothershipClassSheet extends MothershipItemSheet { this.object.update({"system.common_skills":skills}); return this.render(false); } + else if(event.currentTarget.id =="choose_skill_or_li"){ + const li = $(ev.currentTarget); + let index = li.data("itemId"); + const parent = $(ev.currentTarget).parents(".items-list"); + let parent_index = parent.data("itemId"); + + let options = this.object.system.selected_adjustment.choose_skill_or; + + options[parent_index][index].from_list.push(droppedObject.uuid); + + this.object.update({"system.selected_adjustment.choose_skill_or":options}); + return this.render(false); + + } } } @@ -107,18 +127,7 @@ export class MothershipClassSheet extends MothershipItemSheet { const li = $(ev.currentTarget).parents(".item"); let skills = this.object.system.base_adjustment.skills_granted.filter(function( obj ) { - - if(Array.isArray(obj)){ - let found = false; - for (const option of obj){ - if (option === li.data("itemId")){ - found = true; - } - } - return !found; - }else{ return obj !== li.data("itemId"); - } }); this.object.update({"system.base_adjustment.skills_granted":skills}); return this.render(false); @@ -135,24 +144,95 @@ export class MothershipClassSheet extends MothershipItemSheet { return this.render(false); }); - html.find('.stat-delete').click(ev => { + html.find('.stat-option-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); - let stats = this.object.system.selected_adjustment.choose_stat.stats.filter(function( obj ) { - return obj !== li.data("itemId"); - }); - this.object.update({"system.selected_adjustment.choose_stat.stats":stats}); + let stats = this.object.system.selected_adjustment.choose_stat; + stats.splice(li.data("itemId"),1); + + this.object.update({"system.selected_adjustment.choose_stat":stats}); return this.render(false); }); - html.find('.stat-create').click(this._onStatCreate.bind(this)); - html.find('div[id="skill-create-or-option"]').click(ev => { - let skills = this.object.system.base_adjustment.skills_granted; - //add new empty or option - skills.push([]); - this.object.update({"system.base_adjustment.skills_granted":skills}); - return this.render(false); - }); + + html.find('.stat-option-add').click(this._onStatCreate.bind(this)); + + + html.find('.skills-group-add').click(ev => { + let skills = this.object.system.selected_adjustment.choose_skill_or; + let new_group = [] + skills.push(new_group); + this.object.update({"system.selected_adjustment.choose_skill_or":skills}); + return this.render(false); + }); + html.find('.skills-group-delete').click(ev => { + const li = $(ev.currentTarget).parents(".items-list"); + + let options = this.object.system.selected_adjustment.choose_skill_or; + options.splice(li.data("itemId"),1); + + this.object.update({"system.selected_adjustment.choose_skill_or":options}); + return this.render(false); + }); + + html.find('.skills-group-option-delete').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + const liparent = li.parents(".items-list"); + + let options = this.object.system.selected_adjustment.choose_skill_or; + options[liparent.data("itemId")].splice(li.data("itemId"),1); + + this.object.update({"system.selected_adjustment.choose_skill_or":options}); + return this.render(false); + }); + + html.find('.skills-group-option-createnew').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + + let new_data = { + "name":li.find('input[name="choose_skill_or_name"]').prop("value"), + "trained": li.find('input[name="choose_skill_or_trained"]').prop("value"), + "expert": li.find('input[name="choose_skill_or_expert"]').prop("value"), + "expert_full_set": li.find('input[name="choose_skill_or_expert_full_set"]').prop("value"), + "master": li.find('input[name="choose_skill_or_master"]').prop("value"), + "master_full_set": li.find('input[name="choose_skill_or_master_full_set"]').prop("value"), + "from_list": [], + } + if(new_data.name ==""){ + new_data.name = `Option: ${(this.object.system.selected_adjustment.choose_skill_or[li.data("itemId")].length)+1}` + } + if(new_data.trained ==""){ + new_data.trained = 0; + } + if(new_data.expert ==""){ + new_data.expert = 0; + } + if(new_data.expert_full_set ==""){ + new_data.expert_full_set = 0; + } + if(new_data.master ==""){ + new_data.master = 0; + } + if(new_data.master_full_set ==""){ + new_data.master_full_set = 0; + } + //console.log(new_data); + let options = this.object.system.selected_adjustment.choose_skill_or; + options[li.data("itemId")].push(new_data); + + //save data + this.object.update({"system.selected_adjustment.choose_skill_or":options}); + + //clear form and hide it + li.find('input[name="choose_skill_or_name"]').prop("value",""); + li.find('input[name="choose_skill_or_trained"]').prop("value",""); + li.find('input[name="choose_skill_or_expert"]').prop("value",""); + li.find('input[name="choose_skill_or_expert_full_set"]').prop("value",""); + li.find('input[name="choose_skill_or_master"]').prop("value",""); + li.find('input[name="choose_skill_or_master_full_set"]').prop("value",""); + + return this.render(false); + }); } @@ -164,47 +244,59 @@ export class MothershipClassSheet extends MothershipItemSheet { */ _onStatCreate(event) { event.preventDefault(); - let stats = this.object.system.selected_adjustment.choose_stat.stats; + let choose_stat = this.object.system.selected_adjustment.choose_stat; - let DialogContent = `

Stat

\ -
` + let DialogContent = `

${game.i18n.localize("Mosh.CharacterGenerator.StatOption")}

\ +
\ +
${game.i18n.localize("Mosh.Strength")}
\ +
${game.i18n.localize("Mosh.Speed")}
\ +
${game.i18n.localize("Mosh.Intellect")}
\ +
${game.i18n.localize("Mosh.Combat")}
\ +
${game.i18n.localize("Mosh.Sanity")}
\ +
${game.i18n.localize("Mosh.Fear")}
\ +
${game.i18n.localize("Mosh.Body")}
` let d = new Dialog({ title: "Select Stat", content: DialogContent, buttons: { - roll: { + create: { icon: '', label: "Create", callback: (html) => { - - let statname = html.find('[id=\"system.selected_adjustment.choose_stat.stats\"]')[0].value + + let new_stat_option = { + modification: html.find('[id=\"modification\"]').prop("value"), + stats: [], + } + if (html.find('[id=\"strength\"]')[0].checked){ + new_stat_option.stats.push("strength"); + } + if (html.find('[id=\"speed\"]')[0].checked){ + new_stat_option.stats.push("speed"); + } + if (html.find('[id=\"intellect\"]')[0].checked){ + new_stat_option.stats.push("intellect"); + } + if (html.find('[id=\"combat\"]')[0].checked){ + new_stat_option.stats.push("combat"); + } + if (html.find('[id=\"sanity\"]')[0].checked){ + new_stat_option.stats.push("sanity"); + } + if (html.find('[id=\"fear\"]')[0].checked){ + new_stat_option.stats.push("fear"); + } + if (html.find('[id=\"body\"]')[0].checked){ + new_stat_option.stats.push("body"); + } + if(new_stat_option.stats.length < 2){ + ui.notifications.error(game.i18n.localize("Mosh.classNewStatOptionEmptyError")); + return; + } - stats.push(statname); - this.object.update({"system.selected_adjustment.choose_stat.stats":stats}); + choose_stat.push(new_stat_option); + this.object.update({"system.selected_adjustment.choose_stat":choose_stat}); } }, @@ -214,7 +306,7 @@ export class MothershipClassSheet extends MothershipItemSheet { callback: () => { } } }, - default: "roll", + default: "create", close: () => { } }); d.render(true); diff --git a/templates/item/item-class-sheet.html b/templates/item/item-class-sheet.html index 875f8ee..21c2d86 100644 --- a/templates/item/item-class-sheet.html +++ b/templates/item/item-class-sheet.html @@ -159,7 +159,8 @@ {{ localize 'Mosh.Description' }} {{ localize 'Mosh.CharacterGenerator.StatOption' }} {{ localize 'Mosh.SkillsFixed' }} - {{ localize 'Mosh.SkillsOptional' }} + {{ localize 'Mosh.SkillsOptionalAnd' }} + {{ localize 'Mosh.SkillsOptionalOr' }} {{ localize 'Mosh.CharacterGenerator.Tables' }} {{ localize 'Mosh.CharacterGenerator.CommonSkills' }} @@ -173,35 +174,28 @@ {{!-- stats&saves Tab --}}
-
-
- {{ localize - 'Mosh.Value' }} + +
    +
  1. +
    {{ localize 'Mosh.Value' }}
    +
    {{ localize 'Mosh.StatsAndSaves' }}
    + +
  2. + {{#each system.selected_adjustment.choose_stat as |group id|}} +
  3. +
    {{group.modification}}
    +
    {{#each group.stats as |stat id|}}{{stat}}{{#if @last}}{{else}}, {{/if}}{{/each}}
    - -
-
-
    -
  1. -
    {{ localize 'Mosh.Name' }}
    - -
  2. - {{#each system.selected_adjustment.choose_stat.stats as |stat id|}} -
  3. -
    {{stat}}
    -
    - -
    -
  4. - {{/each}} -
-
+
+ +
+ + {{/each}} +
{{!-- skills Tab --}}
@@ -213,13 +207,12 @@
{{ localize 'Mosh.SkillRank' }}
{{ localize 'Mosh.SkillBonus' }}
{{#each system.base_adjustment.skills_granted_object as |skill id|}} - {{#if skill.name}}
  • {{skill.name}}
    @@ -230,48 +223,16 @@ class="fas fa-trash">
  • - {{else}} -
  • -
    -
    OR
    -
      - {{#each skill as |subskill subid|}} -
    1. -
      -
      {{subskill.name}}
      -
      {{subskill.system.rank}}
      -
      {{subskill.system.bonus}}
      -
      - -
      -
    2. - {{/each}} -
    -
    - {{#if skill.[1]}}{{else}} -
    - -
    - {{/if}} -
  • - {{/if}} {{/each}}
    -
    + {{!-- skills Tab --}} +
    -

    - -
    -
    - + class="resource-label minmaxtext">{{ localize 'Mosh.SkillRankTrained' }}
    + class="resource-label minmaxtext">{{ localize 'Mosh.SkillRankExpert' }}
    + class="resource-label minmaxtext">{{ localize 'Mosh.SkillRankMaster' }}
    - +
    + class="resource-label minmaxtext">{{ localize 'Mosh.CharacterGenerator.SkillOption.PopupFullMasterName' }}
    -
    -
    -
    - -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    -
    -
    -
    - -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    -
    - - -
    - -
    -
    - -
    +
    + + {{!-- skills Tab --}} +
    + + {{#each system.selected_adjustment.choose_skill_or as |group id|}} +
      +
    1. +
      +
      +
      {{ localize 'Mosh.SkillRankTrained' }}
      +
      {{ localize 'Mosh.SkillRankExpert' }}
      +
      {{ localize 'Mosh.SkillRankMaster' }}
      +
      {{ localize 'Mosh.CharacterGenerator.SkillOption.PopupFullExpertName' }}
      +
      {{ localize 'Mosh.CharacterGenerator.SkillOption.PopupFullMasterName' }}
      +
      {{ localize 'Mosh.Skills' }}
      +
      + +
      +
    2. + {{#each group}} +
    3. +
      {{this.name}}
      + + +
      {{this.trained}}
      +
      {{this.expert}}
      +
      {{this.master}}
      +
      {{this.expert_full_set}}
      +
      {{this.master_full_set}}
      +
      {{this.from_list.length}}
      +
      + +
      +
    4. + {{/each}} + +
    + {{/each}}
    @@ -508,4 +411,13 @@
    - \ No newline at end of file + + \ No newline at end of file