Skip to content

Commit

Permalink
Реализация на диаманта на смъртта
Browse files Browse the repository at this point in the history
  • Loading branch information
triffon committed May 11, 2022
1 parent b131c72 commit 4543930
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lectures/1/player/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(player VERSION 0.1.0)
include(CTest)
enable_testing()

add_executable(player main.cpp player.cpp hero.cpp superhero.cpp ai.cpp bot.cpp)
add_executable(player main.cpp player.cpp hero.cpp superhero.cpp ai.cpp bot.cpp boss.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
Expand Down
15 changes: 15 additions & 0 deletions lectures/1/player/boss.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "boss.hpp"

Boss::Boss(char const* _name, unsigned _score,
char const* _algorithm, double _threshold,
unsigned _level, unsigned _difficulty, unsigned _damage)
: Hero(_name, _score, _level),
Bot(_name, _score, _algorithm, _threshold, _difficulty),
damage(_damage) {}

void Boss::print(std::ostream& os) const {
Bot::print(os);
std::cout << " и е бос, който е ";
Hero::print(os);
std::cout << " и нанася щети " << getDamage() << std::endl;
}
18 changes: 18 additions & 0 deletions lectures/1/player/boss.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef __BOSS_HPP
#define __BOSS_HPP
#include "hero.hpp"
#include "bot.hpp"

class Boss : public Hero, public Bot {
unsigned damage;
public:
Boss(char const* _name = "<някакъв бос>", unsigned _score = 0,
char const* _algorithm = "<неизвестен алгоритъм>", double _threshold = 0.1,
unsigned _level = 20, unsigned _difficulty = 1, unsigned _damage = 10);

unsigned getDamage() const { return damage; }

void print(std::ostream& os = std::cout) const;
};

#endif
13 changes: 11 additions & 2 deletions lectures/1/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "superhero.hpp"
#include "ai.hpp"
#include "bot.hpp"
#include "boss.hpp"

void anonymousPrint(Player p) {
std::clog << "anonymousPrint: В момента имаме " << Player::getPlayerCount() << " играчи" << std::endl;
Expand Down Expand Up @@ -168,7 +169,14 @@ void testAI() {

void testBot() {
Bot bot("Ботьо", 10, "невронна мрежа", 0.2, 5);
bot.println();
bot.print();
Bot bot1("Deep Thought", 20, "minimax", 3.8, 5),
bot2("HAL 9000", 40, "alpha-beta", 1.9, 15);
}

void testBoss() {
Boss boss("Саурон", 100, "тъмни сили", 1.2, 80, 50, 100);
boss.print();
}

int main() {
Expand All @@ -178,6 +186,7 @@ int main() {
// testSuperHero();
// testPlayers();
// testAI();
testBot();
//testBot();
testBoss();
}

0 comments on commit 4543930

Please sign in to comment.