Skip to content

Commit

Permalink
Add colour to DSN! D6s
Browse files Browse the repository at this point in the history
  • Loading branch information
sasquach45932 committed Sep 1, 2024
1 parent 3bc103c commit 9af755e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 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.SettingAttackShowEnemyAttributeHint": "Show the Creatures target number you are rolling against in the chat.",
"DL.SettingAutoDeleteEffects": "Auto delete Active Effects",
"DL.SettingAutoDeleteEffectsHint": "Automatically delete Active Effects from non-player items when they expire.",
"DL.SettingColourBoBDieDSNMessage": "Add Colour to Boon/Bane Die",
"DL.SettingColourBoBDieDSNMessageHint": "Add colour to used die (green for banes, red for boons) in Dice So Nice!.",
"DL.SettingConfirmAncestryPathRemoval": "Confirm ancestry/path removal",
"DL.SettingConfirmAncestryPathRemovalHint": "Show a confirmation dialog when attempting to remove an ancestry or path from a character of level 1 or higher.",
"DL.SettingGMEffectsControls": "GM Effects Controls",
Expand Down
39 changes: 39 additions & 0 deletions src/module/chat/roll-messages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import {buildAttackEffectsMessage, buildAttributeEffectsMessage, buildTalentEffectsMessage} from './effect-messages'
import {buildActorInfo, formatDice, getChatBaseData} from './base-messages'

function changeBobDieColour (attackRoll)
{
if (attackRoll === null || attackRoll === undefined ) return attackRoll
if (game.settings.get('demonlord', 'colourBoBDieDSN')) {
let d6Index = 0
let bgColor = '#bf0202'
if (game.modules.get('dice-so-nice')?.active) {
if (attackRoll._formula.includes('d6kh') || attackRoll._formula.includes('d6r1kh')) {
let operator = attackRoll.terms[attackRoll.terms.length - 2].operator
let dieIndex = 0

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

View workflow job for this annotation

GitHub Actions / lint

'dieIndex' is assigned a value but never used

if (operator === '+') bgColor = '#104f09'

for (let die of attackRoll.dice) {
if (die._faces === 6) d6Index++
}

attackRoll.dice[d6Index].options.appearance = {
background: bgColor,
outline: bgColor,
}
}
}
}
return attackRoll
}

/**
* Generates and sends the chat message for an ATTACK
* @param attacker DemonlordActor
Expand All @@ -11,6 +38,9 @@ import {buildActorInfo, formatDice, getChatBaseData} from './base-messages'
* @param defenseAttribute stromg (lowercase)
*/
export function postAttackToChat(attacker, defender, item, attackRoll, attackAttribute, defenseAttribute, inputBoons) {

attackRoll = changeBobDieColour (attackRoll)

const itemData = item.system
const rollMode = game.settings.get('core', 'rollMode')

Expand Down Expand Up @@ -108,6 +138,9 @@ export function postAttackToChat(attacker, defender, item, attackRoll, attackAtt
* @param challengeRoll Roll
*/
export function postAttributeToChat(actor, attribute, challengeRoll, inputBoons) {

challengeRoll = changeBobDieColour (challengeRoll)

const rollMode = game.settings.get('core', 'rollMode')

const voidRoll = actor.getAttribute(attribute)?.immune
Expand Down Expand Up @@ -162,6 +195,9 @@ export function postAttributeToChat(actor, attribute, challengeRoll, inputBoons)
* @param target DemonlordActor
*/
export function postTalentToChat(actor, talent, attackRoll, target, inputBoons) {

attackRoll = changeBobDieColour (attackRoll)

const talentData = talent.system
const rollMode = game.settings.get('core', 'rollMode')

Expand Down Expand Up @@ -275,6 +311,9 @@ export function postTalentToChat(actor, talent, attackRoll, target, inputBoons)
* @param target
*/
export async function postSpellToChat(actor, spell, attackRoll, target, inputBoons) {

attackRoll = changeBobDieColour (attackRoll)

const spellData = spell.system
const rollMode = game.settings.get('core', 'rollMode')

Expand Down
8 changes: 8 additions & 0 deletions src/module/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ export const registerSettings = function () {
type: Boolean,
config: true,
})
game.settings.register('demonlord', 'colourBoBDieDSN', {
name: game.i18n.localize('DL.SettingColourBoBDieDSNMessage'),
hint: game.i18n.localize('DL.SettingColourBoBDieDSNMessageHint'),
default: false,
scope: 'client',
type: Boolean,
config: true,
})
game.settings.register('demonlord', 'initMessage', {
name: game.i18n.localize('DL.SettingInitMessage'),
hint: game.i18n.localize('DL.SettingInitMessageHint'),
Expand Down

0 comments on commit 9af755e

Please sign in to comment.