/* * <<D Q>> * * Author xkfx<wyzxk_fx@163.com> * * 游戏规则:利用适当的决策,在13回合内击杀恶龙取得胜利。 * * 2016 - * */ #include<stdio.h> #include<stdlib.h> #include<time.h> void show_State(int round, int dragon_HP, int warrior_HP, int warrior_MP) { //输出起始分割栏 printf("- ROUND-%2d --------------- ", round); //输出dragon状态 printf(" <Deathwing> "); printf(" HP = %-4d , MP = ???? ", dragon_HP); //输出worrior状态 printf(" <Worrior> "); printf(" HP = %-4d , MP = %-4d ", warrior_HP, warrior_MP); //输出结束分割栏 printf("-------------------------------- "); } void show_Skill() { printf("Here is your actions: "); //show hero skill printf("1 Holy Light -140mp "); //show basic skill printf("2 Normal Attack -20mp "); printf("3 Force of Nature -0mp "); //show final skill printf("4 Sword of Judgement "); printf(">Warrior, please choose your action:"); } int main() { /*创建游戏所需的数据*/ int dragon_HP = 4460; int warrior_HP = 1788; int warrior_MP = 240; int score = 1000; int skill_tmp = 0; int skill_tmp_2 = 0; int round; int choice; srand((int)time(0)); system("cls"); for(round = 1; round <= 13; round ++){ srand(rand()); /*显示人物状态*/ show_State(round, dragon_HP, warrior_HP, warrior_MP); /**/ if(round == 13) printf("Deathwing: ALL WILL BURN... "); /*显示决策信息*/ show_Skill(); /*选择决策*/ scanf("%d", &choice); system("cls"); /*执行决策&优先判定敌方*/ /*warrior*/ switch(choice){ case 1: if(warrior_MP < 140) break; skill_tmp = 1788 - warrior_HP; warrior_HP = 1788; warrior_MP = warrior_MP - 140; score = score - skill_tmp; printf("Warrior: I am theone horseman of the Apocalypse! "); printf("You has restored %d HP. ", skill_tmp); break; case 2: if(warrior_MP < 20) break; skill_tmp = skill_tmp_2 + 297 + rand()%152; dragon_HP = dragon_HP - skill_tmp; warrior_MP = warrior_MP - 20; skill_tmp_2 = 0; score = score + skill_tmp; printf("Your cause %d damage ! ", skill_tmp); break; case 3: skill_tmp_2 = skill_tmp_2 + 337 + rand()%488; printf("Your Damage Pool: %d ", 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! "); printf("Your cause %d damage ! ", skill_tmp); break; default: break; } if(dragon_HP <= 0){ printf("Deathwing: It is impossible !?... "); printf("warrior: Embrace the end! So be it! "); printf("..... "); printf("..YOU WIN! "); break; } /*dragon*/ skill_tmp = 303 + rand()%311; warrior_HP = warrior_HP - skill_tmp; printf("You got a few injuries - %d HP ", skill_tmp); if(warrior_HP <= 0){ printf("... "); printf("...... "); printf("..GAME OVER. "); break; } /*显示决策结果*/ } /*显示游戏结果*/ if(dragon_HP <= 0){ score = score + (14 - round) * 417; }else{ score = score + round * 128; } if(warrior_HP >= 0 && dragon_HP >= 0) printf("The game ended in a draw. "); printf(" Your final score: %d ", score);
system("pause"); return 0; }