You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

преди 6 години
  1. #ifndef _2EASY4ME_BATTLE_SYSTEM_LEVEL0_
  2. #define _2EASY4ME_BATTLE_SYSTEM_LEVEL0_
  3. #include "../class/monster.hpp"
  4. #include "../class/player.hpp"
  5. #include <cstdio>
  6. int startBattle(Player *player, Monster *monster)
  7. {
  8. printf(" ===== BATTLE INFO ===== \n");
  9. printf("%15s (Lv.%n):\n", player->getName(), player->getLevel());
  10. printf(" HP : %n/%n\n", player->checkHP(), player->getMaxHP());
  11. printf(" Att: %n\n", player->getAtt());
  12. printf(" Def: %n\n", player->getDef());
  13. printf("%15s:\n", monster->getName());
  14. printf(" HP : %n/%n\n", monster->checkHP(), monster->getMaxHP());
  15. printf(" Att: %n\n", monster->getAtt());
  16. printf(" Def: %n\n", monster->getDef());
  17. printf(" ===== BATTLE START ===== \n");
  18. while (player->isAlive() && monster->isAlive())
  19. {
  20. printf("%15s and %15s attacked each other !!!\n", player->getName(), monster->getName());
  21. printf("%15s lose %d HP...\n", player->getName(), player->defend(monster->getAtt()));
  22. printf("%15s lose %d HP...\n", monster->getName(), monster->defend(player->getAtt()));
  23. }
  24. printf(" ===== BATTLE END ===== \n");
  25. if (player->isAlive())
  26. {
  27. player->restoreHP();
  28. printf("YOU WIN !!!\n");
  29. return 1;
  30. }
  31. else
  32. {
  33. printf("YOU LOSE !!!\n");
  34. return 0;
  35. }
  36. }
  37. #endif