main.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifdef _WIN32
  2. // Windows builds require curses.h for the PDcurses library.
  3. # include <curses.h>
  4. #else
  5. // Unix builds require ncurses.h for the Ncurses library.
  6. # include <ncurses.h>
  7. #endif
  8. #include <stdlib.h>
  9. #include <time.h> /* For making a random seed */
  10. #include <string.h> /* For strcmp, to identify argv[1] */
  11. #include "intro.h" /* To launch intro */
  12. #include "pass.h" /* To launch pass */
  13. #include "wordParse.h" /* To read the file */
  14. int main(int argc, char * argv[]){
  15. if(argc > 1 && !strcmp(argv[1], "--help")){
  16. printf("Usage: %s [--DIFFICULTY]\n\n[--DIFFICULTY] is an optional argument"
  17. " that uses built in words instead\nof words specifed in the config"
  18. " file. Options are:\n\n"
  19. "--veryEasy,\t10 words, 5 letters per word (default)\n\n"
  20. "--easy,\t\t11 words, 7 letters per word\n\n"
  21. "--average,\t14 words, 9 letters per word\n\n"
  22. "--hard,\t\t7 words, 11 letters per word\n\n"
  23. "--veryHard,\t13 words, 12 letters per word\n\n"
  24. "If no difficulty is provided, this program will read input "
  25. "from the FalloutTerminal.cfg file. If this file cannot be found "
  26. "or the configuration is invalid, it will default to Very Easy."
  27. , argv[0]);
  28. exit(0);
  29. }
  30. // Check if a difficulty arg was given
  31. if(argc > 1){
  32. if(!strcmp(argv[1], "--veryEasy")) {
  33. setVeryEasy();
  34. }
  35. if(!strcmp(argv[1], "--easy")) {
  36. setEasy();
  37. }
  38. else if(!strcmp(argv[1], "--average")) {
  39. setAverage();
  40. }
  41. else if(!strcmp(argv[1], "--hard")) {
  42. setHard();
  43. }
  44. else if(!strcmp(argv[1], "--veryHard")) {
  45. setVeryHard();
  46. }
  47. else {
  48. printf("Invalid command. Type \"%s --help\" for usage and a list of commands.\n", argv[0]);
  49. exit(EXIT_FAILURE);
  50. }
  51. }
  52. // Otherwise, read the file for words
  53. else {
  54. readWordsFromFile();
  55. }
  56. // Read what should be launch on completion/victory
  57. readLaunches();
  58. // Read the key config
  59. readKeys();
  60. // Gen a random seed
  61. srand ( (unsigned)time(NULL) );
  62. // Begin curses
  63. initscr();
  64. noecho();
  65. refresh();
  66. attron(A_BOLD);
  67. nodelay(stdscr, 1);
  68. keypad(stdscr, TRUE);
  69. // Check for color support. Start color if it exists.
  70. if(has_colors() == 1){
  71. start_color();
  72. init_pair(1,COLOR_GREEN,COLOR_BLACK);
  73. attron(COLOR_PAIR(1));
  74. }
  75. // Run intro
  76. intro();
  77. // Run pass
  78. pass();
  79. return EXIT_SUCCESS;
  80. }