Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.56 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <time.h>
  8. #include "prototypes.h"
  9.  
  10.  
  11. int main()
  12. {
  13.  
  14.  
  15.     int i;
  16.     int sizePlayerArray;//used to declare size of player struct array
  17.  
  18.     printf("*****Welcome to the game*****\n\n");
  19.     printf("Please enter the number of players (no more than 6): ");
  20.     scanf("%d",&sizePlayerArray);
  21.  
  22.  
  23.  
  24.     //Array will be used for player structs
  25.     struct player playerArray[sizePlayerArray];
  26.  
  27.  
  28.  
  29.  
  30. /*Edge Cases to ensure correct number of players */
  31.    while((sizePlayerArray>6)||(sizePlayerArray<=1)){
  32.  
  33.      if(sizePlayerArray>=6){
  34.         printf("Please enter a number 6 or less: ");
  35.         scanf("%d", &sizePlayerArray);
  36.         }
  37.  
  38.     else if(sizePlayerArray<=1){
  39.         printf("Game needs more than 1 player\n");
  40.         printf("Please enter a valid number of players: ");
  41.         scanf("%d", &sizePlayerArray);
  42.  
  43.         }
  44.    }
  45.  
  46.     //For loop to get user to assign player names
  47.     for(i= 0;i<sizePlayerArray;i++){
  48.  
  49.         printf("Please enter the name of player %d \n",i+1);
  50.         scanf(" %s",&playerArray[i].name);
  51.  
  52.     }
  53.  
  54.     printf("\n\n\n**Now select each player type**\n\n");
  55.     //For loop asks user to select player type for each player
  56.     for(i=0; i <sizePlayerArray;i++){
  57.  
  58.         printf("What type of player is %s?\n",playerArray[i].name);
  59.         printf("Please enter:\n(E) for Elf\n(H) for human\n(W) for Wizard\n(O) for Ogre\n");
  60.         scanf("%s", &playerArray[i].type);
  61.  
  62.         /*If statements that will check player type and call a function that will alter
  63.         the struct according their relevant skills*/
  64.         //Elf
  65.         if(toupper(playerArray[i].type) == 'E'){
  66.             //call function to alter elf struct
  67.         // dummy printf to test printf("grand\n\n");
  68.          elf(&playerArray[i]);
  69.  
  70.         }
  71.         else if(toupper(playerArray[i].type) == 'H'){
  72.             //call function to alter human struct
  73.          human(&playerArray[i]);
  74.  
  75.         }
  76.         else if(toupper(playerArray[i].type) == 'W'){
  77.             //call function to alter wizard struct
  78.  
  79.          wizard(&playerArray[i]);
  80.  
  81.         }
  82.         else if(toupper(playerArray[i].type) == 'O'){
  83.             //call function to alter ogre struct
  84.          ogre(&playerArray[i]);
  85.         }
  86.  
  87.         /*Edge case*/
  88.         else if(playerArray[i].type != 'E' || 'H' || 'W' || 'O' ){
  89.             printf("Not a valid Player Type. Enter again: ");
  90.             scanf("%s", &playerArray[i].type);
  91.         }
  92.  
  93.  
  94.     }
  95.  
  96.         //Print out each players attributes
  97.  
  98.         printf("\n\nEach players attributes:\n");
  99.         for(i=0;i<sizePlayerArray;i++){
  100.  
  101.             printf("Name: %s\n", playerArray[i].name);
  102.             printf("Player type: %c\n", playerArray[i].type);
  103.             printf("Life points: %d\n", playerArray[i].life);
  104.             printf("Smart points: %d\n", playerArray[i].smart);
  105.             printf("Strength points: %d\n", playerArray[i].strength);
  106.             printf("Magic points: %d\n",playerArray[i].magic);
  107.             printf("Dexterity points: %d\n",playerArray[i].dext);
  108.             printf("Luck Points: %d\n", playerArray[i].luck);
  109.             printf("Player row: %d\n", playerArray[i].row);
  110.             printf("Player column: %d\n\n",playerArray[i].col);
  111.            }
  112.  
  113.  
  114.  
  115.  
  116.     //pointer to slot (0,0)
  117.     struct slot *upLeft;
  118.  
  119.     //pointer to slot (0,boardSize -1)
  120.     struct slot *upRight;
  121.  
  122.     //pointer to slot (boardSize - 1, 0)
  123.     struct slot *downLeft;
  124.  
  125.     //pointer to slot (boardSize - 1, boardSize -1)
  126.     struct slot *downRight;
  127.  
  128.  
  129.     int boardSize = 6;
  130.  
  131. //******Creates the board**********
  132.  
  133.     struct slot **board = malloc(boardSize * sizeof(struct slot *));
  134.     createBoard(boardSize,&upLeft, &upRight, &downLeft, &downRight, board);
  135.  
  136.  
  137.  
  138. //*****Rounds begin******
  139.  
  140.  
  141. return 0;
  142.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement