diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cbdaeaf..223b738b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Token bars now display wounds above threshold and most colors are configurable ([#1769](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1769)) * You can now kill a minion or minion group directly from their sheet with a single click! ([#1744](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1744)) * Add derived stats of strainOverThreshold, woundsOverThreshold, hullOverThreshold, and systemStrainOverThreshold to actors (for things like Bar Brawl) ([#1781](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1781)) + * You can now provide a reason for manual XP adjustments ([#1630](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1630)) * Fixes: * Remove usage of deprecated `math.clamped` in favor of `math.clamp` * Fix skill roll sometimes showing a pool of only 2 difficulty when clicked ([#1763](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1763)) diff --git a/lang/en.json b/lang/en.json index c0874adf..3e101529 100644 --- a/lang/en.json +++ b/lang/en.json @@ -795,5 +795,11 @@ "SWFFG.Settings.groupManager.GMCharactersInGroupManager.Name": "Show GM Characters in Group Manager", "SWFFG.Settings.groupManager.GMCharactersInGroupManager.Hint": "Characters owned by a GM will be included in the Group Manager", "SWFFG.Settings.dice.ApplyRemoveSetbackMods.Name": "Roll - Apply \"Remove setback\" mods", - "SWFFG.Settings.dice.ApplyRemoveSetbackMods.Hint": "Automatically apply \"Remove setback\" modifiers when rolling dice." + "SWFFG.Settings.dice.ApplyRemoveSetbackMods.Hint": "Automatically apply \"Remove setback\" modifiers when rolling dice.", + "SWFFG.XP.Adjust.Title": "Adjust XP", + "SWFFG.XP.Adjust.Confirm": "Adjust", + "SWFFG.XP.Adjust.Window.Title": "Adjust Available XP", + "SWFFG.XP.Adjust.Window.Reason": "Adjustment Reason", + "SWFFG.XP.Adjust.Window.Amount": "Adjustment Amount", + "SWFFG.XP.Adjust.Window.Default": "Manual Grant" } diff --git a/modules/actors/actor-sheet-ffg.js b/modules/actors/actor-sheet-ffg.js index ce3cd1e1..e92c87a1 100644 --- a/modules/actors/actor-sheet-ffg.js +++ b/modules/actors/actor-sheet-ffg.js @@ -437,6 +437,10 @@ export class ActorSheetFFG extends ActorSheet { await this._buySkillRank(target); }); + html.find(".xp-adjustment").click(async (ev) => { + await this._xpAdjustment(ev); + }); + html.find(".minion-control").click(async (ev) => { await this._handleKillMinion(ev); }); @@ -2204,6 +2208,56 @@ export class ActorSheetFFG extends ActorSheet { await this.actor.update({'system.stats.wounds.value': this.actor.system.stats.wounds.max + 1}); } } + + async _xpAdjustment(event) { + event.preventDefault(); + event.stopPropagation(); + + const content = ` + + + + + `; + + let d = new Dialog({ + title: game.i18n.localize("SWFFG.XP.Adjust.Window.Title"), + content: content, + buttons: { + one: { + icon: '', + label: game.i18n.localize("SWFFG.XP.Adjust.Confirm"), + callback: async () => { + const startingAvailableXP = parseInt(this.actor.system.experience.available); + const totalXP = parseInt(this.actor.system.experience.total); + const adjustAmount = parseInt($("#adjustAmount").val()); + const adjustReason = $("#adjustReason").val(); + const updatedAvailableXP = startingAvailableXP + adjustAmount; + const updatedTotalXP = totalXP + adjustAmount; + await this.object.update({ + system: { + experience: { + available: updatedAvailableXP, + total: updatedTotalXP, + }, + } + }); + if (adjustAmount > 0) { + await xpLogEarn(this.object, adjustAmount, updatedAvailableXP, updatedTotalXP, adjustReason, "Self"); + } else { + await xpLogSpend(this.object, adjustReason, adjustAmount, updatedAvailableXP, updatedTotalXP); + } + await this.render(true); + } + }, + two: { + icon: '', + label: "Cancel", + } + }, + }); + d.render(true); + } } /** diff --git a/styles/mandar.css b/styles/mandar.css index a3ecb098..994d9515 100644 --- a/styles/mandar.css +++ b/styles/mandar.css @@ -2463,6 +2463,12 @@ img { border-radius: 1rem; } +.starwarsffg .xp-adjustment { + display: flex; + align-items: center; + justify-content: center; +} + .chat-msg-tooltip { color: rgb(25, 24, 19); background: #d8cbc0 url(../images/bgWindow.jpg) no-repeat; diff --git a/templates/actors/ffg-character-sheet.html b/templates/actors/ffg-character-sheet.html index 0343da24..5468c0db 100644 --- a/templates/actors/ffg-character-sheet.html +++ b/templates/actors/ffg-character-sheet.html @@ -255,6 +255,7 @@

{{!-- Experience Box --}} {{> "systems/starwarsffg/templates/parts/shared/ffg-block.html" (object blocktype="split" title="SWFFG.DescriptionXP" fields=(array (object name="data.experience.available" value=data.experience.available type="Number" label="SWFFG.DescriptionXPAvailable") (object name="data.experience.total" value=data.experience.total type="Number" label="SWFFG.DescriptionXPTotal") ))}} +
{{> "systems/starwarsffg/templates/parts/shared/ffg-block.html" (object blocktype="single" title="SWFFG.Actors.Sheets.Purchase.LogTitle" type="PopoutEditor" value=xpLog readonly=true)}}