The Cave of Dragonflies forums

Go Back   The Cave of Dragonflies forums > Websites > Webmaster Help and Discussion

Notices

Reply
 
Thread Tools
  #1  
Old 12-04-2011, 12:26 AM
bulbasaur's Avatar
bulbasaur bulbasaur is offline
Not quite e^(-(x-μ)˛/(2σ˛)) / (σ√(2π))
 
Join Date: December 20, 2008
Location: √sin(3π/2)
Age: 22
Posts: 922
Pronoun: Male
bulbasaur is an unknown quantity at this point
Default Javascript Reffing Calculator

So, I'm making a calculator for ASB. My intents should be pretty clear by reading the code, but I'm a messy coder. Chrome's inspector says there's no errors, but it's not working.

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bulbasaur's Reffing Calculator</title>
</head>

<body>
<center><h2>Bulbasaur's Reffing Calculator</h2></center>

<form name="calculator">
<p>Evolution modifier:  <br>
<input type="radio" name="evo"> Stage 1 of 3<br>
<input type="radio" name="evo">Stage 2 of 3 or 1 of 2<br>
<input type="radio" name="evo">Stage 3 of 3 or 2 of 2 or 1 of 1<br>
Experience: <input type="text" name="exp" size="2"><br>
Same type? <input type="checkbox" name="stab"><br>
Your Sp/Atk changes: <input type="text" name="atk" size="2"><br>
Opponent's Sp/Def changes: <input type="text" name="def" size="2"><br>
Effectiveness:<br>
<input type="radio" name="effectiveness">Immunity<br>
<input type="radio" name="effectiveness">Double Resistance<br>
<Input type="radio" name="effectiveness">Resistance<br>
<input type="radio" name="effectiveness"checked>Neutral<br>
<input type="radio" name="effectiveness">Super Effective</br>
<input type="radio" name="effectiveness">Double Super Effective</br>
Base Power: <input type="text" name="bp" size="3"><br>
Other, multiplicative modifier: <input type="text" name="xmod" size="4"><br>
Other, additive modifier: <input type="text" name="+mod" size="2"><br>
PP: <input type="text" name="pp" size="2"><br>
<input type="button" value="Calculate" onclick="calculate()" >
</form>
<script language="javascript" type="text/javascript">
function calculate () {
if (document.calculator.evo[0].checked){
window.evo=0;
}
if (document.calculator.evo[1].checked){
window.evo=1;
}
if (document.calculator.evo[2].checked){
window.evo=2;
}
if (document.calculator.effectiveness[0].checked){
window.effectiveness=0;
}
if (document.calculator.effectiveness[1].checked){
window.effectiveness=0.5;
}
if (document.calculator.effectiveness[2].checked){
window.effectiveness=(2/3);
}
if (document.calculator.effectiveness[3].checked){
window.effectiveness=1;
}
if (document.calculator.effectiveness[4].checked){
window.effectiveness=1.5;
}
if (document.calculator.effectiveness[5].checked){
window.effectiveness=2;
}
if(document.calculator.stab.checked){
window.stab=1.25;
}
if(document.calculator.stab.checked==0){
window.stab=1;
}
if(document.calculator.xmod.value==null){
document.calculator.xmod.value=1;
}

expevomod = ((90 + Number(document.calculator.exp.value) + 5 * evo) / 100);

	damage = Math.floor(((stab * (Number(document.calculator.bp.value) + 10 * (Number(document.calculator.atk.value) - Number(document.calculator.def.value)) * effectiveness * expevomod * Number(document.calculator.xmod.value))) / 10) + Number(document.calculator.xmod.value));
	if(damage<1) {
	damage=1;
	}
	if (Number(document.calculator.bp.value)<70) {
	window.critdamage = Math.floor(((stab * ( 2 * Number(document.calculator.bp.value) + 10 * (Number(document.calculator.atk.value) - Number(document.calculator.def.value)) * effectiveness * expevomod * Number(document.calculator.xmod.value))) / 10) + Number(document.calculator.xmod.value));
	}
	if(Number(document.calculator.bp.value)>69) {
	window.critdamage = Math.floor(((stab * (Number(document.calculator.bp.value) + 10 * (Number(document.calculator.atk.value) - Number(document.calculator.def.value) + 70) * effectiveness * expevomod * Number(document.calculator.xmod.value))) / 10) + Number(document.calculator.xmod.value));
	}
	if(window.critdamage<1) {
	window.critdamage = 1;
	}
	energy = Math.floor((Math.pow(Math.log(Number(document.calculator.bp.value)),2))/(stab * Math.sqrt(Number(document.calculator.pp.value)) * expevomod));
	if(energy<1) {
	window.energy = 1;
	}
	if(window.effectiveness==0) {
	damage=0;
	critdamage=0;
	}
	document.getElementById('d').InnerHTML= damage + ', ' + critdamage + ' if it is a critical hit';
    document.getElementById('e').InnerHTML= energy;
	}
