Skip to content

Commit

Permalink
Merge pull request #3 from BlakeTacklind/legendaries
Browse files Browse the repository at this point in the history
Legendary Action/Resistance Numbers
  • Loading branch information
jwinget authored Sep 20, 2020
2 parents 7a32304 + fdab3e0 commit af08cd2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/critterdb-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ activateListeners(html) {
}
};

tempActor.data.resources = {};

//check if creature has any legendary actions
if (c.stats.legendaryActions.length > 0){
tempActor.data.resources.legact = {
value: c.stats.legendaryActionsPerRound,
max: c.stats.legendaryActionsPerRound
};
}

//check for a string related to legendary resistance in the aditional abilities
var legRes = c.stats.additionalAbilities.find(aa => aa.name.startsWith("Legendary Resistance"));
if (legRes != null){
var value = legRes.name.match(/Legendary Resistance \(([0-9]+)\/Day\)/);
//just assume 3 if we cant match the number
var number = 3;
if (value != null){
number = parseInt(value[1]);
}

tempActor.data.resources.legres = {
value: number,
max: number
};
}

console.log(tempActor);
// Create the actor
let thisActor = await Actor.create(tempActor,{'temporary':true, 'displaySheet': false});
Expand Down

0 comments on commit af08cd2

Please sign in to comment.