diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 1edefea..bde790f 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -58,6 +58,7 @@ export class PegasusActorSheet extends ActorSheet { effects: duplicate(this.actor.getEffects()), moneys: duplicate(this.actor.getMoneys()), encCapacity: this.actor.getEncumbranceCapacity(), + levelRemainingList: this.actor.getLevelRemainingList(), containersTree: this.actor.containersTree, encCurrent: this.actor.encCurrent, encHindrance: this.actor.encHindrance, @@ -79,6 +80,10 @@ export class PegasusActorSheet extends ActorSheet { rollData.mode = "generic" rollData.title = `Dice Pool Roll` rollData.img = "icons/dice/d12black.svg" + rollData.isGeneric = true + rollData.traumaState = this.actor.getTraumaState() + rollData.diceList = PegasusUtility.getDiceList() + rollData.dicePool = [] let rollDialog = await PegasusRollDialog.create( this.actor, rollData); rollDialog.render( true ); diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 4232f89..f2999a0 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -857,6 +857,18 @@ export class PegasusActor extends Actor { return this.traumaState } + /* -------------------------------------------- */ + getLevelRemaining() { + return this.data.data.biodata.currentlevelremaining + } + /* -------------------------------------------- */ + modifyHeroLevelRemaining( incDec) { + let biodata = duplicate(this.data.data.biodata) + biodata.currentlevelremaining = Math.max(biodata.currentlevelremaining+incDec, 0) + this.update( {"data.biodata": biodata} ) + return biodata.currentlevelremaining + } + /* -------------------------------------------- */ async computeNRGHealth() { if (this.isToken) return @@ -1205,6 +1217,7 @@ export class PegasusActor extends Actor { rollData.actorId = this.id rollData.img = this.img rollData.traumaState = this.getTraumaState() + rollData.levelRemaining = this.getLevelRemaining() rollData.activePerks = duplicate(this.getActivePerks()) rollData.diceList = PegasusUtility.getDiceList() rollData.dicePool = [] @@ -1223,7 +1236,7 @@ export class PegasusActor extends Actor { } let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value) rollData.dicePool.push({ - name: "stat", key: diceKey, + name: "stat", key: diceKey, mod: rollData.stat.mod, img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp` }) } @@ -1236,6 +1249,15 @@ export class PegasusActor extends Actor { return rollData } + /* -------------------------------------------- */ + getLevelRemainingList( ) { + let options = [] + for (let i=0; i<=this.data.data.biodata.maxlevelremaining; i++) { + options.push( ``) + } + return options.join("\n") + } + /* -------------------------------------------- */ async startRoll(rollData) { this.syncRoll(rollData); @@ -1251,7 +1273,7 @@ export class PegasusActor extends Actor { let power = this.data.items.get(itemId) if (power) { power = duplicate(power) - this.rollPool(power.data.dmgstatistic) + this.rollPool(power.data.dmgstatistic, false, "power-dmg") } } @@ -1264,7 +1286,9 @@ export class PegasusActor extends Actor { rollData.subKey = subKey rollData.title = `Roll : ${stat.label} ` rollData.img = "icons/dice/d12black.svg" - + if (subKey == "melee-dmg" || subKey == "ranged-dmg" || subKey == "power-dmg") { + rollData.isDamage = true + } this.startRoll(rollData) } else { ui.notifications.warn("Statistic not found !"); @@ -1312,6 +1336,7 @@ export class PegasusActor extends Actor { rollData.specName = spec.name rollData.img = spec.img rollData.specDicesLevel = spec.data.level + PegasusUtility.updateSpecDicePool(rollData) this.startRoll(rollData) } else { ui.notifications.warn("Specialisation not found !"); @@ -1355,7 +1380,7 @@ export class PegasusActor extends Actor { rollData.title = `Armor : ${armor.name}` rollData.isResistance = true; rollData.img = armor.img - rollData.otherDicesLevel = armor.data.resistance + rollData.damageDiceLevel = armor.data.resistance this.startRoll(rollData); } else { diff --git a/modules/pegasus-roll-dialog.js b/modules/pegasus-roll-dialog.js index a07483b..95b24c4 100644 --- a/modules/pegasus-roll-dialog.js +++ b/modules/pegasus-roll-dialog.js @@ -5,7 +5,7 @@ export class PegasusRollDialog extends Dialog { /* -------------------------------------------- */ static async create(actor, rollData) { - let options = { classes: ["PegasusDialog"], width: 620, height: 380, 'z-index': 99999 }; + let options = { classes: ["PegasusDialog"], width: 620, height: 480, 'z-index': 99999 }; let html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-generic.html', rollData); return new PegasusRollDialog(actor, rollData, html, options); @@ -63,7 +63,7 @@ export class PegasusRollDialog extends Dialog { idVal = "#statDicesLevel" } if (effectData.data.otherdice) { - idVal = "#otherDicesLevel" + idVal = "#damageDiceLevel" } if (effectData.data.hindrance) { idVal = "#hindranceDicesLevel" @@ -96,8 +96,9 @@ export class PegasusRollDialog extends Dialog { this.rollData.specDicesLevel = Number($('#specDicesLevel').val()) //this.rollData.bonusDicesLevel = Number($('#bonusDicesLevel').val()) //this.rollData.hindranceDicesLevel = Number($('#hindranceDicesLevel').val()) - this.rollData.otherDicesLevel = Number($('#otherDicesLevel').val()) + this.rollData.damageDiceLevel = Number($('#damageDiceLevel').val()) PegasusUtility.updateSpecDicePool(this.rollData) + PegasusUtility.updateDamageDicePool(this.rollData) PegasusUtility.updateEffectsBonusDice(this.rollData) } @@ -148,7 +149,7 @@ export class PegasusRollDialog extends Dialog { let equip = this.rollData.equipmentsList[equipIdx] if (equip) { equip.applied = toggled - let idVal = "#otherDicesLevel" // Default + let idVal = "#damageDiceLevel" // Default if (equip.equip.data.bonusdice) { idVal = "#bonusDicesLevel" } @@ -156,7 +157,7 @@ export class PegasusRollDialog extends Dialog { idVal = "#statDicesLevel" } if (equip.equip.data.otherdice) { - idVal = "#otherDicesLevel" + idVal = "#damageDiceLevel" } let newLevel = Number($(idVal).val()) if (toggled) { @@ -171,7 +172,7 @@ export class PegasusRollDialog extends Dialog { this.rollData.specDicesLevel = Number($('#specDicesLevel').val()) this.rollData.bonusDicesLevel = Number($('#bonusDicesLevel').val()) this.rollData.hindranceDicesLevel = Number($('#hindranceDicesLevel').val()) - this.rollData.otherDicesLevel = Number($('#otherDicesLevel').val()) + this.rollData.damageDiceLevel = Number($('#damageDiceLevel').val()) } } @@ -214,14 +215,10 @@ export class PegasusRollDialog extends Dialog { PegasusUtility.updateSpecDicePool(this.rollData) this.refreshDialog() }); - html.find('#bonusDicesLevel').change((event) => { - this.rollData.bonusDicesLevel = Number(event.currentTarget.value) - }); - html.find('#hindranceDicesLevel').change((event) => { - this.rollData.hindranceDicesLevel = Number(event.currentTarget.value) - }); - html.find('#otherDicesLevel').change((event) => { - this.rollData.otherDicesLevel = Number(event.currentTarget.value) + html.find('#damageDiceLevel').change(async (event) => { + this.rollData.damageDiceLevel = Number(event.currentTarget.value) + PegasusUtility.updateDamageDicePool(this.rollData) + this.refreshDialog() }); html.find('.effect-clicked').change(async (event) => { let toggled = event.currentTarget.checked diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index cc011e9..e863357 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -81,16 +81,38 @@ export class PegasusUtility { rollData.dicePool = newDicePool } + /* -------------------------------------------- */ + static updateDamageDicePool(rollData) { + if (rollData.isDamage) { + let newDicePool = rollData.dicePool.filter(dice => dice.name != "damage") + if (rollData.damageDiceLevel > 0) { + let diceKey = PegasusUtility.getDiceFromLevel(rollData.damageDiceLevel) + let diceList = diceKey.split(" ") + for(let myDice of diceList) { + let newDice = { + name: "damage", key: myDice, + img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp` + } + newDicePool.push(newDice) + } + } + rollData.dicePool = newDicePool + } + } + /* -------------------------------------------- */ static updateSpecDicePool(rollData) { let newDicePool = rollData.dicePool.filter(dice => dice.name != "spec") if (rollData.specDicesLevel > 0) { let diceKey = PegasusUtility.getDiceFromLevel(rollData.specDicesLevel) - let newDice = { - name: "spec", key: diceKey, - img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp` + let diceList = diceKey.split(" ") + for(let myDice of diceList) { + let newDice = { + name: "spec", key: myDice, + img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp` + } + newDicePool.push(newDice) } - newDicePool.push(newDice) } rollData.dicePool = newDicePool } @@ -107,8 +129,7 @@ export class PegasusUtility { /*-------------------------------------------- */ static removeFromDicePool( rollData, diceIdx ) { let toRemove = rollData.dicePool[diceIdx] - console.log("CLICK : ", rollData.dicePool, diceIdx) - if (toRemove && toRemove.name != "spec" && toRemove.name != "stat") { + if (toRemove && toRemove.name != "spec" && toRemove.name != "stat" && toRemove.name != "damage") { let newDicePool = [] for (let i=0; i { game.system.pegasus.creator.processChatEvent(event); - }); + }) html.on("click", '.view-item-from-chat', event => { game.system.pegasus.creator.openItemView(event) - }); + }) + html.on("click", '.reroll-level-remaining', event => { + let rollId = $(event.currentTarget).data("roll-id") + let rollData = this.getRollData(rollId) + rollData.reroll = true + this.rollPegasus( rollData) + }) + } /* -------------------------------------------- */ @@ -347,7 +375,7 @@ export class PegasusUtility { static getDiceValue(level = 0) { let diceString = this.diceList[level] if (!diceString) { - console.log("Level error", level) + return __name2DiceValue[level] } let diceTab = diceString.split(" ") let diceValue = 0 @@ -554,6 +582,7 @@ export class PegasusUtility { /* -------------------------------------------- */ static async rollPegasus(rollData) { + /* let dicePool = [{ name: "stat", level: 0, statmod: 0 }, { name: "spec", level: 0 }, { name: "bonus", level: 0 }, { name: "hindrance", level: 0 }, { name: "other", level: 0 }]; if (rollData.stat) { dicePool[0].level += Number(rollData.stat.value) @@ -591,23 +620,34 @@ export class PegasusUtility { diceFormulaTab.push(this.getFoundryDiceFromLevel(diceGroup.level)) } let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh'; + */ + + let actor = game.actors.get(rollData.actorId) + + let diceFormulaTab = [] + for (let dice of rollData.dicePool) { + diceFormulaTab.push(dice.key) + } + let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh + ' + (rollData.stat?.mod || 0) // Performs roll - let myRoll = rollData.roll; - if (!myRoll) { // New rolls only of no rerolls - myRoll = new Roll(diceFormula).roll({ async: false }); - await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")); + let myRoll = rollData.roll + if (!myRoll || rollData.reroll) { // New rolls only of no rerolls + myRoll = new Roll(diceFormula).roll({ async: false }) + await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) rollData.roll = myRoll } - + if (rollData.reroll) { + rollData.levelRemaining = actor.modifyHeroLevelRemaining(-1) + } // Final score and keep data - rollData.finalScore = myRoll.total + dicePool[0].statmod; + rollData.finalScore = myRoll.total if (rollData.damages) { let dmgFormula = this.getFoundryDiceFromLevel(rollData.damages.value) - let dmgRoll = new Roll(dmgFormula).roll({ async: false }); - await this.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode")); - rollData.dmgResult = dmgRoll.total; + let dmgRoll = new Roll(dmgFormula).roll({ async: false }) + await this.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode")) + rollData.dmgResult = dmgRoll.total } this.createChatWithRollMode(rollData.alias, { @@ -617,12 +657,11 @@ export class PegasusUtility { // Init stuf if (rollData.isInit) { let combat = game.combats.get(rollData.combatId) - combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]); + combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]) } // Stun specific -> Suffere a stun level when dmg-res if (rollData.subKey && rollData.subKey == "dmg-res") { - let actor = game.actors.get(rollData.actorId) actor.modifyStun(-1) } diff --git a/system.json b/system.json index 10a5b82..a208faf 100644 --- a/system.json +++ b/system.json @@ -180,9 +180,9 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 92, + "templateVersion": 94, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.5.13", + "version": "0.5.15", "background" : "./images/ui/pegasus_welcome_page.webp" } diff --git a/template.json b/template.json index 03af94a..1c31c11 100644 --- a/template.json +++ b/template.json @@ -21,7 +21,8 @@ "catchphraseused": false, "catchphrasetrigger": "", "charactervalue": 0, - "level": 0, + "maxlevelremaining": 0, + "currentlevelremaining": 0, "threatlevel": 0, "cdp": 0, "cdpused": 0, @@ -197,7 +198,7 @@ } }, "Item": { - "types": [ "race", "role", "ability", "specialisation", "perk", "power" , "armor", "shield", "equipment", "weapon", "effect", "money", "virtuevice"], + "types": [ "race", "role", "ability", "specialisation", "perk", "power" , "armor", "shield", "equipment", "weapon", "effect", "money", "virtue", "vice"], "effect": { "type": "", "genre": "", @@ -266,9 +267,13 @@ "threatlevel": 0, "description": "" }, - "virtuevice": { - "subtype": "", + "virtue": { "unavailablevice": [], + "effectsgained": [], + "threatlevel": 0, + "description": "" + }, + "vice": { "unavailablevirtue": [], "effectsgained": [], "threatlevel": 0, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 44180b7..96f02ca 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -927,13 +927,16 @@
  • - - + +
  • - +
  • diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index 658ae08..23ade78 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -48,6 +48,10 @@ {{/if}} {{/if}} + {{#if levelRemaining}} + + {{/if}} + diff --git a/templates/item-ability-sheet.html b/templates/item-ability-sheet.html index ef9da6c..16d59ed 100644 --- a/templates/item-ability-sheet.html +++ b/templates/item-ability-sheet.html @@ -88,25 +88,6 @@
  • - -
  • diff --git a/templates/item-vice-sheet.html b/templates/item-vice-sheet.html new file mode 100644 index 0000000..b2cd797 --- /dev/null +++ b/templates/item-vice-sheet.html @@ -0,0 +1,59 @@ +
    +
    + +
    +

    +
    +
    + + {{> systems/fvtt-pegasus-rpg/templates/partial-item-nav.html}} + + {{!-- Sheet Body --}} +
    + + {{> systems/fvtt-pegasus-rpg/templates/partial-item-description.html}} + +
    +
  • +
  • +
  • +
      +
    • +
    • + {{#each data.unavailablevirtue as |vice idx|}} +
    • + +
      + +
      +
    • + {{/each}} +
    +
  • + +
  • +
  • +
  • +
      +
    • +
    • + {{#each data.effectsgained as |effect idx|}} +
    • + +
      + +
      +
    • + {{/each}} +
    +
  • + +
  • + +
  • + + +
    + +
    +
    diff --git a/templates/item-virtue-sheet.html b/templates/item-virtue-sheet.html new file mode 100644 index 0000000..b748e7c --- /dev/null +++ b/templates/item-virtue-sheet.html @@ -0,0 +1,59 @@ +
    +
    + +
    +

    +
    +
    + + {{> systems/fvtt-pegasus-rpg/templates/partial-item-nav.html}} + + {{!-- Sheet Body --}} +
    + + {{> systems/fvtt-pegasus-rpg/templates/partial-item-description.html}} + +
    +
  • +
  • +
  • +
      +
    • +
    • + {{#each data.unavailablevice as |vice idx|}} +
    • + +
      + +
      +
    • + {{/each}} +
    +
  • + +
  • +
  • +
  • +
      +
    • +
    • + {{#each data.effectsgained as |effect idx|}} +
    • + +
      + +
      +
    • + {{/each}} +
    +
  • + +
  • + +
  • + + +
    + +
    +
    diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html index fedc403..623c754 100644 --- a/templates/roll-dialog-generic.html +++ b/templates/roll-dialog-generic.html @@ -10,6 +10,9 @@
    + {{#if isGeneric}} + + {{else}}
    Stat Dice : - {{#select selectedSpec}} - - {{#each specList as |spec idx|}} - - {{/each}} - {{/select}} - -   -
    - {{/if}} + {{#if specList}} +
    + Spec : + +   +
    + {{/if}}
    Spec Dice : @@ -47,17 +50,20 @@  
    + {{/if}} + {{#if isDamage}}
    Weapon Damage : - + {{#select damageDiceLevel}} {{{optionsDiceList}}} {{/select}}  
    + {{/if}}