</script>

<p id="d">Damage:</p>
<p id="e">Energy:</p>
</body>
</html>
__________________


Quote:
Originally Posted by Superbird View Post
It works on Minesweeper methodology. As soon as you get done with all the logic you can do, you'll be forced to take a 50/50 guess. And you WILL always be wrong.

Reply With Quote
  #2  
Old 12-04-2011, 12:43 AM
Eifie's Avatar
Eifie Eifie is offline
oh man, good times.
 
Join Date: June 25, 2008
Posts: 2,801
Pronoun: She
Eifie is on a distinguished road
Default Re: Javascript Reffing Calculator

"InnerHTML" should start with a lowercase "i". It'll work if you fix that, I think.
__________________



Reply With Quote
  #3  
Old 12-04-2011, 12:55 AM
bulbasaur's Avatar
bulbasaur bulbasaur is offline
Not quite e^(-(x-μ)˛/(2σ˛)) / (σ√(2π))
 
Join Date: December 20, 2008
Location: √sin(3π/2)
Age: 22
Posts: 922
Pronoun: Male
bulbasaur is an unknown quantity at this point
Default Re: Javascript Reffing Calculator

...

:D

Thanks! Wow, you have a sharp eye!
__________________

Quote:
Originally Posted by Littlestream View Post
@Wargle: Well Wargle is Wargle and so it makes sense that Wargle would have a Wargle avatar so that people talking to Wargle can tell that Wargle is Wargle, because if people couldn't tell that Wargle is Wargle because they didn't see a Wargle they wouldn't know that Wargle is Wargle when they are talking to Wargle. So yes, that makes sense.

Reply With Quote
  #4  
Old 12-05-2011, 12:47 AM
Datura's Avatar
Datura Datura is offline
actually a very nice person
 
Join Date: November 7, 2011
Posts: 238
Pronoun: He
Datura is an unknown quantity at this point
Default Re: Javascript Reffing Calculator

This is totally irrelevant, but I thought I would mention it anyway: <center> is a deprecated tag. Consider using a div or p styled with text-align:center instead.
Reply With Quote
  #5  
Old 12-05-2011, 12:56 AM
bulbasaur's Avatar
bulbasaur bulbasaur is offline
Not quite e^(-(x-μ)˛/(2σ˛)) / (σ√(2π))
 
Join Date: December 20, 2008
Location: √sin(3π/2)
Age: 22
Posts: 922
Pronoun: Male
bulbasaur is an unknown quantity at this point
Default Re: Javascript Reffing Calculator

I'm using transitional. I like my <b>'s and my <u>'s and my <s>'s and especially my <marquee>'s ;_; But yeah. That's just me being lazy.
__________________

Quote:
Originally Posted by Grimdour View Post
It doesn't hurt to be idiotic sometimes

Reply With Quote
  #6  
Old 12-05-2011, 11:38 PM
Datura's Avatar
Datura Datura is offline
actually a very nice person
 
Join Date: November 7, 2011
Posts: 238
Pronoun: He
Datura is an unknown quantity at this point
Default Re: Javascript Reffing Calculator

Oh, didn't even think to look at the doctype. Never mind me then!
Reply With Quote
  #7  
Old 12-06-2011, 12:36 AM
bulbasaur's Avatar
bulbasaur bulbasaur is offline
Not quite e^(-(x-μ)˛/(2σ˛)) / (σ√(2π))
 
Join Date: December 20, 2008
Location: √sin(3π/2)
Age: 22
Posts: 922
Pronoun: Male
bulbasaur is an unknown quantity at this point
Default Re: Javascript Reffing Calculator

Kids, don't be like me! Learn from Butterfree's HTML guide, which teaches you clean, proper HTML, not from some book that's as old as you are! Guideline: if your book contains the <b> tag or mentions being compatible with Netscape in any way, shape, or form, don't use it! Remember, always practice valid HTML'ing!

Yeah, the book I read touched on HTML 3.0, which is older than I am. And when I got used to <sup> and <tt> and <small>, I just couldn't give them up, although I didn't have much trouble giving up <frame>. And since I can't really use 3.0 and expect pages to show up properly, I was sort of forced to use a 4.01 doctype :/ It took me ages to get used to actually closing my <p>'s.

inb4 flamewar about presentation and content and the separation thereof
__________________

Quote:
Originally Posted by Karkat Vantas View Post
Everyone on TCoD is an LGBTQ liberal. No exceptions.

Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:54 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Pokémon, Pikachu and all other Pokémon characters © Nintendo, Game Freak and Creatures Inc. The Cave of Dragonflies, content, styles, etc. © Butterfree/Dragonfree/antialiasis.
Forum now hosted by Eevee's HQ.