Skip to content

Commit

Permalink
feat: add ability to not include effect in damage rolls
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin9257 committed Nov 16, 2023
1 parent 858b54d commit 2d71902
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/module/entities/TwodsixItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ export default class TwodsixItem extends Item {
for (let i = 0; i < numberOfAttacks; i++) {
const roll = await this.skillRoll(false, settings, showInChat);
if (game.settings.get("twodsix", "automateDamageRollOnHit") && roll?.isSuccess()) {
const totalBonusDamage = (bonusDamage !== "0" && bonusDamage !== "") ? `${roll.effect} + ${bonusDamage}` : `${roll.effect}`;
let totalBonusDamage = game.settings.get('twodsix', 'addEffectToDamage') ? `${roll.effect}` : ``;
if (bonusDamage !== "0" && bonusDamage !== "") {
totalBonusDamage += (game.settings.get('twodsix', 'addEffectToDamage') ? ` + `: ``) + `${bonusDamage}`;
}
const damagePayload = await this.rollDamage(settings.rollMode, totalBonusDamage, showInChat, false) || null;
if (targets.length >= 1 && damagePayload) {
targets[i%targets.length].actor.handleDamageData(damagePayload, <boolean>!game.settings.get('twodsix', 'autoDamageTarget'));
Expand Down Expand Up @@ -604,7 +607,7 @@ export async function onRollDamage(event):Promise<void> {

const element = $(event.currentTarget);
let bonusDamageFormula = String(element.data('bonus-damage') || 0);
if (game.settings.get('twodsix', 'addEffectToManualDamage')) {
if (game.settings.get('twodsix', 'addEffectToManualDamage') && game.settings.get('twodsix', 'addEffectToDamage')) {
const lastMessage = <ChatMessage>(game.messages?.contents.pop());
if (lastMessage?.getFlag("twodsix", "effect")) {
bonusDamageFormula === "0" ? bonusDamageFormula = String(lastMessage.getFlag("twodsix", "effect")) : bonusDamageFormula += `+` + String(lastMessage.getFlag("twodsix", "effect"));
Expand Down
5 changes: 4 additions & 1 deletion src/module/hooks/chatCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ async function onChatCardAction(event: Event): Promise<any> {
const showFormulaDialog = useInvertedShiftClick ? event["shiftKey"] : !event["shiftKey"];
const bonusDamage:string = message.getFlag("twodsix", "bonusDamage");
const effect = message.getFlag("twodsix", "effect") ?? 0;
const totalBonusDamage = (bonusDamage !== "0" && bonusDamage !== "") ? `${effect} + ${bonusDamage}` : `${effect}`;
let totalBonusDamage = game.settings.get("twodsix", "addEffectToDamage") ? `${effect}` : ``;
if (bonusDamage !== "0" && bonusDamage !== "") {
totalBonusDamage += (game.settings.get('twodsix', 'addEffectToDamage') ? ` + `: ``) + `${bonusDamage}`;
}
switch ( action ) {
case "damage":
await item.rollDamage((<DICE_ROLL_MODES>game.settings.get('core', 'rollMode')), totalBonusDamage, true, showFormulaDialog);
Expand Down
10 changes: 9 additions & 1 deletion src/module/settings/RulsetSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,17 @@ export default class RulesetSettings extends AdvancedSettings {
settings.animals_robots.push(booleanSetting("displayReactionMorale", false));
settings.damage.push(booleanSetting("useDodgeParry", false));
settings.damage.push(stringSetting("damageTypeOptions", "", false, "world"));
settings.damage.push(booleanSetting('addEffectToManualDamage', false));
settings.damage.push(booleanSetting('addEffectToDamage', true, false, "world", checkManualDamageSetting));
settings.damage.push(booleanSetting('addEffectToManualDamage', false, false, "world", checkManualDamageSetting));
settings.roll.push(stringChoiceSetting('useDegreesOfSuccess', "none", true, TWODSIX.SuccessTypes));
settings.roll.push(booleanSetting("overrideSuccessWithNaturalCrit", false));
return settings;
}
}

export const checkManualDamageSetting = function () {
if (!game.settings.get('twodsix', 'addEffectToDamage') && game.settings.get('twodsix', 'addEffectToManualDamage')) {
game.settings.set('twodsix', 'addEffectToManualDamage', false);
ui.notifications.warn(game.i18n.localize("TWODSIX.Warnings.ResetEffectForManualDamage"));
}
};
1 change: 1 addition & 0 deletions src/types/twodsix.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ declare global {
'twodsix.showTimeframe': boolean;
'twodsix.showStatusIcons': boolean;
'twodsix.showHullAndArmor': string;
'twodsix.addEffectToDamage': boolean;
'twodsix.addEffectToManualDamage': boolean;
'twodsix.showRangeSpeedNoUnits': boolean;
'twodsix.showInitiativeButton': boolean;
Expand Down

0 comments on commit 2d71902

Please sign in to comment.