1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
// Cast Time Calculator
#include <iostream>
#include <cmath>
using namespace std;
float computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed);
float computeReduction(float castTime, int base) ;
void display (int base, float castTime, float reduction);
// This will prompt the user for DEX, INT, Variable Cast Time Reduction (in %), Base Cast Time and Fixed Cast Time Redution (highest modifier)
int main ()
{
// declaration of variables
int dexterity, intelligence, variable, base, fixed;
float castTime, reduction;
// Prompt
cout << "Please insert DEX: ";
cin >> dexterity;
cout << "\nPlease insert INT: ";
cin >> intelligence;
cout << "\nPlease insert Variable Cast Time Reduction (in %): ";
cin >> variable;
cout << "\nPlease insert Base Cast Time: ";
cin >> base;
cout << "\nPlease insert highest Fixed Cast Time Reduction: ";
cin >> fixed;
// calculate the total cast time
castTime = computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed);
// calculate the reduction in %
reduction = computeReduction(float castTime, int base);
// display table with results
display(int base, float castTime, float reduction);
return 0;
}
// calculates the cast time reduction with the following formula:
// castTime = [(1 - SQRT((DEX * 2 + INT) / 530)) * (1 - sum_castReduction/100%) * baseCast * 0.8] + [(1 - max_fixedReduction/100%) * baseCast * 0.2]
float computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed)
{
float castTime = 0;
castTime = ((1 - sqrt (((dexterity * 2) +intelligence) / 530)) * (1 - (variable / 100)) * base * 0.8) + ((1 - (fixed / 100)) * base * 0.2);
return castTime;
}
// reduction = 1- (castTime / base )
float computeReduction(float castTime, int base)
{
float reduction = 0;
reduction = (1- (castTime / base)) * 100;
return reduction;
}
// displays the Base time, adjusted base time and reduction %
void display (int base, float castTime, float reduction)
{
cout << "\nBASE TIME\tCAST TIME\tREDUCTION\n";
cout << base << " seconds" << '\t' << castTime << " seconds\t" << reduction << " %\n";
}
| |