diff --git a/modules/crucible-actor.js b/modules/crucible-actor.js index 9d1fa3e..c31a8ea 100644 --- a/modules/crucible-actor.js +++ b/modules/crucible-actor.js @@ -86,39 +86,47 @@ export class CrucibleActor extends Actor { /* -------------------------------------------- */ getMoneys() { let comp = this.data.items.filter(item => item.type == 'money'); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } /* -------------------------------------------- */ getFeats() { let comp = duplicate(this.data.items.filter(item => item.type == 'feat') || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } /* -------------------------------------------- */ getFeatsWithDie() { let comp = duplicate(this.data.items.filter(item => item.type == 'feat' && item.data.data.isfeatdie) || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } getFeatsWithSL() { let comp = duplicate(this.data.items.filter(item => item.type == 'feat' && item.data.data.issl) || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } /* -------------------------------------------- */ getLore() { let comp = duplicate(this.data.items.filter(item => item.type == 'spell') || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } getEquippedWeapons() { let comp = duplicate(this.data.items.filter(item => item.type == 'weapon' && item.data.data.equipped) || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } /* -------------------------------------------- */ getArmors() { let comp = duplicate(this.data.items.filter(item => item.type == 'armor') || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } /* -------------------------------------------- */ getShields() { let comp = duplicate(this.data.items.filter(item => item.type == 'shield') || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } getRace() { @@ -140,6 +148,7 @@ export class CrucibleActor extends Actor { /* -------------------------------------------- */ getWeapons() { let comp = duplicate(this.data.items.filter(item => item.type == 'weapon') || []); + CrucibleUtility.sortArrayObjectsByName(comp) return comp; } /* -------------------------------------------- */ @@ -156,8 +165,9 @@ export class CrucibleActor extends Actor { /* -------------------------------------------- */ getSkills() { - let comp = duplicate(this.data.items.filter(item => item.type == 'skill') || []); - return comp; + let comp = duplicate(this.data.items.filter(item => item.type == 'skill') || []) + CrucibleUtility.sortArrayObjectsByName(comp) + return comp } /* -------------------------------------------- */ @@ -389,7 +399,7 @@ export class CrucibleActor extends Actor { user: game.user.id, rollMode: game.settings.get("core", "rollMode"), whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')), - content: `
${this.name} has gained 1 exp in the skill ${skill.name} (exp = ${skill.data.data.exp}}${this.name} has gained 1 exp in the skill ${skill.name} (exp = ${skill.data.data.exp})= 25) { @@ -398,7 +408,7 @@ export class CrucibleActor extends Actor { user: game.user.id, rollMode: game.settings.get("core", "rollMode"), whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')), - content: `
${this.name} has gained 1 SL in the skill ${skill.name} (new SL : ${skill.data.data.level} ) !${this.name} has gained 1 SL in the skill ${skill.name} (new SL : ${skill.data.data.level}) ! { - this.rollData.advantage = "none" - this.refreshDialog() + html.find('#advantage').change((event) => { + this.rollData.advantage = event.currentTarget.value }) - html.find('#advantage-clicked').change((event) => { - this.rollData.advantage = "advantage" - this.refreshDialog() - }) - html.find('#disadvantage-clicked').change((event) => { - this.rollData.advantage = "disadvantage" - this.refreshDialog() - }) - html.find('#roll-with-advantage-clicked').change((event) => { - this.rollData.rollAdvantage = !this.rollData.rollAdvantage - this.refreshDialog() + html.find('#rollAdvantage').change((event) => { + this.rollData.rollAdvantage = event.currentTarget.value }) html.find('#featDieName').change((event) => { this.rollData.featDieName = event.currentTarget.value diff --git a/modules/crucible-utility.js b/modules/crucible-utility.js index 2adb11a..92bce03 100644 --- a/modules/crucible-utility.js +++ b/modules/crucible-utility.js @@ -274,12 +274,18 @@ export class CrucibleUtility { } diceFormula += "+" + String(level) + "d8cs>=5" } - if(rollData.advantage == "advantage") { + if(rollData.advantage == "advantage1") { diceFormula += "+ 1d10cs>=5" } - if(rollData.advantage == "disadvantage") { + if(rollData.advantage == "advantage2") { + diceFormula += "+ 2d10cs>=5" + } + if(rollData.advantage == "disadvantage1") { diceFormula += "- 1d10cs>=5" } + if(rollData.advantage == "disadvantage2") { + diceFormula += "- 2d10cs>=5" + } if (rollData.featDieName != "none") { diceFormula += "+ 1d10cs>=5" } @@ -291,12 +297,19 @@ export class CrucibleUtility { } rollData.roll = myRoll rollData.nbSuccess = myRoll.total - if (rollData.rollAdvantage) { + if (rollData.rollAdvantage != "none") { let myRoll2 = new Roll(diceFormula).roll({ async: false }) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) - if ( myRoll2.total > rollData.nbSuccess) { - rollData.roll = myRoll2 - rollData.nbSuccess = myRoll2.total + if (rollData.rollAdvantage == "roll-advantage") { + if ( myRoll2.total > rollData.nbSuccess) { + rollData.roll = myRoll2 + rollData.nbSuccess = myRoll2.total + } + } else { + if ( myRoll2.total < rollData.nbSuccess) { + rollData.roll = myRoll2 + rollData.nbSuccess = myRoll2.total + } } } // Manage exp @@ -317,6 +330,21 @@ export class CrucibleUtility { actor.lastRoll = rollData } + /* -------------------------------------------- */ + static sortArrayObjectsByName( myArray) { + myArray.sort((a, b) => { + let fa = a.name.toLowerCase(); + let fb = b.name.toLowerCase(); + if (fa < fb) { + return -1; + } + if (fa > fb) { + return 1; + } + return 0; + }) + } + /* -------------------------------------------- */ static getUsers(filter) { return game.users.filter(filter).map(user => user.data._id); diff --git a/system.json b/system.json index a5726c4..ac24858 100644 --- a/system.json +++ b/system.json @@ -208,11 +208,11 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 9, + "templateVersion": 10, "title": "Crucible RPG", "manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.15.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.16.zip", "url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg", - "version": "0.1.15", + "version": "0.1.16", "background" : "./images/ui/crucible_welcome_page.webp" } diff --git a/template.json b/template.json index cdb4bf1..3b178a6 100644 --- a/template.json +++ b/template.json @@ -121,6 +121,8 @@ "armorpenalty": false, "isproficient": false, "isweaponskill": false, + "islore": false, + "skilltype": "", "isinnate": false, "bonusdice": "", "level": 0, diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index f789fc0..0b54a61 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -28,12 +28,26 @@ {{/if}} {{/if}} - {{#if (eq advantage "advantage")}} -
  • Advantage !
  • + + {{#if (eq advantage "advantage1")}} +
  • 1 Advantage Die !
  • {{/if}} - {{#if (eq advantage "disadvantage")}} -
  • Disdvantage !
  • + {{#if (eq advantage "advantage2")}} +
  • 2 Advantage Dice !
  • {{/if}} + {{#if (eq advantage "disadvantage1")}} +
  • 1 Disadvantage Die !
  • + {{/if}} + {{#if (eq advantage "disadvantage2")}} +
  • 2 Disadvantage Dice !
  • + {{/if}} + {{#if (eq rollAdvantage "roll-advantage")}} +
  • Roll with Advantage !
  • + {{/if}} + {{#if (eq rollAdvantage "roll-disadvantage")}} +
  • Roll with Disadvantage !
  • + {{/if}} + {{#if (ne featDieName "none")}}
  • Feature Die : d10 ({{featDieName}})
  • {{/if}} diff --git a/templates/item-skill-sheet.html b/templates/item-skill-sheet.html index 2667f49..b43571e 100644 --- a/templates/item-skill-sheet.html +++ b/templates/item-skill-sheet.html @@ -31,6 +31,15 @@ +
  • + +
  • +
  • + +
  • + +
  • diff --git a/templates/partial-roll-select.html b/templates/partial-roll-select.html index 3995a84..7c9e85f 100644 --- a/templates/partial-roll-select.html +++ b/templates/partial-roll-select.html @@ -1,24 +1,4 @@
      -
    • - - -
    • -
    • - - -
    • -
    • - - -
    • -
    • - - -
    diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html index a30c74a..ef2745c 100644 --- a/templates/roll-dialog-generic.html +++ b/templates/roll-dialog-generic.html @@ -6,8 +6,6 @@

    {{title}}

    -
    -
    @@ -18,10 +16,34 @@ {{#if skill}}
    Skill : - {{skill.name}} - {{skill.data.value}}d8 + {{skill.name}} - {{skill.data.level}}d8
    {{/if}} +
    + Advantage/Disadvantage : + +
    + +
    + Roll with Advantage/Disadvantage : + +
    +
    Feature Die :
    -
    - -
    - {{> systems/fvtt-crucible-rpg/templates/partial-roll-select.html}} -
    -
    \ No newline at end of file