diff options
| -rw-r--r-- | src/YetiHack.cpp | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/src/YetiHack.cpp b/src/YetiHack.cpp index 1265dae..59c6fc5 100644 --- a/src/YetiHack.cpp +++ b/src/YetiHack.cpp @@ -6,15 +6,17 @@ #include <cstring> #include <fstream> #include <sstream> +#include <cmath> #include "yeti.h" #define Linux using namespace std; void endCurses(); void startCurses(); int wait(int); -int start(int, bool, bool, double); +int start(bool, bool, double); void story(); -bool smessage(int, int, string); +bool smessage(int, string); +vector<int> turns(int); const char* convert(int); void menu(bool); @@ -41,13 +43,22 @@ int wait(int seconds) snum = time(NULL) - initial; } while (snum < seconds); } -int start(int rate, bool immortal, bool story, double escapeturns) +int start(bool immortal, bool story, double escapeturns) { + escapeturns = turns((int)escapeturns)[1]; + int rate; + if (story) + { + rate = turns((int)escapeturns)[0]; + } + else + { + rate = escapeturns; + escapeturns = 0; + } int x, y; int sizex, sizey; getmaxyx(stdscr,y,x); - escapeturns = escapeturns / 7810; - escapeturns = escapeturns * x * y; sizey = y - 3; sizex = x; char input; @@ -233,23 +244,23 @@ int start(int rate, bool immortal, bool story, double escapeturns) void story() { - if (!smessage(10, 50, "One day, you are ambushed by yetis!\n")) + if (!smessage(1, "One day, you are ambushed by yetis!\n")) { return; } - if (!smessage(5, 100, "You escaped, unfortunately, they attack again.\n")) + if (!smessage(2, "You escaped, unfortunately, they attack again.\n")) { return; } - if (!smessage(2, 500, "Now, you are attacked a third time!\n")) + if (!smessage(3, "Now, you are attacked a third time!\n")) { return; } - if (!smessage(1, 800, "There sure are a lot of yetis, because you are attacked again!\n")) + if (!smessage(4, "There sure are a lot of yetis, because you are attacked again!\n")) { return; } - if (!smessage(1, 1000, "One last fight.\n")) + if (!smessage(5, "One last fight.\n")) { return; } @@ -257,7 +268,7 @@ void story() getch(); } -bool smessage(int rate, int num, string message) +bool smessage(int num, string message) { char input; int x, y; @@ -265,13 +276,13 @@ bool smessage(int rate, int num, string message) const char* printm = message.c_str(); addstr(printm); addstr("You have to survive "); - addstr(convert((num / 7810.) * x * y)); + addstr(convert(turns(num)[1])); addstr(" turns\n"); addstr("Press any key to fight them...\n"); refresh(); getch(); erase(); - if (start(rate, false, true, num) == 1) + if (start(true, true, num) == 1) { erase(); addstr("You died!"); @@ -285,6 +296,21 @@ bool smessage(int rate, int num, string message) return true; } +vector<int> turns(int num) +{ + vector<int> numbers; + int x, y; + getmaxyx(stdscr,y,x); + int turn = num; + turn *= 300; + turn = turn / 7810. * x * y; + num *= 5; + int rate = turn / num; + numbers.push_back(rate); + numbers.push_back(turn); + return numbers; +} + const char* convert(int a) { stringstream convert; @@ -344,7 +370,7 @@ void menu(bool immortal) } while (input != '\n'); noecho(); erase(); - while(start(rate, immortal, false, 0)); + while(start(immortal, false, rate)); break; case '2': erase(); |
