/* **********************************************************
* Filename:    AP_CALC.js                                   *
* Author:      Kain McBride                                 *
* Company:     Leprichaun Productions                       *
* Description: AP Calculator for use with                   *
*              the online game: Vampires: The Dark Alleyway *
*              http://quiz.ravenblack.net/blood.pl?         *
********************************************************** */

function doAP_CALC()
 {
  var stANSWER = "You have " + getREGEN_TIME_STRING() + "* until you reach full A.P.";
  stANSWER = stANSWER + "<br><br> * - This time is approximated based on the full amount of time required to regenerate " + getAP_NEEDED() + " AP, whatever time has passed since you reached that AP has not been deducted from the time remaining.";
  stANSWER = stANSWER + "<br>** - Yeah yeah, it's a lame script, but it works...";
  document.getElementById('apCALC_ANSWER').innerHTML = stANSWER;
 }
function getHOURS(datMIN)
 {
  return Math.floor(datMIN/60);
 }
function getMINUTES(datMIN)
 {
  return datMIN - (getHOURS(datMIN)*60);
 }
function getAP_MAX()
 {
  // determines maximum AP based on current stamina level
  // and blood level.
  var curBLOOD = document.apCALC.curBP.value;
  var maxAP = 35;
  if (curBLOOD >=10)
   { maxAP = maxAP + 5; }
  if (curBLOOD >=50)
   { maxAP = maxAP + 5; }
  if (curBLOOD >=100)
   { maxAP = maxAP + 5; }
  if (curBLOOD >=200)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=400)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=800)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=1600)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=3200)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=6400)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=12800)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=25600)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=51200)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=102400)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=204800)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=409600)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=819200)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=1638400)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=3276800)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=6553600)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=13107200)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=26214400)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=52428800)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=104857600)
   { maxAP = maxAP + 1; }
  if (curBLOOD >=209715200)
   { maxAP = maxAP + 1 }
  if (curBLOOD >=419430400)
   { maxAP = maxAP + 1 }
  if (curBLOOD >=838860800)
   { maxAP = maxAP + 1 }
  if (curBLOOD >=1677721600)
   { maxAP = maxAP + 1 }
  return maxAP + parseInt(getSTAMINA_BONUS());
 }
function getSTAMINA_BONUS()
 {
  // returns the Max AP bonus attributed from current level of stamina...
  return document.apCALC.lvlSTA.options[document.apCALC.lvlSTA.selectedIndex].value;
 }
function getAP_NEEDED()
 {
  // determines required AP for full AP based on current
  // AP level and the getAP_MAX() function.
  var apMAX = getAP_MAX();
  var apCUR = document.apCALC.curAP.value;
  return getAP_MAX() - document.apCALC.curAP.value;
 }
function getAP_REGEN_TIME()
 {
  // determines AP regen time based on current level of
  // celerity.
  return document.apCALC.lvlCEL.options[document.apCALC.lvlCEL.selectedIndex].value;
 }
function getREGEN_TIME()
 {
  // determines total AP Regen time with getAP_NEEDED()
  // and getAP_REGEN_TIME(); (returns regen time in
  // minutes)
  return getAP_REGEN_TIME() * getAP_NEEDED();
 }
function getREGEN_TIME_STRING()
 {
  // uses getREGEN_TIME to write out the hours and minutes
  // remaining until AP is fully regenerated
  var stTIME = '';
  stTIME = stTIME + getHOURS(getREGEN_TIME());
  stTIME = stTIME + ' hours, ';
  stTIME = stTIME + getMINUTES(getREGEN_TIME());
  stTIME = stTIME + ' minutes';
  return stTIME;
 }
