码迷,mamicode.com
首页 > 其他好文 > 详细

勇者斗恶龙 1.5 (重写)

时间:2016-10-28 22:59:26      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:please   print   case   oca   system   ase   pool   time   pre   

/*
 * <<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 ---------------\n", round);
    //输出dragon状态
    printf(" <Deathwing>                             \n");
    printf(" HP = %-4d , MP = ????                   \n", dragon_HP);
    //输出worrior状态
    printf(" <Worrior>                                \n");
    printf(" HP = %-4d , MP = %-4d                     \n", warrior_HP, warrior_MP);
    //输出结束分割栏
    printf("--------------------------------\n");
 }
 
 void show_Skill()
 {
    printf("Here is your actions:\n");
    //show hero skill 
    printf("1 Holy Light -140mp\n");
    //show basic skill
    printf("2 Normal Attack -20mp\n");
    printf("3 Force of Nature -0mp\n");
    //show final skill
    printf("4 Sword of Judgement \n");
    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...\n");
        /*显示决策信息*/
        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!\n");
            printf("You has restored %d HP.\n", 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 !\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 be 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;
        }
        /*显示决策结果*/
    }
    /*显示游戏结果*/
    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.\n");
    printf("\nYour final score: %d\n", score);
  system("pause");
return 0; }

 

勇者斗恶龙 1.5 (重写)

标签:please   print   case   oca   system   ase   pool   time   pre   

原文地址:http://www.cnblogs.com/xkxf/p/6009411.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!