Browse Source

added level 0 battle system

master
myitinos 6 years ago
parent
commit
8960bbc418
1 changed files with 43 additions and 0 deletions
  1. +43
    -0
      system/battle0.hpp

+ 43
- 0
system/battle0.hpp View File

@ -0,0 +1,43 @@
#ifndef _2EASY4ME_BATTLE_SYSTEM_LEVEL0_
#define _2EASY4ME_BATTLE_SYSTEM_LEVEL0_
#include "../class/monster.hpp"
#include "../class/player.hpp"
#include <cstdio>
int startBattle(Player *player, Monster *monster)
{
printf(" ===== BATTLE INFO ===== \n");
printf("%15s (Lv.%n):\n", player->getName(), player->getLevel());
printf(" HP : %n/%n\n", player->checkHP(), player->getMaxHP());
printf(" Att: %n\n", player->getAtt());
printf(" Def: %n\n", player->getDef());
printf("%15s:\n", monster->getName());
printf(" HP : %n/%n\n", monster->checkHP(), monster->getMaxHP());
printf(" Att: %n\n", monster->getAtt());
printf(" Def: %n\n", monster->getDef());
printf(" ===== BATTLE START ===== \n");
while (player->isAlive() && monster->isAlive())
{
printf("%15s and %15s attacked each other !!!\n", player->getName(), monster->getName());
printf("%15s lose %d HP...\n", player->getName(), player->defend(monster->getAtt()));
printf("%15s lose %d HP...\n", monster->getName(), monster->defend(player->getAtt()));
}
printf(" ===== BATTLE END ===== \n");
if (player->isAlive())
{
player->restoreHP();
printf("YOU WIN !!!\n");
return 1;
}
else
{
printf("YOU LOSE !!!\n");
return 0;
}
}
#endif

Loading…
Cancel
Save