diff options
| author | Ray Hogenson <rayhogenson@gmail.com> | 2012-01-24 16:10:52 -0900 |
|---|---|---|
| committer | Ray Hogenson <rayhogenson@gmail.com> | 2012-01-24 16:10:52 -0900 |
| commit | 13f98a368dba0c65ed623136586698c2447428cf (patch) | |
| tree | 981e356d020fe958e406e1d0fe2314b8ad0b9efd /src | |
| parent | 577ac701fc0000ba98f6710cdfd30ad353e8df2e (diff) | |
| download | yetihack-13f98a368dba0c65ed623136586698c2447428cf.tar.zst | |
added a turns needed message, and put stuff into a function
Diffstat (limited to 'src')
| -rw-r--r-- | src/YetiHack.cpp | 84 |
1 files changed, 26 insertions, 58 deletions
diff --git a/src/YetiHack.cpp b/src/YetiHack.cpp index 4709c6f..1265dae 100644 --- a/src/YetiHack.cpp +++ b/src/YetiHack.cpp @@ -14,6 +14,7 @@ void startCurses(); int wait(int); int start(int, bool, bool, double); void story(); +bool smessage(int, int, string); const char* convert(int); void menu(bool); @@ -232,77 +233,45 @@ int start(int rate, bool immortal, bool story, double escapeturns) void story() { - char input; - addstr("One day, you are ambushed by yetis!\n"); - addstr("Press any key to fight them...\n"); - refresh(); - getch(); - erase(); - if (start(10, false, true, 50) == 1) + if (!smessage(10, 50, "One day, you are ambushed by yetis!\n")) { - erase(); - addstr("You died!"); - do - { - input = getch(); - } while (input != '\n'); return; } - erase(); - addstr("You escaped, unfortunately, they attack again.\n"); - addstr("Press any key to fight them...\n"); - refresh(); - getch(); - erase(); - if (start(5, false, true, 100) == 1) + if (!smessage(5, 100, "You escaped, unfortunately, they attack again.\n")) { - erase(); - addstr("You died!"); - do - { - input = getch(); - } while (input != '\n'); return; } - erase(); - addstr("Now, you are attacked a third time!\n"); - addstr("Press any key to fight them...\n"); - refresh(); - getch(); - erase(); - if (start(2, false, true, 500) == 1) + if (!smessage(2, 500, "Now, you are attacked a third time!\n")) { - erase(); - addstr("You died!"); - do - { - input = getch(); - } while (input != '\n'); return; } - erase(); - addstr("There sure are a lot of yetis, because you are attacked again!\n"); - addstr("Press any key to fight them...\n"); - refresh(); - getch(); - erase(); - if (start(1, false, true, 800) == 1) + if (!smessage(1, 800, "There sure are a lot of yetis, because you are attacked again!\n")) { - erase(); - addstr("You died!"); - do - { - input = getch(); - } while (input != '\n'); return; } - erase(); - addstr("One last fight.\n"); + if (!smessage(1, 1000, "One last fight.\n")) + { + return; + } + addstr("You won!!!!"); + getch(); +} + +bool smessage(int rate, int num, string message) +{ + char input; + int x, y; + getmaxyx(stdscr,y,x); + const char* printm = message.c_str(); + addstr(printm); + addstr("You have to survive "); + addstr(convert((num / 7810.) * x * y)); + addstr(" turns\n"); addstr("Press any key to fight them...\n"); refresh(); getch(); erase(); - if (start(1, false, true, 1000) == 1) + if (start(rate, false, true, num) == 1) { erase(); addstr("You died!"); @@ -310,11 +279,10 @@ void story() { input = getch(); } while (input != '\n'); - return; + return false; } erase(); - addstr("You won!!!!"); - getch(); + return true; } const char* convert(int a) |
