Skip to main content
added update
Source Link
kymully
  • 905
  • 1
  • 7
  • 10

You could do a simple "security level" style switch case.

This is just off the top of my head so beware logic errors beyond my tired state's level of thought, but I hope this can get you started.

Assuming your time is done in block integers -

// after casting spell
int remainingTime = (coolDown - castTime);
switch(spellJustCast)
{
  // assuming the cast method will have some input validation for whether the spell
  // is off cooldown or not, pass the time as a parameter
  case 3 : castSpell1(remainingTime);
           castSpell2(remainingTime);
           break;
  case 1 : castSpell2(remainingTime);
           castSpell3(remainingTime);
           break;
  case 2 : castSpell1(remainingTime);
           castSpell3(remainingTime);
           break;
  default: System.out.println("Debug!");
           break;
}

Some of the method calls are unnecessary due to your spell times, but there's always room for updates this way.

Edit: I just realised, you would need to reset the remaining time after the new spell was cast, probably best to make it a class attribute/field and set it from a call within the castSpell methods.

You could do a simple "security level" style switch case.

This is just off the top of my head so beware logic errors beyond my tired state's level of thought, but I hope this can get you started.

Assuming your time is done in block integers -

// after casting spell
int remainingTime = (coolDown - castTime);
switch(spellJustCast)
{
  // assuming the cast method will have some input validation for whether the spell
  // is off cooldown or not, pass the time as a parameter
  case 3 : castSpell1(remainingTime);
           castSpell2(remainingTime);
           break;
  case 1 : castSpell2(remainingTime);
           castSpell3(remainingTime);
           break;
  case 2 : castSpell1(remainingTime);
           castSpell3(remainingTime);
           break;
  default: System.out.println("Debug!");
           break;
}

Some of the method calls are unnecessary due to your spell times, but there's always room for updates this way.

You could do a simple "security level" style switch case.

This is just off the top of my head so beware logic errors beyond my tired state's level of thought, but I hope this can get you started.

Assuming your time is done in block integers -

// after casting spell
int remainingTime = (coolDown - castTime);
switch(spellJustCast)
{
  // assuming the cast method will have some input validation for whether the spell
  // is off cooldown or not, pass the time as a parameter
  case 3 : castSpell1(remainingTime);
           castSpell2(remainingTime);
           break;
  case 1 : castSpell2(remainingTime);
           castSpell3(remainingTime);
           break;
  case 2 : castSpell1(remainingTime);
           castSpell3(remainingTime);
           break;
  default: System.out.println("Debug!");
           break;
}

Some of the method calls are unnecessary due to your spell times, but there's always room for updates this way.

Edit: I just realised, you would need to reset the remaining time after the new spell was cast, probably best to make it a class attribute/field and set it from a call within the castSpell methods.

Source Link
kymully
  • 905
  • 1
  • 7
  • 10

You could do a simple "security level" style switch case.

This is just off the top of my head so beware logic errors beyond my tired state's level of thought, but I hope this can get you started.

Assuming your time is done in block integers -

// after casting spell
int remainingTime = (coolDown - castTime);
switch(spellJustCast)
{
  // assuming the cast method will have some input validation for whether the spell
  // is off cooldown or not, pass the time as a parameter
  case 3 : castSpell1(remainingTime);
           castSpell2(remainingTime);
           break;
  case 1 : castSpell2(remainingTime);
           castSpell3(remainingTime);
           break;
  case 2 : castSpell1(remainingTime);
           castSpell3(remainingTime);
           break;
  default: System.out.println("Debug!");
           break;
}

Some of the method calls are unnecessary due to your spell times, but there's always room for updates this way.