Skip to content

Commit

Permalink
Merge pull request #220 from Havoclivekiller/master
Browse files Browse the repository at this point in the history
Fix above 20 result
  • Loading branch information
ClipplerBlood authored Dec 17, 2024
2 parents 21e7c74 + 9319427 commit a82a6cc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 38 deletions.
2 changes: 2 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@
"DL.RollFormula": "Roll formula",
"DL.SettingAttackReverseDamage": "Reverse Damage/Health",
"DL.SettingAttackReverseDamageHint": "Substract damage from Health insted of adding damage.",
"DL.SettingOptinalRuleExceedsByFive": "20+ rule more than 5",
"DL.SettingOptinalRuleExceedsByFiveHint": "Rules of effects of 20+ will require that you exceed the target by more than 5.",
"DL.SettingAttackShowEnemyAttribute": "Show Creature target number",
"DL.SettingAttackShowEnemyAttributeAtt": "Show the Creatures attack number",
"DL.SettingAttackShowEnemyAttributeAttHint": "Show the Creatures attack number you are rolling against in the chat.",
Expand Down
8 changes: 4 additions & 4 deletions src/module/chat/roll-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function postAttackToChat(attacker, defender, item, attackRoll, attackAtt
? defender?.system.characteristics.defense
: defender?.getAttribute(defenseAttribute)?.value || ''

const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + 5 : true)
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + (optinalRuleExceedsByFive ? 5 : 4) : true)

Check failure on line 57 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 57 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 57 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined
const didHit = voidRoll ? false : attackRoll?.total >= targetNumber

let diceTotalGM = attackRoll?.total ?? ''
Expand Down Expand Up @@ -223,7 +223,7 @@ export function postTalentToChat(actor, talent, attackRoll, target, inputBoons)
}

const targetNumber = talentData?.action?.attack ? actor.getTargetNumber(talent) : ''
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + 5 : true)
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + (optinalRuleExceedsByFive ? 5 : 4) : true)

Check failure on line 226 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 226 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 226 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

let resultText =
!voidRoll && attackRoll != null && targetNumber !== undefined && attackRoll.total >= parseInt(targetNumber)
Expand Down Expand Up @@ -339,7 +339,7 @@ export async function postSpellToChat(actor, spell, attackRoll, target, inputBoo
if (uses >= 0 && usesMax > 0) usesText = game.i18n.localize('DL.SpellCastingsUses') + ': ' + uses + ' / ' + usesMax

const targetNumber = actor.getTargetNumber(spell)
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + 5 : true)
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + (optinalRuleExceedsByFive ? 5 : 4) : true)

Check failure on line 342 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 342 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 342 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

let resultText =
!voidRoll && targetNumber && attackRoll?.total >= parseInt(targetNumber)
Expand Down Expand Up @@ -511,7 +511,7 @@ export const postItemToChat = (actor, item, attackRoll, target, inputBoons) => {
}*/

const targetNumber = itemData?.action?.attack ? actor.getTargetNumber(item) : ''
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + 5 : true)
const plus20 = attackRoll?.total >= 20 && (targetNumber ? attackRoll?.total > targetNumber + (optinalRuleExceedsByFive ? 5 : 4) : true)

Check failure on line 514 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 514 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

Check failure on line 514 in src/module/chat/roll-messages.js

View workflow job for this annotation

GitHub Actions / lint

'optinalRuleExceedsByFive' is not defined

let resultText =
!voidRoll && attackRoll != null && targetNumber !== undefined && attackRoll.total >= parseInt(targetNumber)
Expand Down
12 changes: 11 additions & 1 deletion src/module/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export class OptionalRulesSettings extends FormApplication {
i: game.i18n.localize('DL.SettingOptionalRuleInitiativeInduvidual'),
h: game.i18n.localize('DL.SettingOptionalRuleInitiativeGroup'),
},
optinalRuleRollInitEachRound: game.settings.get('demonlord', 'optinalRuleRollInitEachRound')
optinalRuleRollInitEachRound: game.settings.get('demonlord', 'optinalRuleRollInitEachRound'),
optinalRuleExceedsByFive: game.settings.get('demonlord', 'optinalRuleExceedsByFive')
}
}

