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

added support for charge 2024 feat with additional GWF 2014/24 #1195

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 src/dndbeyond/base/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class Character extends CharacterBase {
let is2024 = false;
if((feat_name.toLowerCase() === "great weapon master" ||
feat_name.toLowerCase() === "sharpshooter" ||
feat_name.toLowerCase() === "charger" ||
feat_name.toLowerCase() === "polearm master") &&
feat_reference.toLowerCase().includes("2024")) {
is2024 = true;
Expand Down
20 changes: 20 additions & 0 deletions src/dndbeyond/content-scripts/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,26 @@ function handleSpecialMeleeAttacks(damages=[], damage_types=[], properties, sett
damages.push("+5");
damage_types.push("Charger Feat");
settings_to_change["charger-feat"] = false;
} else if (character.hasFeat("Charger 2024") &&
character.getSetting("charger-feat")) {
let charge_dmg = "1d8";
// apply GWF if needed
if(((properties["Attack Type"] == "Melee" && ((properties["Properties"].includes("Versatile") && character.getSetting("versatile-choice") != "one") ||
properties["Properties"].includes("Two-Handed"))) ||
action_name == "Polearm Master - Bonus Attack" ||
action_name == "Pole Strike")) {
if(character.hasGreatWeaponFighting(2014)) {
charge_dmg += "ro<=2";
} else if(character.hasGreatWeaponFighting(2024)) {
charge_dmg = charge_dmg.replace(/([0-9]*)d([0-9]+)([^\s+-]*)(.*)/g, (match, amount, faces, roll_mods, mods) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need all this complex regexp, you know charge_dmg is 1d8, you can just do charge_dmg = "1d8min3" or use += safely, like for 2014 version

return new Array(parseInt(amount) || 1).fill(`1d${faces}${roll_mods}min3`).join(" + ") + mods;
});
}
}

damages.push(charge_dmg);
damage_types.push("Charger Feat");
settings_to_change["charger-feat"] = false;
}

return to_hit;
Expand Down
2 changes: 1 addition & 1 deletion src/extension/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function populateCharacter(response) {
e = createHTMLOption("artificer-arcane-jolt", false, character_settings);
options.append(e);
}
if (response["feats"].includes("Charger")) {
if (response["feats"].some(f => f.toLowerCase().includes("charger"))) {
e = createHTMLOption("charger-feat", false, character_settings);
options.append(e);
}
Expand Down