CIN Input #2 gets skipped, I don't understand why.

Joined
Jan 20, 2023
Messages
3
Reaction score
0
I've been trying to create a stat calculator for my game, and when you enter the ability name, its meant to ask you for the ability level, which, it does- but it does not allow the user to input a response

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
C++:
[I]// steven stat calculator[/I]
#include <string>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include <iostream>
#include <cstdlib>
int main()
{
    std::string name;
    long ability_level;
    bool Final_Power, Fireblazer, Shadow_Sphere, Dark_And_Stormy_Night, Electropunch, Kneeslapper, Glare, Instrumental_Doom, Flower_Power, weneedtocook, Magic_Pulse, Heal_Spell, ability;
    double long attack, defense, health, speed, armor, weapon, durability, total_damage, total_durability, remaining, level, base_power, ability_damage, e_speed, e_defense, e_percentage_loss_sp, e_percentage_loss_def, health_gained_back, speed_increase, defense_increase, attack_increase, current_health, health_regened, dmg_dealt_to_player; [I]// e = enemy[/I]
    std::cout << "Welcome To The STEVEN Stats Calculator" << '\n';
    sleep(1);
std::cout << "Here You Can Test Calculations Including Stats, Armory, Weaponary, and Special Abilties." << '\n';
sleep(1);
std::cout << "First off, What is your Name?" << '\n';
std::cin >> name;
sleep(1);
std::cout << "Ah, I see, your name is " << name << ", That's a good name!" << '\n';
sleep(1);
std::cout << "Anyway, What is the Armor Stat of the character?" << '\n';
std::cin >> armor;
std::cout << "Anyway, What is the Weapon Stat of the character?" << '\n';
std::cin >> weapon;
std::cout << "Anyway, What is the Level Stat of the character?" << '\n';
while (true){
    std::cin >> level;
    if (level > 100) {
        std::cout << "Please enter a level equal to or below 100." << '\n';
    }
    else {
        break;
    }
}


defense = 80 + armor; // base stat + armor stat
attack = 80 + weapon; // base stat + weapon stat
health = (defense + level) / 2;
speed = (defense * health) / (armor + level) * 2;
std::cout << "Your Attack is " << attack << '\n';
sleep(3);
std::cout << "Your Defense is " << defense << '\n';
sleep(3);
std::cout << "Your Health is " << health << '\n';
sleep(3);
std::cout << "Your Speed is " << speed << '\n';
sleep(3);
std::cout << "Now that you've gotten your basic stats done, let's move on to durability." << '\n';
sleep(3);
std::cout << "What is the total durability of the item? (Armor/Weapon)" << '\n';
std::cin >> total_durability;
std::cout << "How much damage is dealt to the weapon?" << '\n';
std::cin >> total_damage;
remaining = total_durability - total_damage;
std::cout << "Your Remaining Durability is " << remaining << '\n';
std::cout << "Now that you've gotten your durability done, let's move on to Abilities." << '\n';
std::cout << "Feel free to start calculating abilities, heres an example of all their names: Final_Power, Fireblazer, Shadow_Sphere, Dark_And_Stormy_Night, Electropunch, Kneeslapper, Glare, Instrumental_Doom, Flower_Power, weneedtocook, Magic_Pulse, Heal_Spell" << '\n';
std::cin >> ability;
if (ability = "Fireblazer")
{
std::cout << "what is the ability level?" << '\n';
std::cin >> ability;
    if (level > 10) {
        std::cout << "Please enter a level equal to or below 10." << '\n';
    }
    else {
        base_power = 75;
total_damage = ((base_power * ability_level) / 2) + (attack + speed) / 2;
std::cout << "Total Damage Dealt = " << total_damage << std::endl;
    }   
}
return 0;
}
 
Joined
Jan 20, 2023
Messages
3
Reaction score
0
I just noticed, that bottom ¨ability¨ should actually be ability_level. but same issue still applies
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top