Skip to content

Commit

Permalink
Merge pull request #198 from sasquach45932/master
Browse files Browse the repository at this point in the history
Add colour to used die on boons/banes (Dice So Nice!)
  • Loading branch information
ClipplerBlood committed Sep 2, 2024
2 parents 6235cfe + 3ca46f7 commit dbd8f1a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion src/module/chat/base-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function formatDice(diceRoll) {
pushDice(diceData, pooldie.result, faces, '#777')
} else {
let color = 'white'
if (diceRoll._formula.includes('d6kh') && faces === 6) {
if ((diceRoll._formula.includes('d6kh') || diceRoll._formula.includes('d6r1kh')) && faces === 6) {
let operator = diceRoll.terms[diceRoll.terms.length - 2].operator
if (operator === '+') color = '#006400'
if (operator === '-') color = '#a22223'
Expand Down
38 changes: 38 additions & 0 deletions src/module/chat/roll-messages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
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

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 +37,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 +137,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 +194,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 +310,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 dbd8f1a

Please sign in to comment.