main.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifdef _WIN32
  2. # include <curses.h>
  3. #else
  4. # include <ncurses.h>
  5. #endif
  6. #include <stdlib.h>
  7. #include <time.h>
  8. #include <string.h>
  9. #include "intro.h"
  10. #include "pass.h"
  11. #include "wordParse.h"
  12. int main(int argc, char * argv[]){
  13. if(argc > 1 && !strcmp(argv[1], "--help")){
  14. printf("Usage: %s [--DIFFICULTY]\n\n[--DIFFICULTY] is an optional argument"
  15. " that uses built in words instead\nof words specifed in the config"
  16. " file. Options are:\n\n"
  17. "--veryEasy,\t10 words, 5 letters per word (default)\n\n"
  18. "--easy,\t\t11 words, 7 letters per word\n\n"
  19. "--average,\t14 words, 9 letters per word\n\n"
  20. "--hard,\t\t7 words, 11 letters per word\n\n"
  21. "--veryHard,\t13 words, 12 letters per word\n\n"
  22. "If no difficulty is provided, this program will read input "
  23. "from the FalloutTerminal.cfg file. If this file cannot be found "
  24. "or the configuration is invalid, it will default to Very Easy."
  25. , argv[0]);
  26. exit(0);
  27. }
  28. FILE *fp = NULL;
  29. fp = fopen("FalloutTerminal.cfg", "r");
  30. if(argc > 1){
  31. if(!strcmp(argv[1], "--veryEasy")) {
  32. setVeryEasy();
  33. }
  34. if(!strcmp(argv[1], "--easy")) {
  35. setEasy();
  36. }
  37. else if(!strcmp(argv[1], "--average")) {
  38. setAverage();
  39. }
  40. else if(!strcmp(argv[1], "--hard")) {
  41. setHard();
  42. }
  43. else if(!strcmp(argv[1], "--veryHard")) {
  44. setVeryHard();
  45. }
  46. else {
  47. printf("Invalid command. Type \"%s --help\" for usage and a list of commands.\n", argv[0]);
  48. exit(EXIT_FAILURE);
  49. }
  50. }
  51. else {
  52. readWordsFromFile(fp);
  53. }
  54. readLaunches(fp);
  55. srand ( (unsigned)time(NULL) );
  56. initscr();
  57. noecho();
  58. refresh();
  59. attron(A_BOLD);
  60. nodelay(stdscr, 1);
  61. if(has_colors() == 1){
  62. /* Colors */
  63. start_color();
  64. init_pair(1,COLOR_GREEN,COLOR_BLACK);
  65. attron(COLOR_PAIR(1));
  66. }
  67. intro();
  68. pass();
  69. fclose(fp);
  70. return 0;
  71. }