advanced
sigonasr2, Sig, Sigo 4 years ago committed by GitHub
parent 9e8eecfaa6
commit 21b374a7fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 406
      parkingcalc.html

@ -1,330 +1,76 @@
const MAXSTEPS= 10000 <!DOCTYPE html>
<html lang="en">
function Plural(t) { <head>
return t==1?"":"s" <meta charset="UTF-8" />
} <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
function test(){ <link rel="stylesheet" href="muni.css" />
var start = Math.abs(Math.max(0,Number(document.getElementById("starting").value))) <title>D4DJ Parking Calculator | Powered by Muni</title>
var end = Math.abs(Math.max(0,Number(document.getElementById("ending").value))) <script src="muni.js"></script>
var bonus = Number(document.getElementById("team").value) </head>
var type = (document.getElementById("Bingo").checked?"Bingo": <body>
document.getElementById("Poker").checked?"Poker/Raid": <h1>D4DJ Event Parking Calculator</h1>
"Medley")
var flexible = document.getElementById("flexible").checked <fieldset>
//document.getElementById("console").value=flexible+"...\n\n" <legend>Parking Configuration</legend>
var step=1 <input type="radio" id="Poker" name="type" value="Poker" checked />
var flameCount=0 <label for="Poker">Poker/Raid</label>
var originalTarget=start &nbsp;&nbsp;&nbsp;
document.getElementById("console").value="" <input type="radio" id="Bingo" name="type" value="Bingo" />
<label for="Bingo">Bingo</label>
var interval = (type=="Medley")?15000:10000 &nbsp;&nbsp;&nbsp;
<input type="radio" id="Medley" name="type" value="Medley" />
var maxscore = Math.floor(Math.abs(Math.max(0,Number(document.getElementById("maxscore").value)))/interval)*interval <label for="Medley">Medley</label>
&nbsp;&nbsp;&nbsp;
function EPCalc(voltage,score,bonus) { <hr />
if (voltage>0) { <label for="team">Event Team Bonus:</label>
switch (type) { <select id="team" name="team">
case "Bingo":{ <option value="0">0%</option>
return voltage * Math.floor((1 + bonus)*Math.max(10,Math.floor(score/interval))) <option value="0.2">20%</option>
}break; <option value="0.4">40%</option>
case "Medley":{ <option value="0.6">60%</option>
return voltage * Math.floor((1 + bonus)*(10+Math.floor(score/interval))) <option value="0.8">80%</option>
}break; <option value="1.0">100%</option>
case "Poker/Raid":{ <option value="1.2">120%</option>
return voltage * Math.floor((1 + bonus)*(50 + Math.floor(score/interval))) <option value="1.4">140%</option>
}break; <option value="1.6" selected>160%</option>
} </select>
} else { &nbsp;&nbsp;&nbsp;&nbsp;<label for="flexible" alt="Yes"
return Math.round(bonus*10)+10 ><b>Flexible Team?</b></label
} ><input id="flexible" type="checkbox" />
} <i>If turned on, calculates scoring options using lower % teams also.</i>
<br />
function EvenOdd(val) { <br />
return val%2==0?"even":"odd" <label for="maxscore"><b>Max Free Live Score: </b></label
} ><input id="maxscore" min="0" type="number" value="650000" /> <i> (Use 0 for Rehearsals Only)</i>
<hr />
function TryBiggestGain(tbonus) { <label for="starting"><b>Starting EP: </b></label
var voltage=5 ><input id="starting" min="0" type="number" value="100000" />
for (var i=maxscore;i>=maxscore*0.8;i-=interval) { <span style="font-size: 32px; padding: 0px 10px 0px 10px"></span>
if (start+EPCalc(voltage,i,tbonus)<end-10||start+EPCalc(voltage,i,tbonus)==end) { <label for="ending"><b>Target EP: </b></label
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n" ><input id="ending" min="0" type="number" value="104000" />
if (EvenOdd(start+EPCalc(voltage,i,tbonus))==EvenOdd(end-10)) { <br />
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n" <br />
start+=EPCalc(voltage,i,tbonus) <button
flameCount+=voltage id="calculate"
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n" style="
return true background-color: #ccddff;
} margin-left: 20px;
} width: 240px;
} height: 32px;
return false font-size: 18px;
} "
onclick="test()"
function TrySmallerGain(voltage,tbonus) { >
for (var i=maxscore;i>=maxscore*0.8;i-=interval) { Calculate
if (start+EPCalc(voltage,i,tbonus)<end-10||start+EPCalc(voltage,i,tbonus)==end) { </button>
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n" </fieldset>
if (EvenOdd(start+EPCalc(voltage,i,tbonus))==EvenOdd(end-10)||start+EPCalc(voltage,i,tbonus)==end) { <div style="display: flex; justify-content: stretch; align-items: center">
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n" <textarea rows="20" cols="160" id="console" disabled> </textarea>
start+=EPCalc(voltage,i,tbonus) </div>
flameCount+=voltage
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n" <script>
return true document.getElementById("ips").value = "";
} </script>
} </body>
} </html>
return false
}
function TrySmolGain(voltage,tbonus) {
for (var i=maxscore;i>=0;i-=interval) {
if ((EPCalc(voltage,i,tbonus)>=(10+Math.round(bonus*10))&&(start+EPCalc(voltage,i,tbonus)<=end-(10+Math.round(bonus*10))))||start+EPCalc(voltage,i,tbonus)==end) {
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n"
if (EvenOdd(start+EPCalc(voltage,i,tbonus))==EvenOdd(end-10)||start+EPCalc(voltage,i,tbonus)==end) {
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n"
start+=EPCalc(voltage,i,tbonus)
flameCount+=voltage
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n"
return true
}
}
}
for (var i=maxscore;i>=0;i-=interval) {
if (EvenOdd(start+EPCalc(voltage,i,tbonus))!=EvenOdd(end-10)&&(start+EPCalc(voltage,i,tbonus))==end) {
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n"
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n"
start+=EPCalc(voltage,i,tbonus)
flameCount+=voltage
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n"
return true
}
}
/*for (var i=maxscore;i>=0;i-=interval) {
if ((start+EPCalc(voltage,i,tbonus))==end) {
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n"
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n"
start+=EPCalc(voltage,i,tbonus)
flameCount+=voltage
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n"
return true
}
}*/
for (var i=maxscore;i>=0;i-=interval) {
if (EvenOdd(start+EPCalc(voltage,i,tbonus))!=EvenOdd(end-10)&&(start+EPCalc(voltage,i,tbonus))==end) {
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n"
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n"
start+=EPCalc(voltage,i,tbonus)
flameCount+=voltage
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n"
return true
}
}
return false
}
function TryEqualGain(voltage,tbonus) {
for (var i=maxscore;i>=0;i-=interval) {
//document.getElementById("console").value+=(start+EPCalc(voltage,i,tbonus))+"/"+end+"\n"
if ((start+EPCalc(voltage,i,tbonus))==end) {
//document.getElementById("console").value+="Ending value needs to be "+EvenOdd(end-10)+"\n"
//document.getElementById("console").value+=EvenOdd(start+EPCalc(voltage,i,tbonus))+"/"+EvenOdd(end-10)+"\n"
start+=EPCalc(voltage,i,tbonus)
flameCount+=voltage
document.getElementById("console").value+="Step "+(step++)+") Using "+voltage+" voltage w/"+Math.round(tbonus*100)+"% team, score between "+i+"~"+(i+interval-1)+" pts. EP +"+EPCalc(voltage,i,tbonus)+". Remaining:"+(end-start)+" EP \n"
return true
}
}
if (end==start) {
return false
} else {
return undefined
}
}
function TryMatchingRehearsal(tbonus) {
//document.getElementById("console").value+=(Math.round(tbonus*10))+10
if (end-start==(Math.round(tbonus*10))+10) {
var gain=(Math.round(tbonus*10))+10
start+=gain
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+Math.round(tbonus*100)+"% team. EP +"+gain+". Remaining:"+(end-start)+" EP \n"
return false
}
return true
}
function TryRehearsal(tbonus) {
if (end==start) {
return false
}
var voltage=0
if ((end-start)%2!==0) {
return undefined
}
if (end-start>(10+Math.round(tbonus*10))+10) {
var gain=(10+Math.round(tbonus*10))
start+=gain
//document.getElementById("console").value+="1)"
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+Math.round(tbonus*100)+"% team. EP +"+gain+". Remaining:"+(end-start)+" EP \n"
return true
} else
for (var j=tbonus;j>=0;j-=0.2) {
result = TryMatchingRehearsal(j)
if (!result) {
return false
}
}
if (end-start>=20) {
var gain=end-start-10
start+=gain
//document.getElementById("console").value+="2)"
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+((gain-10)*10)+"% team. EP +"+gain+". Remaining:"+(end-start)+" EP \n"
return true
} else
if ((end-start)%10==0) {
var gain=10
start+=gain
//document.getElementById("console").value+="3)"
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/0% team. EP +"+gain+". Remaining:"+(end-start)+" EP \n"
return false
} else
{
var gain=end-start
if (((gain-10)*10)>=0) {
start+=gain
//document.getElementById("console").value+="4)"
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+((gain-10)*10)+"% team. EP +"+(gain)+". Remaining:"+(end-start)+" EP \n"
return false
} else {
return undefined
}
}
return false
/*var voltage=0
if (end-start>36) {
start+=26
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+(1.6*100)+"% team. EP +"+EPCalc(voltage,1,1.6)+". Remaining:"+(end-start)+" EP \n"
return true
} else
if (end-start>20) {
var bonus = (end-start-20)*10
var gain = end-start-10
start+=end-start-10
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+(bonus)+"% team. EP +"+gain+". Remaining:"+(end-start)+" EP \n"
if ((bonus/10)%2!=0) {
return undefined
} else {
return true
}
} else {
if (end-start<10||(end-start)%2!=0) {
return undefined
}
var bonus = ((end-start-10)/20)*2
start+=end-start
document.getElementById("console").value+="Step "+(step++)+") Use Rehearsal w/"+((bonus)*100)+"% team. EP +"+EPCalc(voltage,1,bonus)+". Remaining:"+(end-start)+" EP \n"
return false
}
return true*/
}
if ((end-start)>1000000) {
document.getElementById("console").value="Get closer to target score before using parking calculator!"
}
else {
var result=true
if (maxscore>0) {
if (flexible) {
for (var j=bonus;j>=0;j-=0.2) {
while (TryBiggestGain(j)) {
//document.getElementById("console").value+=+start+" EP"+"\n"
}
for (var i=4;i>0;i--) {
while (TrySmallerGain(i,j)) {
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
}
}
for (var i=5;i>0;i--) {
while (TrySmolGain(i,j)) {
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
}
}
}
} else {
while (TryBiggestGain(bonus)) {
//document.getElementById("console").value+=+start+" EP"+"\n"
}
for (var i=4;i>0;i--) {
while (TrySmallerGain(i,bonus)) {
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
}
}
for (var i=5;i>0;i--) {
while (TrySmolGain(i,bonus)) {
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
}
}
}
}
for (var j=bonus;j>=0;j-=0.2) {
result = TryMatchingRehearsal(j)
if (!result) {
break;
}
}
if (result) {
for (var j=1.6;j>=0;j-=0.2) {
result = TryMatchingRehearsal(j)
if (!result) {
break;
}
}
}
if (result) {
do {
if (flexible) {
for (var j=bonus;j>=0;j-=0.2) {
var prevstart = 0
result = TryRehearsal(j)
if (start!==prevstart) {
break;
}
}
} else {
result = TryRehearsal(bonus)
}
} while (result);
}
if (maxscore>0) {
if (flexible) {
for (var i=5;i>0;i--) {
for (var j=bonus;j>=0;j-=0.2) {
while (result = TryEqualGain(i,j)) {
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
}
}
}
} else {
for (var i=5;i>0;i--) {
while (result = TryEqualGain(i,bonus)) {
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
}
}
}
}
start=end
if (result===undefined) {
document.getElementById("console").value="Impossible to park using this team!"
} else {
document.getElementById("console").value="Calculating from "+originalTarget+" to "+end+" for event type "+type+"...\n\t(All games are done in Free Live)\n\nFound a park! "+(step-1)+" step"+Plural(step-1)+" and "+flameCount+" voltage required!\n\n"+document.getElementById("console").value
}
//document.getElementById("console").value+="Step "+(step++)+")"+start+" EP"+"\n"
step++
}
}

Loading…
Cancel
Save