Skip to content

Commit

Permalink
Merge pull request #206 from sasquach45932/master
Browse files Browse the repository at this point in the history
New Features: Optional initiatives (induvidual, group), Special duration: NextD20Roll, Concentration automation
  • Loading branch information
ClipplerBlood authored Sep 25, 2024
2 parents 803f90b + 1c9d5fa commit 3356075
Show file tree
Hide file tree
Showing 8 changed files with 370 additions and 39 deletions.
12 changes: 10 additions & 2 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,19 @@
"DL.SettingOptionalRuleBellStandardRolls": "SotDL Standard (Attack/Challenge Roll: d20, BoB: d6, Challenge target nr.: 10)",
"DL.SettingOptionalRuleDieRollsMode": "Die Rolls Method",
"DL.SettingOptionalRuleConsistentDamage": "Enable Consistent Damage",
"DL.SettingOptionalRuleInitiative": "Initiative Method",
"DL.SettingOptionalRuleInitiativeStd" : "SotDL Standard (Slow turns & fast turns)",
"DL.SettingOptionalRuleInitiativeInduvidual" : "Induvidual Rolls (d20)",
"DL.SettingOptionalRuleInitiativeGroup" : "Group Rolls (d6) - PCs, NPCs, Creatures",
"DL.SettingOptinalRuleRollInitEachRound": "Roll initiative each round",
"DL.SettingOptionalRuleStaticBoonsAndBanes": "Static Boons and Banes",
"DL.SettingOptionalRules": "Optional Rules",
"DL.SettingOptionalRulesHint": "Enable/Disable Optional Rules.",
"DL.SettingOptionalRulesLabel": "Optional Rule Settings",
"DL.SettingAutoDeleteEffects": "Auto delete Active Effects",
"DL.SettingAutoDeleteEffectsHint": "Automatically delete Active Effects from non-player items when they expire.",
"DL.SettingConcentrationEffect": "Apply Concentration Status Effect",
"DL.SettingConcentrationEffectHint": "Apply effect with duration when casting a spell which requires concentration.",
"DL.SettingDSN3d": "Use Roman numerals on d3",
"DL.SettingDSN3dHint": "When using Demonlord dice-set on d3, Arabic numerals are replaced with Roman numerals. Requires reload.",
"DL.SettingDSNBaneDieColour": "Bane dice",
Expand Down Expand Up @@ -620,9 +627,10 @@
"DL.SpecialDurationNone" : "None",
"DL.SpecialDurationLabel" : "Special Duration",
"DL.SpecialDurationTurnEnd": "Turn End: Expires at the end of the targets's next turn (in combat)",
"DL.SpecialDurationTurnEndSource": "Turn End: Expires at the end of the source actor's next turn (in combat)",
"DL.SpecialDurationTurnEndSource": "Turn End: Expires at the end of the source actor's next turn (in combat)",
"DL.SpecialDurationTurnStart": "Turn Start: Expires at the start of the targets's next turn (in combat)",
"DL.SpecialDurationTurnStartSource": "Turn Start: Expires at the start of the source actor's next turn (in combat)",
"DL.SpecialDurationTurnStartSource": "Turn Start: Expires at the start of the source actor's next turn (in combat)",
"DL.SpecialDurationNextD20Roll": "Next d20 Roll: Expires at the targets's next Challenge/Attack Roll",
"DL.SpellAftereffect": "Aftereffect",
"DL.SpellArea": "Area",
"DL.SpellAttribute": "Attribute",
Expand Down
35 changes: 9 additions & 26 deletions src/module/active-effects/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,44 +137,27 @@ export function prepareActiveEffectCategories(effects, showCreateButtons = false
tokenName = fromUuidSync(e.origin.substr(0, e.origin.search('.Actor.')))?.name
switch (specialDuration) {
case 'TurnEndSource':
e.dlRemaining = `TrunEnd [${tokenName}]`
e.dlRemaining = `TurnEnd [${tokenName}]`
break
case 'TurnStartSource':
e.dlRemaining = `TrunStart [${tokenName}]`
e.dlRemaining = `TurnStart [${tokenName}]`
break
case 'TurnEnd':
default:
e.dlRemaining = specialDuration
break
case 'TurnStart':
e.dlRemaining = specialDuration
break
}
}

if (e.disabled) {
categories.inactive.effects.push(e)
continue
}

if (e.isTemporary) {
categories.temporary.effects.push(e)
continue
}

if (specialDuration !== 'None' && specialDuration !== undefined) {
categories.temporary.effects.push(e)
continue
}

categories.passive.effects.push(e)

if (e.disabled) categories.inactive.effects.push(e)
else if (e.isTemporary) categories.temporary.effects.push(e)
else categories.passive.effects.push(e)

}

return categories
}

Hooks.on('renderActiveEffectConfig', (app, html) => {
if (!game.user.isGM) return
// if (!game.user.isGM) return

var dropDownConfig = function ({ default_value, values }) {
let flags = app.object.flags
Expand Down Expand Up @@ -210,7 +193,7 @@ Hooks.on('renderActiveEffectConfig', (app, html) => {

dropDownConfig({
specialDuration: 'specialDuration',
values: ['None', 'TurnStart', 'TurnEnd', 'TurnStartSource', 'TurnEndSource'],
values: ['None', 'TurnStart', 'TurnEnd', 'TurnStartSource', 'TurnEndSource','NextD20Roll'],
default_value: 'None',
})

Expand Down
55 changes: 54 additions & 1 deletion src/module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ export class DemonlordActor extends Actor {
return attackRoll?.total >= targetNumber
})

for (let effect of this.appliedEffects) {
const specialDuration = foundry.utils.getProperty(effect, 'flags.specialDuration')
if (!(specialDuration?.length > 0)) continue
if (specialDuration === 'NextD20Roll') await effect?.delete()
}

Hooks.call('DL.RollAttack', {
sourceToken: attacker.token || tokenManager.getTokenByActorId(attacker.id),
targets: defendersTokens,
Expand Down Expand Up @@ -492,6 +498,13 @@ export class DemonlordActor extends Actor {
const challengeRoll = new Roll(this.rollFormula(modifiers, boons, boonsReroll), this.system)
await challengeRoll.evaluate()
postAttributeToChat(this, attribute.key, challengeRoll, parseInt(inputBoons) || 0)

for (let effect of this.appliedEffects) {
const specialDuration = foundry.utils.getProperty(effect, 'flags.specialDuration')
if (!(specialDuration?.length > 0)) continue
if (specialDuration === 'NextD20Roll') await effect?.delete()
}

return challengeRoll
}

Expand Down Expand Up @@ -561,6 +574,13 @@ export class DemonlordActor extends Actor {

attackRoll = new Roll(this.rollFormula(modifiers, boons, boonsReroll), this.system)
await attackRoll.evaluate()

for (let effect of this.appliedEffects) {
const specialDuration = foundry.utils.getProperty(effect, 'flags.specialDuration')
if (!(specialDuration?.length > 0)) continue
if (specialDuration === 'NextD20Roll' && attackAttribute !== '' ) await effect?.delete()
}

}

Hooks.call('DL.UseTalent', {
Expand Down Expand Up @@ -646,6 +666,34 @@ export class DemonlordActor extends Actor {
})

postSpellToChat(this, spell, attackRoll, target?.actor, parseInt(inputBoons) || 0)

for (let effect of this.appliedEffects) {
const specialDuration = foundry.utils.getProperty(effect, 'flags.specialDuration')
if (!(specialDuration?.length > 0)) continue
if (specialDuration === 'NextD20Roll' && attackAttribute !== '' ) await effect?.delete()
}

// Add concentration if it's in the spell duration
const concentrate = CONFIG.statusEffects.find(e => e.id === 'concentrate')
if (
spell.system.duration.toLowerCase().includes('concentration') &&
this.effects.find(e => e.statuses?.has('concentrate')) === undefined &&
game.settings.get("demonlord", "concentrationEffect")
) {
let result = spell.system.duration.match(/\d+/)
if (result) {
if (spell.system.duration.toLowerCase().includes('minute')) {
concentrate['duration.rounds'] = result[0] * 6
concentrate['duration.seconds'] = result[0] * 60
} // hour
else {
concentrate['duration.rounds'] = result[0] * 360
concentrate['duration.seconds'] = result[0] * 3600
}
}
concentrate['statuses'] = [concentrate.id]
ActiveEffect.create(concentrate, {parent: this});
}
return attackRoll
}

Expand Down Expand Up @@ -715,8 +763,13 @@ export class DemonlordActor extends Actor {

attackRoll = new Roll(this.rollFormula(modifiers, boons, boonsReroll), this.system)
await attackRoll.evaluate()
}

for (let effect of this.appliedEffects) {
const specialDuration = foundry.utils.getProperty(effect, 'flags.specialDuration')
if (!(specialDuration?.length > 0)) continue
if (specialDuration === 'NextD20Roll' && attackAttribute !== '' ) await effect?.delete()
}
}
postItemToChat(this, item, attackRoll, target?.actor, parseInt(inputBoons) || 0)
return attackRoll
}
Expand Down
26 changes: 24 additions & 2 deletions src/module/combat/combat-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export class DLCombatTracker extends CombatTracker {
}

async getData() {
return await super.getData()
const context = await super.getData()
context.turns.forEach(turn => {
if (turn.initiative >= 0) {turn.initiative = Math.floor(turn.initiative)} else {turn.initiative = Math.ceil(turn.initiative)}
})
return context
}

/** @override */
Expand All @@ -19,6 +23,7 @@ export class DLCombatTracker extends CombatTracker {
const currentCombat = this.getCurrentCombat()
const combatants = currentCombat?.combatants

let initiativeMethod = game.settings.get('demonlord', 'optionalRuleInitiativeMode')
html.find('.combatant').each((i, el) => {
// For each combatant in the tracker, change the initiative selector
const combId = el.getAttribute('data-combatant-id')
Expand All @@ -29,9 +34,26 @@ export class DLCombatTracker extends CombatTracker {
? game.i18n.localize('DL.TurnFast')
: game.i18n.localize('DL.TurnSlow')

el.getElementsByClassName('token-initiative')[0].innerHTML =
if (initiativeMethod === 's') el.getElementsByClassName('token-initiative')[0].innerHTML =
`<a class="combatant-control dlturnorder" title="${i18n('DL.TurnChangeTurn')}">${init}</a>`

if (initiativeMethod === 'h' && game.user.isGM)
{
let groupID = combatant.flags?.group
switch (groupID) {
case 2:
el.style.borderLeft = "thick solid " + '#009E60' //greenish
break;
case 0:
el.style.borderLeft = "thick solid " + '#FFC300 ' //yellow
break;
case 1:
el.style.borderLeft = "thick solid " + '#005a87' //blueish
break;
}
if (combatant.actor.system.maluses.noFastTurn) {el.style.borderLeft = "thick solid " + '#f93e3e'}
}

// Add Tooltip on Status Effects
// Group actor effects by image
const imgEffectMap = new Map()
Expand Down
Loading

0 comments on commit 3356075

Please sign in to comment.