JavaScript Javascript - Cannot figure out how to implement a while condition for turn based actions

Just wanna say first off you're awesome and thank you in advance. Now onto my problem. I am making a turn based RPG game using HTML5, Javascript, and some Jquery. I'm good on mostly everything like damage, taking turns, etc. except when I try to emulate a buff/debuff. Think of a video game character in a turn based RPG like say Final Fantasy or something that gets poisoned and takes damage every turn. Or a character that drinks a potion and does 5+ damage for 3 turns. I have done what I believe is extensive research and have tried messing around with different techniques listed below:

1) setInterval (Why it doesn't work for me): It uses milliseconds but I can't seem to implement that into a turn based action.

2) setTimeout (Why it doesn't work for me): Like setInterval it depends on milliseconds passed not counters like times something is clicked.

3) While and For Loops (Why it doesn't work for me): I first make a variable that counts the number of times my attack function is clicked, increments that count by 1 and then I apply the debuff. Say for this example, evil character's health -5 for 3 turns and then after the loop is executed reset. so something like (this is watered down by the way to focus on the topic at hand). The prevalent problem I seem to be having as well is my loops seem to infinitely loop or when I use either return false; or break; nothing happens when the code reaches that loop for some reason. Help please!

//This is a counter for detecting times attack function executed
var attackCounter = 0;
var dragonHealth = 30; 
// Returns a number between 1-10
var bleedChance = Math.floor((Math.random() * 10) + 1); 

// stored into a variable to call later in different function
var attack1 = function() {
$("#kAttack1").click(function() {
// Apply regular damage of -5 to dragons health 
dragonHealth -= 5; 
// Increment turn counter by 1
attackCounter++;
// If I get an 8 or above (%20 chance) I apply the bleed buff of -5 
// health for 3 turns
if (bleedChance >= 8) {
attackCounter = 0;
// THIS IS WHERE I GET STUCK (What do I need to execute so that (1) I 
// apply -5 health to the dragon for 3 turns (2) After I reset the 
// attack counter to 0 how can I make sure that if bleedChance is called
// during the current 3 turns the dragon is taking -5 bleed damage that 
// bleed damage isn't called again thus stacking the effect undesirably
// And lastly (3) when the effect is over allow bleedChance to be able
// to be activated again if I get over. Again my entire game is turn 
//based not in real time. 
}

});
};
Answer:1

I have a Google Sheets trigger function that on form submit places submissions in sheets based on the value selected for one of my questions. I'm trying to test my function with "Test as an Add-On" ...

I have a Google Sheets trigger function that on form submit places submissions in sheets based on the value selected for one of my questions. I'm trying to test my function with "Test as an Add-On" ...

I'm having trouble trying to call a chain of asynchronous functions inside an array. When I call the function individually it works without any problem like in the example below: function ...

I'm having trouble trying to call a chain of asynchronous functions inside an array. When I call the function individually it works without any problem like in the example below: function ...

  1. calling async functions
  2. calling async functions javascript
  3. calling async function without await
  4. calling async function without await javascript
  5. calling async function without await c#
  6. calling async function c#
  7. calling async function python
  8. calling async function js
  9. calling async function nodejs
  10. calling async function in sync
  11. calling async function with await
  12. calling async function in constructor
  13. calling async function in sync c#
  14. calling async function in a loop
  15. calling async function vb.net
  16. calling asynchronous javascript functions in a sequential manner
  17. asynchronous calling method
  18. calling an asynchronous function within a for loop in javascript
  19. asynchronous calls synchronous functions

I am using this method in order to convert an Object to QueryString. QueryString is required for ajax send request. var objectToQueryString = function(a) { var prefix, s, add, name, r20, ...

I am using this method in order to convert an Object to QueryString. QueryString is required for ajax send request. var objectToQueryString = function(a) { var prefix, s, add, name, r20, ...

I have a loading object, with boolean values for each loading. My state looks like this: state: { loading: { itemA: false, itemB: false, itemC: false } } I want to update my state ...

I have a loading object, with boolean values for each loading. My state looks like this: state: { loading: { itemA: false, itemB: false, itemC: false } } I want to update my state ...

  1. updating nested object redux
  2. updating a nested object
  3. update nested object redux
  4. redux updating nested object
  5. update nested state redux