Got bored at work today.... Character Creator For Dragon Slayer

Started this game but don’t really have interest in going any further. It creates and customizes a character.

//initialize variables
var characterType = "Bobblehead";
var characterName = "Bubbles";
var characterStats = [0,0,0]; //ATTK,SPD,DEF
var characterHitPoints = 100;
var characterChoice = "0";
var loopy = 1;
var gearChoice = "0";
var addStat = "0";

do { //character reset loop
//Character Selection
do { 
characterChoice = prompt("Choose your character type: (1/2/3)\n\n(1)Archer: A ranged combatant with a fast attack speed. Archers can only be hit by ranged attacks.\n\n(2)Warrior: The warriors damage, speed and defense can very greatly depending on the selection of short sword/shield combination or having just a long sword.\n\n(3)Barbarian: The barbarian is generally slow but extremely strong and has impressive defense.");

//input validation for character selection
if (characterChoice === "1"){
    loopy = 0;
} else if (characterChoice === "2") {
    loopy = 0;
} else if (characterChoice === "3") {
    loopy = 0;
} else { 
    loopy = 1;
    alert("Please enter a valid character selection.");}
} while (loopy); //end of character selection loop


//Gear Selection and character stat assignment
do { //start of gear slection loop
if (characterChoice === "1") {  //Archer            
    characterChoice = "Archer";
    //prompt for gear selection
    gearChoice = prompt("Choose your bow: (1/2)\n\n(1)Long Bow: This bow offers a slightly higher damage at a slight reduction in speed.\n\n(2)Crossbow: This bow offers maximum speed at a slight reduction in damage.");
    if (gearChoice === "1") {  //long bow
        characterStats = [4,7,4];//ATTK,SPD,DEF
        gearChoice = "Long Bow";
        loopy = 0;
    } else if (gearChoice === "2") {  //crossbow
        characterStats = [3,10,4];//ATTK,SPD,DEF
        gearChoice = "Crossbow";
        loopy = 0;
    } else {
        loopy = 1;
        alert("Please enter a valid gear selection.");
        }
        
}  else if (characterChoice === "2") {  //Warrior
    characterChoice = "Warrior";
    //prompt for gear selection
    gearChoice = prompt("Choose your gear: (1/2/3)\n\n(1)Longsword: This is a two handed sword that offers maximum damage at a great cost in speed and a small reduction in defense.\n\n(2)Shortsword + Sheild: This combination offers moderate damage and speed while increasing defense to almost the maximum.\n\n(3)Double Shortsword: This combination offers an almost maximum to speed, a cost to damage and a great cost to defense.");
    if (gearChoice === "1") {  //Longsword
        characterStats = [10,3,6];//ATTK,SPD,DEF
        gearChoice = "Longsword";
        loopy = 0;
    } else if (gearChoice === "2") {  //shortsword + sheild
        characterStats = [6,5,9];//ATTK,SPD,DEF
        gearChoice = "Shortsword";
        loopy = 0;
    } else if (gearChoice === "3") {  //double shortsword
        characterStats = [5,9,4];//ATTK,SPD,DEF
        gearChoice = "Double Shortsword";
        loopy = 0;
    } else {
        alert("Please enter a valid gear selection.");
        loopy = 1;}
} else if (characterChoice === "3") {  //Barbarian
    characterChoice = "Barbarian";
    //prompt for gear selection
    gearChoice = prompt("Choose your gear: (1/2/3)\n\n(1)Great Axe: This weapon offers maximum damage at a cost to speed and defense.\n\n(2)Double Small Axe: This combination offers almost maximum speed at a cost great cost to damage and a slight reduction in defense.");
    if (gearChoice === "1") {  //Great Axe
        characterStats = [13,2,8];//ATTK,SPD,DEF
        gearChoice = "Great Axe";
        loopy = 0;
    } else if (gearChoice === "2") {  //double small axe
        characterStats = [5,9,9];//ATTK,SPD,DEF
        gearChoice = "Drouble Small Axe";
        loopy = 0;
    } else {
        alert("Please enter a valid gear selection.");
        loopy = 1;}
} 
} while (loopy);  //end of gear selection loop


//Name Character
characterName = prompt("Please enter a name for your character:");

//Display character information and input 1 stat point increase
do {
addStat = prompt("Congratulations, your hero has been born!\n\n" + characterName + ", is a " + characterChoice + " and has chosen the " + gearChoice + " for their weapon.\n\n" + "The current stats for " + characterName + " are:\nAttack Damage: " + characterStats[0] + "\nAttack Speed: " + characterStats[1] + "\nHero Defense: " + characterStats[2] + "\n\nYou may now enter 1 additional point into any stat of your choice. Please select (1)Attack Damage, (2) Attack Speed or (3)Hero Defense:");

//add chosen stat point to characterStats
if (addStat === "1") {
    characterStats[0] += 1;
    loopy = 0;
} else if (addStat === "2") {
    characterStats[1] += 1;
    loopy = 0;
} else if (addStat === "3") {
    characterStats[2] += 1;
    loopy = 0;
} else {
    alert("Please enter a valid value 1-3.");
    loopy = 1;
}
} while (loopy);
} while (confirm("Your character's finalized stats are:\nAttack Damage: " + characterStats[0] + "\nAttack Speed: " + characterStats[1] + "\nHero Defense: " + characterStats[2] + "\n\nTo accept this character click OK. To restart the character creator click on Cancel.") == 0); //when i use === 0 it does not loop again clicking cancel?
                        // === false, ==flase works and == 0 works

//END OF CHARACTER CREATION LOOP






//speed is effectively going to be the number of rolls you get for a hit
3 Likes

LOVE IT! Good job on this. I love when people create things based on the lessons.

This is very cool, save this script for when you get to learning objects!