Delete Soldier class
Make Infantry as structure
This commit is contained in:
@@ -16,11 +16,15 @@ if (POLICY CMP0141)
|
|||||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
|
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
project ("BattleCap")
|
project ("BattleCap")
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
# Добавьте источник в исполняемый файл этого проекта.
|
# Добавьте источник в исполняемый файл этого проекта.
|
||||||
add_executable (BattleCap "src/BattleCap.cpp" "include/BattleCap.h" "include/Soldier.h" "include/Game.h" "include/Infantry.h" "src/Game.cpp" "include/Player.h" "include/stdafx.h")
|
add_executable (BattleCap
|
||||||
|
"src/BattleCap.cpp"
|
||||||
|
"src/Game.cpp"
|
||||||
|
"src/Infantry.cpp")
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
set_property(TARGET BattleCap PROPERTY CXX_STANDARD 20)
|
set_property(TARGET BattleCap PROPERTY CXX_STANDARD 20)
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Soldier.h"
|
|
||||||
class Infantry : public Soldier {
|
struct Infantry {
|
||||||
public:
|
void attack();
|
||||||
Infantry() : Soldier() {};
|
|
||||||
int step() override
|
|
||||||
{
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
void fire() override
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
class Player {
|
class Player {
|
||||||
private:
|
private:
|
||||||
char name;
|
char name;
|
||||||
std::vector<std::unique_ptr<Soldier>> army;
|
std::vector<std::unique_ptr<Infantry>> army;
|
||||||
double score;
|
double score;
|
||||||
public:
|
public:
|
||||||
Player() {
|
Player() {
|
||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
army.push_back(std::make_unique<Infantry>());
|
army.push_back(std::make_unique<Infantry>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<std::unique_ptr<Soldier>>& get_army() {
|
std::vector<std::unique_ptr<Infantry>>& get_army() {
|
||||||
return army;
|
return army;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
class Soldier {
|
|
||||||
private:
|
|
||||||
double HP;
|
|
||||||
double attack;
|
|
||||||
double defence;
|
|
||||||
char type;
|
|
||||||
protected:
|
|
||||||
Soldier() : HP(100), attack(1), defence(1) {};
|
|
||||||
Soldier(double _HP, double _attack, double _defence) : HP(_HP), attack(_attack), defence(_defence) {};
|
|
||||||
public:
|
|
||||||
virtual int step() = 0;
|
|
||||||
virtual void fire() = 0;
|
|
||||||
};
|
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "curses.h"
|
#include "curses.h"
|
||||||
#endif // WINDOWS
|
#endif // WINDOWS
|
||||||
|
|
||||||
#include "Soldier.h"
|
|
||||||
#include "Infantry.h"
|
#include "Infantry.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
|||||||
6
src/Infantry.cpp
Normal file
6
src/Infantry.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "Infantry.h"
|
||||||
|
|
||||||
|
void Infantry::attack()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user