- Oct 8, 2019
- 2,251
- 1,456
- 113
I'm required to learn at home and this is what I spent my afternoon with.
I'm open to suggestions.
The language is c++.
compiled exe for win10: can't find a good site to upload, I will edit it later.
Sourceforge requires phonenumber and doesn't accept mine, but I filled it in correctly.
I'm open to suggestions.
The language is c++.
compiled exe for win10: can't find a good site to upload, I will edit it later.
Sourceforge requires phonenumber and doesn't accept mine, but I filled it in correctly.
Code:
/*
Name of the program: HFQ-Calculator
Purpose of the program: This program's purpose is to calculate the expected time to get
a specific rune in Diablo 2 1.10+ via the Hellforge.
It is assumed, that you keep runes below Pul.
It also assumes that you can trade for example Ist vs 2 Mal.(due to incompetence from my part)
Who wrote this code and when: d2lover, 7th August 2020
Version number: 0.9
Assumed user input: integers, letters
*/
#include <iostream> // required for outputting text on screen and for reading the user's input
#include <limits> // used for the "Press Enter to continue"-message
#include <vector> // required to store the runeworth in Hel-runes in a vector
const std::string version_number = "V 0.9";
const std::string screen_clear_string = std::string ( 50, '\n' );
const std::vector<std::string> runes
{
"Sol",
"Shael",
"Dol",
"Hel",
"Io",
"Lum",
"Ko",
"Fal",
"Lem",
"Pul",
"Um",
"Mal",
"Ist",
"Gul",
"Vex",
"Ohm",
"Lo",
"Sur",
"Ber",
"Jah",
"Cham",
"Zod"};
const double runeworth_nm_in_pul =(1.+2)/11;
const double runeworth_hell_in_pul =(1.+2+4+8+16)/11;
// self explanatory
void press_enter_to_continue()
{
std::cout << "Press ENTER to continue... " << std::flush;
std::cin.ignore ( std::numeric_limits <std::streamsize> ::max(), '\n' );
}
// function that acts as a screen clear
void screen_clear()
{
std::cout << screen_clear_string;
}
int get_target_rune()
{
screen_clear();
std::cout << "Enter the integer of the rune you want:\n";
for(unsigned int i=0; i<runes.size();i++)
{
std::cout << runes[i]<<":"<<i<<"\n";
}
int target_rune=0;
std::cin >> target_rune;
return target_rune;
}
int get_number_of_rushees()
{
screen_clear();
std::cout << "Enter your number of rushees per HFQ-run:\n";
int number_of_rushees=1;
std::cin>>number_of_rushees;
return number_of_rushees;
}
int get_time_per_run()
{
screen_clear();
std::cout << "Enter your time per run in minutes:\n";
int time_per_run=1;
std::cin>>time_per_run;
return time_per_run;
}
void do_more_rounds();
void one_calculation()
{
std::vector<int> runeworth_sol_to_zod(9,0);
runeworth_sol_to_zod.push_back(1);//Pul
runeworth_sol_to_zod.push_back(2);//Um
runeworth_sol_to_zod.push_back(4);//Mal
runeworth_sol_to_zod.push_back(8);//Ist
runeworth_sol_to_zod.push_back(16);//Gul
runeworth_sol_to_zod.push_back(32);//Vex
runeworth_sol_to_zod.push_back(64);//Ohm
runeworth_sol_to_zod.push_back(128);//Lo
runeworth_sol_to_zod.push_back(256);//Sur
runeworth_sol_to_zod.push_back(512);//Ber
runeworth_sol_to_zod.push_back(1024);//Jah
runeworth_sol_to_zod.push_back(2048);//Cham
runeworth_sol_to_zod.push_back(4096);//Zod
std::cout << "Welcome to HFQ-Calculator "<<version_number<<"\n";
press_enter_to_continue();
int target=get_target_rune();
int rushees=get_number_of_rushees();
int time=get_time_per_run();
double expected_runs=0;
if (target<3) // runes Sol-Dol
{
expected_runs=11./rushees;
}
else if (target>2 && target<9) // runes Hel-Lem
{
expected_runs=11./(rushees*2);
}
else
{
expected_runs=runeworth_sol_to_zod[target]/((runeworth_nm_in_pul+runeworth_hell_in_pul)*rushees);
}
std::cout << "You need to do on average "<< expected_runs<<" runs and it will take you " << expected_runs*time<<" minutes.\n";
void do_more_rounds();
}
void do_more_rounds()
{
one_calculation();
std::cout << "Do you want to calculate another rune? (y/n)\n";
char yes_no=' ';
std::cin >> yes_no;
if(yes_no=='y')
{
one_calculation();
}
else
{
std::cout << "Bye\n";
}
}
int main()
{
do_more_rounds();
return 0;
}