/** <<d q>> * * Author xkfx<[email protected]> * * Game rules: Use the right decision to kill the dragon within 13 rounds to win. * *-**/#include<stdio.h>#include<stdlib.h>#include<time.h>voidShow_state (intRoundintDRAGON_HP,intWARRIOR_HP,intwarrior_mp) { //Output start splitter barprintf"-round-%2d---------------\ n", round); //Output Dragon Statusprintf"<Deathwing> \ n"); printf ("HP =%-4d, MP =???? \ n", DRAGON_HP); //Output Worrior Statusprintf"<Worrior> \ n"); printf ("HP =%-4d, MP =%-4d \ n", WARRIOR_HP, WARRIOR_MP); //Output End Splitter barprintf"--------------------------------\ n"); } voidShow_skill () {printf ("Here is your actions:\n"); //Show hero Skillprintf"1 Holy light-140mp\n"); //Show basic Skillprintf"2 Normal attack-20mp\n"); printf ("3 Force of Nature-0mp\n"); //Show final Skillprintf"4 Sword of judgement \ n"); printf (">warrior, please choose your action:"); } intMain () {/*Create the data you need for your game*/ intDRAGON_HP =4460; intWARRIOR_HP =1788; intWARRIOR_MP = -; intScore = +; intSkill_tmp =0; intSkill_tmp_2 =0; intround; intchoice; Srand ((int) Time (0)); System ("CLS"); for(round =1; Round <= -; Round + +) {Srand (rand ()); /*Show people status*/show_state (round, dragon_hp, WARRIOR_HP, WARRIOR_MP); /**/ if(Round = = -) printf ("Deathwing:all'll burn...\n"); /*Display decision Information*/Show_skill (); /*Select decision*/scanf ("%d", &choice); System ("CLS"); /*Execute decision & prioritize enemy*/ /*Warrior*/ Switch(choice) { Case 1: if(Warrior_mp < $) Break; Skill_tmp=1788-warrior_hp; WARRIOR_HP=1788; WARRIOR_MP= WARRIOR_MP- $; Score= Score-skill_tmp; printf ("warrior:i am Theone horseman of the apocalypse!\n"); printf ("You have restored%d hp.\n", skill_tmp); Break; Case 2: if(Warrior_mp < -) Break; Skill_tmp= Skill_tmp_2 +297+ rand ()% the; DRAGON_HP= DRAGON_HP-skill_tmp; WARRIOR_MP= WARRIOR_MP- -; Skill_tmp_2=0; Score= score +skill_tmp; printf ("Your cause%d damage!\n", skill_tmp); Break; Case 3: skill_tmp_2= Skill_tmp_2 +337+ rand ()%488; printf ("Your Damage Pool:%d\n", skill_tmp_2); Break; Case 4: Skill_tmp= WARRIOR_HP +428+ rand ()%697; DRAGON_HP= DRAGON_HP-skill_tmp; WARRIOR_HP=1; Score= score +skill_tmp; printf ("Warrior:embrace the end!\n"); printf ("Your cause%d damage!\n", skill_tmp); Break; default: Break; } if(DRAGON_HP <=0) {printf ("Deathwing:it is impossible!? . ... \ n"); printf ("Warrior:embrace the end! so is it!\n"); printf (".... \ n"); printf (".. You win!\n"); Break; } /*Dragon*/skill_tmp=303+ rand ()%311; WARRIOR_HP= WARRIOR_HP-skill_tmp; printf ("You got a few injuries-%d hp\n", skill_tmp); if(WARRIOR_HP <=0) {printf (". ... \ n"); printf ("... \ n"); printf (".. GAME over.\n"); Break; } /*Show decision Results*/ } /*Show Game Results*/ if(DRAGON_HP <=0) {score= score + ( --round) *417; }Else{score= score + round * -; } if(WARRIOR_HP >=0&& dragon_hp >=0) printf ("The game ended in a draw.\n"); printf ("\nyour Final score:%d\n", score);
System ("pause"); return 0; }
Dragon Quest 1.5 (rewrite)