diff --git a/modules/crucible-actor.js b/modules/crucible-actor.js
index 1b4e405..bc86f2a 100644
--- a/modules/crucible-actor.js
+++ b/modules/crucible-actor.js
@@ -380,6 +380,31 @@ export class CrucibleActor extends Actor {
}
}
+ /* -------------------------------------------- */
+ async incrementSkillExp(skillId, inc) {
+ let skill = this.data.items.get(skillId)
+ if (skill) {
+ await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'data.exp': skill.data.data.exp + inc }])
+ let chatData = {
+ 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}}
= 25) {
+ await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'data.exp': 0, 'data.level': skill.data.data.level + 1 }])
+ let chatData = {
+ 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.rollData.rollAdvantage = !this.rollData.rollAdvantage
+ this.refreshDialog()
+ })
html.find('#featDieName').change((event) => {
this.rollData.featDieName = event.currentTarget.value
})
diff --git a/modules/crucible-utility.js b/modules/crucible-utility.js
index 39ad458..1c49192 100644
--- a/modules/crucible-utility.js
+++ b/modules/crucible-utility.js
@@ -287,9 +287,24 @@ export class CrucibleUtility {
if (!myRoll) { // 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
}
+ rollData.roll = myRoll
rollData.nbSuccess = myRoll.total
+ if (rollData.rollAdvantage) {
+ 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
+ }
+ }
+ // Manage exp
+ if (rollData.skill) {
+ let nbSkillSuccess = rollData.roll.terms[2].total
+ if ( nbSkillSuccess == 0 || nbSkillSuccess == rollData.skill.data.level) {
+ actor.incrementSkillExp(rollData.skill._id, 1)
+ }
+ }
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
diff --git a/templates/partial-roll-select.html b/templates/partial-roll-select.html
index 8648242..3995a84 100644
--- a/templates/partial-roll-select.html
+++ b/templates/partial-roll-select.html
@@ -15,5 +15,10 @@
+
+
+
+