Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <time.h>
  5. struct Players
  6. {
  7. char name[15];
  8. char type[10];
  9. int luck;
  10. int magic_skills;
  11. int smartness;
  12. int dexterity;
  13. int strength;
  14. int life_points;
  15.  
  16. };
  17.  
  18. void human (struct Players *structname);
  19. int main(void)
  20. {
  21. setbuf (stdout,NULL);
  22. srand (time(NULL));
  23. int no_players;
  24. int i;
  25. int type;
  26. char name;
  27. char p_name[15];
  28. int p_type;
  29.  
  30. printf("Please enter the number of players you wish to have (max 6) \n \n");
  31. scanf("%d",&no_players);
  32.  
  33. printf("To pick your player type, please use these corresponding numbers:"
  34. "Elf=1"
  35. "Human=2"
  36. "Ogre=3"
  37. "Wizard=4 \n \n");
  38.  
  39. struct Players playerstruct[no_players];
  40. for (i=0;i<no_players;i++)
  41. {
  42. printf("\n Please enter player name: \n");
  43. scanf("%s",p_name);
  44.  
  45. printf(" \n Please enter corresponding number of player type: \n ");
  46. scanf("%d",p_type);
  47.  
  48. }
  49.  
  50. if (p_type==1)
  51. {
  52. strcpy(playerstruct[i].type,"Elf");
  53. }
  54. else if(p_type==2)
  55. {
  56. strcpy(playerstruct[i].type,"Human");
  57. }
  58. else if(p_type==3)
  59. {
  60. strcpy(playerstruct[i].type,"Ogre");
  61. }
  62. else if (p_type == 4)
  63. {
  64. strcpy(playerstruct[i].type,"Wizard");
  65. }
  66.  
  67.  
  68. return 0;
  69. }
  70.  
  71. void human (struct Players *structname)
  72. {
  73. int sum=300;
  74.  
  75.  
  76. if (sum <= 300)
  77. {
  78. (*structname).smartness= rand() %100 +1;
  79. (*structname).luck= rand() %100 +1;
  80. (*structname).dexterity= rand() %100 +1;
  81. (*structname).strength= rand() %100 +1;
  82. (*structname).magic_skills= rand() %100 +1;
  83. sum=(*structname).luck+(*structname).dexterity+(*structname).smartness+(*structname).magic_skills+(*structname).strength;
  84. }
  85. if (sum<300)
  86. {
  87. printf("%d",sum);
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement