Skip to content

Commit

Permalink
Add tags to combatants from encounters
Browse files Browse the repository at this point in the history
This adds 'character' or 'monster' and 'is-healthy', 'is-bloodied', 'is-critical'
to the tags based on the info from DDB
  • Loading branch information
kakaroto committed Jun 17, 2022
1 parent 827021d commit 322bccd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dndbeyond/content-scripts/encounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ function updateCombatTracker() {
const combat = Array.from($(".combatant-card.in-combat")).map(combatant => {
const $combatant = $(combatant);
const initiative = $combatant.find(".combatant-card__initiative-value").text() || $combatant.find(".combatant-card__initiative-input").val()
const tags = Array.from(combatant.classList)
.filter(c => c.startsWith("combatant-card--"))
.map(c => c.slice("combatant-card--".length))
return {
name: $combatant.find(".combatant-summary__name").text(),
initiative: initiative,
turn: $combatant.hasClass("is-turn"),
tags
};
});
const json = JSON.stringify(combat);
Expand Down

0 comments on commit 322bccd

Please sign in to comment.