Skip to content

Commit

Permalink
Add setting to show attack roll result (AC check) card to players
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Basov committed Feb 29, 2024
1 parent c7b32b9 commit 0d2efa4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,10 @@
"SETTINGS.5eAutoCollapseCardN": "Collapse Item Cards in Chat",
"SETTINGS.5eAutoSpellTemplateL": "When a spell is cast, defaults to begin the process to create the corresponding Measured Template if any (requires TRUSTED or higher player role)",
"SETTINGS.5eAutoSpellTemplateN": "Always place Spell Template",
"SETTINGS.5eAttackRollCheckVisibility": {
"Name": "Show attack roll result to players.",
"Hint": "Control if AC check cards are visible to the players."
},
"SETTINGS.5eChallengeVisibility": {
"Name": "Challenge Visibility",
"Hint": "Control what roll DCs are visible to the players and whether successess/failures are highlighted.",
Expand Down
2 changes: 1 addition & 1 deletion module/documents/chat-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default class ChatMessage5e extends ChatMessage {
_enrichAttackTargets(html) {
const attackRoll = this.rolls[0];
const targets = this.getFlag("dnd5e", "targets");
if ( !game.user.isGM || !(attackRoll instanceof dnd5e.dice.D20Roll) || !targets?.length ) return;
if ( !game.settings.get("dnd5e", "attackRollCheckVisibility") || !(attackRoll instanceof dnd5e.dice.D20Roll) || !targets?.length ) return;
const evaluation = document.createElement("ul");
evaluation.classList.add("dnd5e2", "evaluation");
evaluation.innerHTML = targets.reduce((str, { name, img, ac, uuid }) => {
Expand Down
10 changes: 10 additions & 0 deletions module/settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export function registerSystemSettings() {
}
});

// Attack AC check visibility
game.settings.register("dnd5e", "attackRollCheckVisibility", {
name: "SETTINGS.5eAttackRollCheckVisibility.Name",
hint: "SETTINGS.5eAttackRollCheckVisibility.Hint",
scope: "world",
config: true,
default: false,
type: bool
});

// Encumbrance tracking
game.settings.register("dnd5e", "encumbrance", {
name: "SETTINGS.5eEncumbrance.Name",
Expand Down

0 comments on commit 0d2efa4

Please sign in to comment.