Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(xp): manual adjustment #1790

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 7 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
54 changes: 54 additions & 0 deletions modules/actors/actor-sheet-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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 = `
<label for="adjustAmount">${game.i18n.localize("SWFFG.XP.Adjust.Window.Amount")}</label>
<input type="number" id="adjustAmount" name="adjustAmount" value="0" />
<label for="adjustReason">${game.i18n.localize("SWFFG.XP.Adjust.Window.Reason")}</label>
<input type="text" id="adjustReason" name="adjustReason" value="${game.i18n.localize("SWFFG.XP.Adjust.Window.Default")}" />
`;

let d = new Dialog({
title: game.i18n.localize("SWFFG.XP.Adjust.Window.Title"),
content: content,
buttons: {
one: {
icon: '<i class="fas fa-check"></i>',
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: '<i class="fas fa-times"></i>',
label: "Cancel",
}
},
});
d.render(true);
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions styles/mandar.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions templates/actors/ffg-character-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ <h2><input name="name" type="text" value="{{actor.name}}" placeholder="{{localiz
<div class="tab xp" data-group="primary" data-tab="xp">
{{!-- 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") ))}}
<div class="xp-adjustment" title="{{ localize "SWFFG.XP.Adjust.Title" }}"><a class="fa-solid fa-eraser"></a></div>
{{> "systems/starwarsffg/templates/parts/shared/ffg-block.html" (object blocktype="single" title="SWFFG.Actors.Sheets.Purchase.LogTitle" type="PopoutEditor" value=xpLog readonly=true)}}
</div>

Expand Down