Random Attack Name Generator
by cinderwell
JavaScript
var phyAttackSuffixes = [
"Slam",
"Punch",
"Kick"
];
var spAttackSuffixes = [
"Beam",
"Bolt",
"Blast"
];
var elePrefixes = [
["Flame","Fire","Lava"],
["Water","Aqua","Hydro"],
["Electro","Spark","Thunder"]
];
function getRandInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getRandBool(){
return Math.random()<.5; // Readable, succint
}
function generateAttack()
{
var phy = getRandBool();
var prefix = "";
var suffix = "";
var index = 0;
var index2 = 0;
if(phy)
{
index = getRandInt(0,phyAttackSuffixes.length-1);
suffix = phyAttackSuffixes[index];
}
else
{
index = getRandInt(0,spAttackSuffixes.length-1);
suffix = spAttackSuffixes[index];
}
index = getRandInt(0,2);
index2 = getRandInt(0,2);
prefix = elePrefixes[index][index2];
return prefix+suffix;
}
alert(generateAttack());
//document.write(result1);
//document.write('<br>');
//document.write(result2);
//document.write('<br>');
//document.write(result3);