#include<stdio.h>
#include<stdlib.h>
#include<time.h> int main()
{
int bloodD = ;
int bloodW = ;
int MP = ;
int action;
int tmp = ;
int tmp2 = ;
int score = ;
int round = ;
printf("Update by xkfx ( E-mail: wyzxk_fx@163.com ) 2016-10-26\n");
srand((int)time());
for(round = ; round <= ; round ++){
srand(rand());
//输出回合数
printf("---Details above------ Round - %d -----\n", round);
//输出恶龙血量
printf("<Deathwing> \n");
printf("HP = %d , MP = ??? \n", bloodD);
//输出勇者血量 与 MP
printf("<Warrior> \n");
printf("HP = %d , MP = %d \n", bloodW, MP);
printf("---------------------------------------\n");
//输出勇者的技能列表
//printf("\n");
printf("YOUR ACTIONS:\n");
printf(" 1 --- ATTACK --- 20 MP\n");
printf(" 2 --- DEFENSE --- 10 MP\n");
printf(" 3 --- GATHER STRENGTH --- 0 MP \n");
printf(" 4 -SWORD OF JUDGEMENT --- ALL HP \n");
printf("> Warrior , please choose your action:");
//选择下一步行动
scanf("%d", &action);
//计算下一回合数据
switch(action){
case :
tmp = + rand()%;
bloodD = bloodD - tmp - tmp2;
MP = MP - ;
printf("\nYour cause %d damage !\n", tmp+tmp2);
score = score + tmp+tmp2;
tmp2 = ;
break;
case :
tmp = + rand()%;
bloodW = bloodW + tmp;
MP = MP - ;
printf("\nYour recovery %d HP !\n", tmp);
break;
case :
tmp2 = tmp2 + rand()%;
printf("\nWarrior:I will find you and I will kill you...\n");
break;
case :
bloodW = ;
tmp = + rand()%;
score = score + tmp;
bloodD = bloodD - tmp;
printf("\nWarrior:SWORD OF JUDGEMENT!!!\n");
printf("Your cause %d damage !\n", tmp);
break;
default:
break;
}
printf("Deathwing:All will burn!\n");
tmp = +rand()%;
printf("You got a few injuries - %d HP\n", tmp);
bloodW = bloodW - tmp;
if((bloodD < ) || (bloodW < ))
break;
}
if(bloodD < && bloodW > ){
printf("...\n");
printf("......\n");
printf("You have kill the Dragon!\n");
printf(".....\n");
printf("What a brave Warrior!");
printf("Your final score: %d\n", + (-round)*+score);
printf("......\n");
}else if(bloodW < && bloodD > ){
printf("...\n");
printf("......\n");
printf("GAME OVER");
printf("Your final score: %d\n", round* +score);
}else
printf("The game ended in a draw");
//system("pause");
return ;
}
更多版本: