Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- struct Players
- {
- char name[15];
- char type[10];
- int luck;
- int magic_skills;
- int smartness;
- int dexterity;
- int strength;
- int life_points;
- };
- void human (struct Players *structname);
- int main(void)
- {
- setbuf (stdout,NULL);
- srand (time(NULL));
- int no_players;
- int i;
- int type;
- char name;
- char p_name[15];
- int p_type;
- printf("Please enter the number of players you wish to have (max 6) \n \n");
- scanf("%d",&no_players);
- printf("To pick your player type, please use these corresponding numbers:"
- "Elf=1"
- "Human=2"
- "Ogre=3"
- "Wizard=4 \n \n");
- struct Players playerstruct[no_players];
- for (i=0;i<no_players;i++)
- {
- printf("\n Please enter player name: \n");
- scanf("%s",p_name);
- printf(" \n Please enter corresponding number of player type: \n ");
- scanf("%d",p_type);
- }
- if (p_type==1)
- {
- strcpy(playerstruct[i].type,"Elf");
- }
- else if(p_type==2)
- {
- strcpy(playerstruct[i].type,"Human");
- }
- else if(p_type==3)
- {
- strcpy(playerstruct[i].type,"Ogre");
- }
- else if (p_type == 4)
- {
- strcpy(playerstruct[i].type,"Wizard");
- }
- return 0;
- }
- void human (struct Players *structname)
- {
- int sum=300;
- if (sum <= 300)
- {
- (*structname).smartness= rand() %100 +1;
- (*structname).luck= rand() %100 +1;
- (*structname).dexterity= rand() %100 +1;
- (*structname).strength= rand() %100 +1;
- (*structname).magic_skills= rand() %100 +1;
- sum=(*structname).luck+(*structname).dexterity+(*structname).smartness+(*structname).magic_skills+(*structname).strength;
- }
- if (sum<300)
- {
- printf("%d",sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement