Skip to content

Commit d29a404

Browse files
authored
Merge pull request #1302 from kakaroto/wild-shape-fix
fix: stop custom damages being added twice and tiding up code
2 parents 1038cf8 + d2740bf commit d29a404

File tree

4 files changed

+44
-32
lines changed

4 files changed

+44
-32
lines changed

src/common/settings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ const character_settings = {
938938
"type": "bool",
939939
"default": false
940940
},
941+
"druid-circle-of-mutation-circle-forms": {
942+
"title": "Druid: Circle of Mutation - Circle Forms",
943+
"description": "Predator's Strike. When you hit a creature with an attack roll using a Beast form's attack in Wild Shape, you add +2 to the damage dealt.",
944+
"type": "bool",
945+
"default": false
946+
},
941947
"discord-target": {
942948
"title": "Discord Destination",
943949
"description": "Send rolls to a character specific Discord channel",

src/dndbeyond/base/extras.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -563,27 +563,25 @@ class MonsterExtras extends CharacterBase {
563563
addEffect(roll_properties, "Rage");
564564
}
565565

566-
if(this._parent_character.hasClass("Druid") && this._parent_character.hasClassFeature("Improved Lunar Radiance", true) && this._parent_character.getSetting("druid-improved-lunar-radiance", false))
567-
{
568-
roll_properties["damages"].push(String("2d10"));
569-
roll_properties["damage-types"].push("Lunar Radiance");
566+
if(this._parent_character.hasClass("Druid")) {
567+
if(this._parent_character.hasClassFeature("Improved Lunar Radiance", true) && this._parent_character.getSetting("druid-improved-lunar-radiance", false))
568+
{
569+
roll_properties["damages"].push(String("2d10"));
570+
roll_properties["damage-types"].push("Lunar Radiance");
571+
}
572+
if(this._parent_character.hasClassFeature("Druid Subclass: Circle of Mutation", true)
573+
&& this._parent_character.hasClassFeature("Circle Forms", true)
574+
&& this._parent_character.getSetting("druid-circle-of-mutation-circle-forms", false))
575+
{
576+
roll_properties["damages"].push(String("2"));
577+
roll_properties["damage-types"].push("Predator's Strike");
578+
}
570579
}
580+
571581
// Add custom damages to wild shape attacks
572582
addCustomDamages(character, roll_properties["damages"], roll_properties["damage-types"]);
573-
}
574-
if (roll_properties["damages"] && roll_properties["damages"].length > 0) {
575-
for (const key in key_modifiers) {
576-
if (!key.startsWith("custom_damage:") || !key_modifiers[key]) continue;
577-
const custom_damage = key.slice("custom_damage:".length);
578-
if (custom_damage.includes(":")) {
579-
const parts = custom_damage.split(":", 2);
580-
roll_properties["damages"].push(parts[1].trim());
581-
roll_properties["damage-types"].push(parts[0].trim());
582-
} else {
583-
roll_properties["damages"].push(custom_damage.trim());
584-
roll_properties["damage-types"].push("Custom");
585-
}
586-
}
583+
} else if (roll_properties["damages"] && roll_properties["damages"].length > 0) {
584+
addCustomDamages(character, roll_properties["damages"], roll_properties["damage-types"]);
587585
}
588586
if (roll_properties["to-hit"]) {
589587
for (const key in key_modifiers) {

src/dndbeyond/base/monster.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -625,22 +625,26 @@ class Monster extends CharacterBase {
625625
roll_properties["damage-types"].push("Rage");
626626
addEffect(roll_properties, "Rage");
627627
}
628-
// Add custom damages to wild shape attacks
629-
addCustomDamages(character, roll_properties["damages"], roll_properties["damage-types"]);
630-
}
631-
if (roll_properties["damages"] && roll_properties["damages"].length > 0) {
632-
for (const key in key_modifiers) {
633-
if (!key.startsWith("custom_damage:") || !key_modifiers[key]) continue;
634-
const custom_damage = key.slice("custom_damage:".length);
635-
if (custom_damage.includes(":")) {
636-
const parts = custom_damage.split(":", 2);
637-
roll_properties["damages"].push(parts[1].trim());
638-
roll_properties["damage-types"].push(parts[0].trim());
639-
} else {
640-
roll_properties["damages"].push(custom_damage.trim());
641-
roll_properties["damage-types"].push("Custom");
628+
629+
if(this._parent_character.hasClass("Druid")) {
630+
if(this._parent_character.hasClassFeature("Improved Lunar Radiance", true) && this._parent_character.getSetting("druid-improved-lunar-radiance", false))
631+
{
632+
roll_properties["damages"].push(String("2d10"));
633+
roll_properties["damage-types"].push("Lunar Radiance");
634+
}
635+
if(this._parent_character.hasClassFeature("Druid Subclass: Circle of Mutation", true)
636+
&& this._parent_character.hasClassFeature("Circle Forms", true)
637+
&& this._parent_character.getSetting("druid-circle-of-mutation-circle-forms", false))
638+
{
639+
roll_properties["damages"].push(String("2"));
640+
roll_properties["damage-types"].push("Predator's Strike");
642641
}
643642
}
643+
644+
// Add custom damages to wild shape attacks
645+
addCustomDamages(character, roll_properties["damages"], roll_properties["damage-types"]);
646+
} else if (roll_properties["damages"] && roll_properties["damages"].length > 0) {
647+
addCustomDamages(character, roll_properties["damages"], roll_properties["damage-types"]);
644648
}
645649
if (roll_properties["to-hit"]) {
646650
for (const key in key_modifiers) {

src/extension/popup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ function populateCharacter(response) {
362362
e = createHTMLOption("druid-improved-lunar-radiance", false, character_settings);
363363
options.append(e);
364364
}
365+
if (response["class-features"].includes("Druid Subclass: Circle of Mutation") && response["class-features"].includes("Circle Forms")) {
366+
e = createHTMLOption("druid-circle-of-mutation-circle-forms", false, character_settings);
367+
options.append(e);
368+
}
365369
}
366370
$('.beyond20-option-input').off('change', save_settings);
367371
$('.beyond20-option-input').change(save_settings);

0 commit comments

Comments
 (0)