Expand Down Expand Up @@ -178,6 +179,15 @@ export const registerSettings = function () {
config: false,
})

game.settings.register('demonlord', 'optinalRuleExceedsByFive', {
name: game.i18n.localize('DL.SettingOptinalRuleExceedsByFive'),
hint: game.i18n.localize('DL.SettingOptinalRuleExceedsByFiveDamageHint'),
default: false,
scope: 'world',
type: Boolean,
config: false,
})

game.settings.register('demonlord', 'optionalRuleDieRollsMode', {
name: game.i18n.localize('DL.SettingOptionalRuleDieRollsMode'),
scope: 'world',
Expand Down
70 changes: 37 additions & 33 deletions src/templates/setting/optionalrules.hbs
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
<form autocomplete="off">

<div class="form-group">
<label>{{localize "DL.SettingOptionalRuleConsistentDamage"}}</label>
<input type="checkbox" name="optinalRuleConsistentDamage" {{checked optinalRuleConsistentDamage}} data-dtype="Boolean"/>
</div>
<hr>
<div class="form-group">
<label>{{localize "DL.SettingOptionalRuleDieRollsMode"}}</label>
<select name="optionalRuleDieRollsMode">
{{selectOptions dieRollsDropDrown selected=selectedDieRollsDropDrown localize=true}}
</select>
</div>
<hr>
<div class="form-group">
<label>{{localize "DL.SettingOptionalRuleInitiative"}}</label>
<select name="optionalRuleInitiativeMode">
{{selectOptions initiativeMethodDropDrown selected=selectedInitiativeMethodDropDrown localize=true}}
</select>
</div>
<div class="form-group">
<label>{{localize "DL.SettingOptinalRuleRollInitEachRound"}}</label>
<input type="checkbox" name="optinalRuleRollInitEachRound" {{checked optinalRuleRollInitEachRound}} data-dtype="Boolean"/>
</div>
<footer class="sheet-footer flexrow">
<button type="submit" name="submit">
<i class="far fa-save"></i>
{{localize "SETTINGS.Save"}}
</button>
<button type="button" data-action="reset">
<i class="fas fa-undo"></i>
{{localize "SETTINGS.Reset"}}
</button>
</footer>
</form>
<div class="form-group">
<label>{{localize "DL.SettingOptionalRuleConsistentDamage"}}</label>
<input type="checkbox" name="optinalRuleConsistentDamage" {{checked optinalRuleConsistentDamage}} data-dtype="Boolean" />
</div>
<hr>
<div class="form-group">
<label>{{localize "DL.SettingOptionalRuleDieRollsMode"}}</label>
<select name="optionalRuleDieRollsMode">
{{selectOptions dieRollsDropDrown selected=selectedDieRollsDropDrown localize=true}}
</select>
</div>
<hr>
<div class="form-group">
<label>{{localize "DL.SettingOptionalRuleInitiative"}}</label>
<select name="optionalRuleInitiativeMode">
{{selectOptions initiativeMethodDropDrown selected=selectedInitiativeMethodDropDrown localize=true}}
</select>
</div>
<div class="form-group">
<label>{{localize "DL.SettingOptinalRuleRollInitEachRound"}}</label>
<input type="checkbox" name="optinalRuleRollInitEachRound" {{checked optinalRuleRollInitEachRound}} data-dtype="Boolean" />
</div>
<div class="form-group">
<label>{{localize "DL.SettingOptinalRuleExceedsByFive"}}</label>
<input type="checkbox" name="optinalRuleExceedsByFive" {{checked optinalRuleExceedsByFive}} data-dtype="Boolean" />
</div>
<footer class="sheet-footer flexrow">
<button type="submit" name="submit">
<i class="far fa-save"></i>
{{localize "SETTINGS.Save"}}
</button>
<button type="button" data-action="reset">
<i class="fas fa-undo"></i>
{{localize "SETTINGS.Reset"}}
</button>
</footer>
</form>

0 comments on commit a82a6cc

Please sign in to comment.