Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Recover Health #44

Closed
MulliganStu opened this issue Oct 14, 2024 · 2 comments
Closed

Suggestion: Recover Health #44

MulliganStu opened this issue Oct 14, 2024 · 2 comments

Comments

@MulliganStu
Copy link
Contributor

Similar to how you can click on BDY, DEX, and so on and they roll for you, requesting the ability to click on recover and it rolls 1d8+BDY and then updates the hitPoint.value accordingly.

@MulliganStu
Copy link
Contributor Author

MulliganStu commented Oct 14, 2024

Wrote and tested the following function for actor.js:

async rollRecovery(){
	  //get BDY
	  const body = this.system.abilities.body.value;
	  //roll 1d8+BDY
	  const roll = new Roll(`1d8 + ${body}`);
	  await roll.evaluate();
	  //if outcome was positive
	  if(roll.total > 0){
		  //do not exceed max health
		  const newValue = Math.min(this.system.hitPoints.value + roll.total, this.system.hitPoints.max);
		  //set value
		  await this.update({ ["system.hitPoints.value"]: newValue});
	  }
	  //chat message
	  roll.toMessage({
		  user: game.user.id,
		  sound: diceSound(),
		  speaker: ChatMessage.getSpeaker({actor: this}),
		  flavor: `Recovered ${roll.total} hit points`
	  });
  }

Not sure how to make the text in the character sheet highlightable. Otherwise I'd do that

@MulliganStu
Copy link
Contributor Author

45 fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant