Create a Data Structure called Character to contain all a - TopicsExpress



          

Create a Data Structure called Character to contain all a characters statistics. In Character you should have: • An array of int to store the 6 attributes, Str, Dex, Con, Int, Wis, and Cha. • An array of Strings with the contents, Str, Dex, Con, Int, Wis, and Cha • Level, Hitpoints and a new variable, Hitdice You should now offer a selection of classes or professions for the user to select from. Read in Character.Level and Character.Class from the console. The character class or profession should be selected from a predefined list you provide and sanity checked. The class or profession chosen should now change the dice used to calculate the variable Hitpoints. This variable is referred to as the Hitdice. Hitpoints should be calculated as Character.Hitdice + Character.[Con Bonus] per level. Now that they are stored in an array, you should now be able to generate the stats (Str, Dex, Con, Int, Wis, and Cha) in a loop. Roll all these stats as one entire set and then display them together. The dice roller should be abstracted as a function that accepts: • The number of dice to roll • A dice type (determined by character class) • Returns a rolled value or sum of the rolled values (if more than 1 dice) Once rolled and displayed the user should have the option to accept or re-roll their stats. Once accepted, print back the result as indicated in Workshop 1 with the addition of class and hit dice. Remember, you can get a random number from 1 to using (rand()%+1); Bonus XP (note: NOT marks): Add the ability to give the character a name and have a description. This should be sanity checked. NOTES: To use rand successfully, follow these guidelines: You must use the #include if you want to use the rand() function You must use the #include if you want to draw a seed from the clock The first line after declarations should be a call to srand(); You must provide the seed somehow or: If you want to draw your seed from the clock use srand ((unsigned)time( NULL )); this is whatve done so far. #include int main() { char character_class; printf(Choose your character:\n);/*START OF LIST OF CHARACTERS*/ printf(W for Warrior\n); printf(R for Rogue\n); printf(S for Sorcerer\n); printf(B for Barbarian\n); printf(M for Monk\n\n\n); scanf(%c, &character_class);/*MAKE THE CHOICE*/ if (character_class == W )/*START OF THE IF STATEMENT FOR THE CHARACTER CLASSES*/ { char one; printf(You have chosen Warrior [%c]\n, &character_class); printf(%s, func (one)); getchar(); getchar(); } if (character_class == R ) { char one; int two, three; printf(You have chosen Rogue [%c]\n, &character_class); printf(%s, func (one)); getchar(); getchar(); } if (character_class == S ) { char one; printf(You have chosen Sorcerer [%c]\n, &character_class); printf(%s, func (one)); getchar(); getchar(); } if (character_class == B ) { char one; printf(You have chosen Barbarian [%c]\n, &character_class); printf(%s, func (one)); getchar(); getchar(); } if (character_class == M ) { char one; printf(You have chosen Monk [%c]\n, &character_class); printf(%s, func (one)); getchar(); getchar(); } else { printf(Invalid Input\n); } } int func(int argc, char *argv[])/*START THE STATS FUNCTION*/ { int i = 0; for(i = 1; i < argc; i++) { printf(arg %d: %s\n, i, argv[i]); } char *attribute_names[] = { STR, DEX,CON, INT, WIS, CHA }; int attributes[6]= {10,11,8,16,32,14}; int counter = 6; for(i = 0; i < counter ; i++) { printf(%d: %s [%d]\n, i+1, attribute_names[i],attributes[i]); } return 0; } I havent done the bonuses, the hitdice, hitpoints. i need a bit of help getting everything together.. any suggestions?
Posted on: Sun, 27 Apr 2014 18:01:13 +0000

Trending Topics



Recently Viewed Topics




© 2015