Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/module/combat/combat-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ calculateEncounterDifficulty(combatants) {
}
}

const trackerHeader = html.querySelector(".combat-tracker-header")
if (this.initiativeMethod === 's') {
if (game.combat?.turn === null)
trackerHeader.innerHTML = trackerHeader.innerHTML + `<div class="encounter-controls combat"><strong class="encounter-difficulty" data-rating="challenging">${game.i18n.localize('DL.TurnChooseTurn')}</strong></div>`
else
trackerHeader.innerHTML = trackerHeader.innerHTML + `<div class="encounter-controls combat"><class="encounter-difficulty">&nbsp;</div>`
}

html.querySelectorAll('.combatant')?.forEach(el => {
// For each combatant in the tracker, change the initiative selector
const combId = el.getAttribute('data-combatant-id')
Expand All @@ -246,6 +254,8 @@ calculateEncounterDifficulty(combatants) {

if (this.initiativeMethod === 's' && !game.modules.get('lancer-initiative').active) {
const multipleCombatants = game.combat.getCombatantsByToken(combatant.token)
const title = (game.user.isGM || combatant.actor.isOwner) && game.combat?.turn === null ? i18n('DL.TurnChangeTurn') : ''
const style = (game.user.isGM || combatant.actor.isOwner) && game.combat?.turn === null ? 'font-weight: bold; cursor: pointer;' : 'font-weight: normal; cursor: auto; opacity: 0.5;'

if (combatant.actor?.system.fastAndSlowTurn && multipleCombatants.length == 2) {
// The combatant has a double initiative, so we display "Fast" and "Slow"
Expand All @@ -261,7 +271,7 @@ calculateEncounterDifficulty(combatants) {
: game.i18n.localize('DL.TurnSlow')

// Change initiative by clicking on the name
el.getElementsByClassName('token-initiative')[0].innerHTML = `<a class="combatant-control dlturnorder" title="${i18n('DL.TurnChangeTurn')}">${init}</a>`
el.getElementsByClassName('token-initiative')[0].innerHTML = `<a class="combatant-control dlturnorder" style="${style}" title="${title}">${init}</a>`
}
}

Expand Down Expand Up @@ -359,7 +369,7 @@ calculateEncounterDifficulty(combatants) {
const combatant = combatants.get(combId)
if (!combatant) return

if (game.user.isGM || combatant.actor.isOwner) {
if (game.user.isGM || combatant.actor.isOwner && game.combat?.turn === null) {
await combatant.actor.update({'system.fastturn': !combatant.actor.system.fastturn})
const initChatMessage = await createInitChatMessage(combatant, {})
if (initChatMessage) ChatMessage.create(initChatMessage)
Expand Down
5 changes: 5 additions & 0 deletions src/module/combat/combat.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ async rollInitiativeGroup(ids, { formula = null, updateTurn = true, messageOptio

/** @override */
async nextTurn() {
const combatant = game.combat.combatants.get(game.combat.current.combatantId)
if (combatant) combatant.setFlag('demonlord', 'hasActed', true)
const _updatedTurn = await super.nextTurn()
await this._handleTurnEffects()
await this.allowTurnOrderChangeInTurns(_updatedTurn)
Expand All @@ -297,6 +299,9 @@ async rollInitiativeGroup(ids, { formula = null, updateTurn = true, messageOptio
}
})
}
for (let combatant of game.combat.combatants) {
await combatant.setFlag('demonlord', 'hasActed', false)
}
const _updatedRound = await super.nextRound()
await this._handleTurnEffects()
await this.allowTurnOrderChangeInRounds()
Expand Down
15 changes: 0 additions & 15 deletions src/module/demonlord.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,21 +548,6 @@ Hooks.on('renderCompendiumDirectory', async (app, html, _data) => {
footer.append(button)
})

// Combat hooks
Hooks.on('combatTurnChange', async (combat, prior, _current) => {
if (game.user.isGM && prior.combatantId) {
const combatant = combat.combatants.get(prior.combatantId)
combatant.setFlag('demonlord', 'hasActed', true)
}
})

Hooks.on('combatRound', async (combat) => {
// Reset hasActed flag for all combatants at the start of each round
for (let combatant of combat.combatants) {
await combatant.setFlag('demonlord', 'hasActed', false)
}
})

Hooks.once('diceSoNiceReady', dice3d => {
dice3d.addSystem({id: 'demonlord', name: 'Demonlord'}, true)
dice3d.addDicePreset({
Expand Down
Loading