Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.64 KB | None | 0 0
  1. const int MSLDF = 40;
  2. static size_t HEALTH;
  3. void duel(char *spells[8]) {
  4.     char *variants[8];
  5.  
  6.     signed char health_action[8] = {2, 0, -1, -1, 0, -1, -1, 0};
  7.     signed char health_variants[8] = {0, 0, 0, 0,
  8.                                       0, 0, 0, 0}; /*char ask_yn[1]="T";*/
  9.  
  10.     printf("Chose a spell:\n");
  11.     for (int i = 0; i < 8; ++i) {
  12.         printf("%s", spells[i]);
  13.     }
  14.  
  15.     // This place of code work on linux gcc, but no in windows minGW
  16.     unsigned char variants_index = 0;
  17.     unsigned char health_action_index = 0;
  18.     unsigned char health_variants_index = 0;
  19.  
  20.     for (int i = 0; i < 8; i++) {
  21.         size_t string_size = strlen(spells[i]) + 1;
  22.         if (string_size >= 2) {
  23.             variants[variants_index] = spells[i];
  24.             variants_index++;
  25.         };
  26.         if (string_size <= 2) {
  27.             health_action[health_action_index] = 42;
  28.             health_action_index++;
  29.         };
  30.     };
  31.     for (int i = 0; i < 8; i++) {
  32.         if (health_action[i] != 42) {
  33.             health_variants[health_variants_index] = health_action[i];
  34.             health_variants_index++;
  35.         };
  36.     }
  37.  
  38.     unsigned char ask_index = 0;
  39.     scanf("%hhu", &ask_index);
  40.     ask_index -= 1;
  41.     printf("You have chosen\n%s", variants[ask_index]);
  42.     HEALTH += health_variants[ask_index];
  43.     printf("Your choise is:\n%s--Correct? (Y/N)--\n", variants[ask_index]);
  44.     char ask_yn;
  45.     scanf("%c", &ask_yn);
  46.     printf("%c\n", ask_yn);
  47.     if (ask_yn == 'Y')
  48.         printf("Lalala\n");
  49.     else {
  50.         printf("Heyheyhey\n");
  51.     }
  52.     printf("%s", variants[2]);
  53.     printf("Test\n");
  54.     return;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement