Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <time.h>
- #include "prototypes.h"
- int main()
- {
- int i;
- int sizePlayerArray;//used to declare size of player struct array
- printf("*****Welcome to the game*****\n\n");
- printf("Please enter the number of players (no more than 6): ");
- scanf("%d",&sizePlayerArray);
- //Array will be used for player structs
- struct player playerArray[sizePlayerArray];
- /*Edge Cases to ensure correct number of players */
- while((sizePlayerArray>6)||(sizePlayerArray<=1)){
- if(sizePlayerArray>=6){
- printf("Please enter a number 6 or less: ");
- scanf("%d", &sizePlayerArray);
- }
- else if(sizePlayerArray<=1){
- printf("Game needs more than 1 player\n");
- printf("Please enter a valid number of players: ");
- scanf("%d", &sizePlayerArray);
- }
- }
- //For loop to get user to assign player names
- for(i= 0;i<sizePlayerArray;i++){
- printf("Please enter the name of player %d \n",i+1);
- scanf(" %s",&playerArray[i].name);
- }
- printf("\n\n\n**Now select each player type**\n\n");
- //For loop asks user to select player type for each player
- for(i=0; i <sizePlayerArray;i++){
- printf("What type of player is %s?\n",playerArray[i].name);
- printf("Please enter:\n(E) for Elf\n(H) for human\n(W) for Wizard\n(O) for Ogre\n");
- scanf("%s", &playerArray[i].type);
- /*If statements that will check player type and call a function that will alter
- the struct according their relevant skills*/
- //Elf
- if(toupper(playerArray[i].type) == 'E'){
- //call function to alter elf struct
- // dummy printf to test printf("grand\n\n");
- elf(&playerArray[i]);
- }
- else if(toupper(playerArray[i].type) == 'H'){
- //call function to alter human struct
- human(&playerArray[i]);
- }
- else if(toupper(playerArray[i].type) == 'W'){
- //call function to alter wizard struct
- wizard(&playerArray[i]);
- }
- else if(toupper(playerArray[i].type) == 'O'){
- //call function to alter ogre struct
- ogre(&playerArray[i]);
- }
- /*Edge case*/
- else if(playerArray[i].type != 'E' || 'H' || 'W' || 'O' ){
- printf("Not a valid Player Type. Enter again: ");
- scanf("%s", &playerArray[i].type);
- }
- }
- //Print out each players attributes
- printf("\n\nEach players attributes:\n");
- for(i=0;i<sizePlayerArray;i++){
- printf("Name: %s\n", playerArray[i].name);
- printf("Player type: %c\n", playerArray[i].type);
- printf("Life points: %d\n", playerArray[i].life);
- printf("Smart points: %d\n", playerArray[i].smart);
- printf("Strength points: %d\n", playerArray[i].strength);
- printf("Magic points: %d\n",playerArray[i].magic);
- printf("Dexterity points: %d\n",playerArray[i].dext);
- printf("Luck Points: %d\n", playerArray[i].luck);
- printf("Player row: %d\n", playerArray[i].row);
- printf("Player column: %d\n\n",playerArray[i].col);
- }
- //pointer to slot (0,0)
- struct slot *upLeft;
- //pointer to slot (0,boardSize -1)
- struct slot *upRight;
- //pointer to slot (boardSize - 1, 0)
- struct slot *downLeft;
- //pointer to slot (boardSize - 1, boardSize -1)
- struct slot *downRight;
- int boardSize = 6;
- //******Creates the board**********
- struct slot **board = malloc(boardSize * sizeof(struct slot *));
- createBoard(boardSize,&upLeft, &upRight, &downLeft, &downRight, board);
- //*****Rounds begin******
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement