crash1115 / 5e-training

A module for Foundry VTT that allows users to keep track of downtime activities, quest progress and... Well, pretty much anything you can track with a loading bar and a %.
MIT License
14 stars 12 forks source link

API Improvements #60

Open crash1115 opened 3 years ago

crash1115 commented 3 years ago

Create Item Suggested by Exodil#5028 on Discord. I gave him the following macro to use for the time being.

// Programatically add a new tracked item to an actor.

// Define our actor and get current tracked items
let actorName = "Test Actor";
let a = game.actors.getName(actorName);
let allTrackedItems = CrashTNT.getActivitiesForActor(actorName);

// Create a new tracked item
// ability, skill, tool, fixedIncrease, macroName are mutually exclusive. Only set one of them. Which you use will depend on what you set as progressionStyle.
let newItem = {
  id: randomID(),
  name: "Activity Name",
  img: "icons/svg/book.svg",
  description: "",
  category: "", // The id of the category. Can be found in the "5e-training", "categories" flags
  progressionStyle: "ABILITY", // "ABILITY", "SKILL", "TOOL", "MACRO", "FIXED"
  ability: "str", // ABILITY ONLY: any of the ability abbreviations
  skill: null, // SKILL ONLY: any of the skill abbreviations
  tool: null, // TOOL ONLY: this would be the ID of a tool on the actor's sheet
  fixedIncrease: null, // FIXED ONLY: this would be the flat value to increase progress by
  macroName: null, // MACRO ONLY: this would be the name of the macro to run
  dc: null, // ABILITY,SKILL,TOOL: if set, this will have DC
  progress: 0,
  completionAt: game.settings.get("5e-training", "totalToComplete"),
  changes: [],
  schemaVersion: 1 
};

// Add new activity to array
allTrackedItems.push(newItem);

// Set flag
a.setFlag("5e-training", "trainingItems", allTrackedItems);
Thomas-Zan commented 3 years ago

I'd also like to suggest a method to programatically execute a training roll. Preferably with feedback if the roll succeeded or failed (in case of a roll with DC)

This would help greatly minimise the code for modules that use yours as a visual representation of some kind of progress.

A second part to this that would be neat would be adding the possiblity of forbidding a pc to roll on an item in the tracking tab thus making it purely informational