Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y build-essential libgtest-dev
echo "GTEST_INCLUDE_PATH=/usr/include/gtest" >> $GITHUB_ENV
echo "GTEST_LIB_PATH=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
echo "Verifying Google Test installation:"
ls -la /usr/include/gtest/
ls -la /usr/lib/x86_64-linux-gnu/libgtest*

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install googletest
echo "GTEST_INCLUDE_PATH=/opt/homebrew/include" >> $GITHUB_ENV
echo "GTEST_LIB_PATH=/opt/homebrew/lib" >> $GITHUB_ENV

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
Expand All @@ -43,6 +50,8 @@ jobs:
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
C:\vcpkg\vcpkg install gtest
echo "GTEST_INCLUDE_PATH=C:\vcpkg\installed\x64-windows\include" >> $GITHUB_ENV
echo "GTEST_LIB_PATH=C:\vcpkg\installed\x64-windows\lib" >> $GITHUB_ENV

- name: Set up compiler (GCC)
if: matrix.compiler == 'gcc'
Expand Down Expand Up @@ -75,6 +84,10 @@ jobs:
- name: Build and run tests
run: |
cd lab2/game/tests
echo "Environment variables:"
echo "GTEST_INCLUDE_PATH=$GTEST_INCLUDE_PATH"
echo "GTEST_LIB_PATH=$GTEST_LIB_PATH"
echo "CXX=$CXX"
make clean
make CXX=$CXX
./all_tests
Expand Down
57 changes: 57 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"files.associations": {
"__bit_reference": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__verbose_abort": "cpp",
"array": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"complex": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"execution": "cpp",
"memory": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"locale": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"print": "cpp",
"queue": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"variant": "cpp",
"vector": "cpp",
"algorithm": "cpp"
}
}
Binary file added lab1/.DS_Store
Binary file not shown.
Binary file added lab1/1718889054_sample_640×426.bmp
Binary file not shown.
Binary file added lab1/Mandrill_filtered_clockwise.bmp
Binary file not shown.
Binary file added lab1/Mandrill_filtered_counter_clockwise.bmp
Binary file not shown.
Binary file added lab1/Mandrill_rotated_clockwise.bmp
Binary file not shown.
Binary file added lab1/Mandrill_rotated_counter_clockwise.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion lab1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

int main() {
try {
std::string inputPath = "Mandrill.bmp";
std::string inputPath = "1718889054_sample_640×426.bmp";

std::string outputPathRotatedClockwise = "Mandrill_rotated_clockwise.bmp";
std::string outputPathFilteredClockwise = "Mandrill_filtered_clockwise.bmp";
Expand Down
Binary file added lab1/start
Binary file not shown.
37 changes: 37 additions & 0 deletions lab2/game/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CXX := g++
CXXFLAGS := -std=c++17 -O1 -g -Wall -Wextra
INCLUDES := -Iinclude
SRC_DIR := src
BIN_DIR := bin
TARGET := $(BIN_DIR)/game

SRCS := $(SRC_DIR)/main.cpp $(SRC_DIR)/Game.cpp $(SRC_DIR)/Player.cpp $(SRC_DIR)/Enemy.cpp $(SRC_DIR)/Battle.cpp \
$(SRC_DIR)/Item.cpp $(SRC_DIR)/Weapon.cpp $(SRC_DIR)/Armor.cpp $(SRC_DIR)/Potion.cpp \
$(SRC_DIR)/Inventory.cpp $(SRC_DIR)/NPC.cpp $(SRC_DIR)/Quest.cpp $(SRC_DIR)/Dialog.cpp \
$(SRC_DIR)/Skill.cpp $(SRC_DIR)/Magic.cpp $(SRC_DIR)/Shop.cpp $(SRC_DIR)/Logger.cpp $(SRC_DIR)/Menu.cpp \
$(SRC_DIR)/World.cpp $(SRC_DIR)/Utils.cpp
OBJS := $(SRCS:.cpp=.o)

all: $(TARGET)

$(TARGET): $(OBJS) | $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $(OBJS)
@echo "Cleaning up object files..."
@rm -f $(OBJS)
@echo "Build complete! Binary: $(TARGET)"

# Build without cleaning object files (for debugging)
build: $(OBJS) | $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $(TARGET) $(OBJS)
@echo "Build complete! Binary: $(TARGET) (object files preserved)"

$(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

$(BIN_DIR):
mkdir -p $(BIN_DIR)

clean:
rm -f $(SRC_DIR)/*.o $(TARGET)

.PHONY: all build clean
Empty file added lab2/game/README.md
Empty file.
Binary file added lab2/game/bin/game
Binary file not shown.
20 changes: 20 additions & 0 deletions lab2/game/include/Armor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "Item.h"
#include "Player.h"

class Armor : public Item {
public:
Armor(const std::string& name = "", const std::string& description = "", int value = 0, int defense = 0);
int GetDefense() const;
void Upgrade();
void Break();
void Repair();
void Use(Player& p) override;
Armor* Clone() const override;
int GetDurability() const { return durability; }
int GetMaxDurability() const { return maxDurability; }
private:
int defense;
int durability;
int maxDurability;
};
21 changes: 21 additions & 0 deletions lab2/game/include/Battle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "Player.h"
#include "Enemy.h"

class World; // Forward declaration

class Battle {
public:
Battle() : player(nullptr), enemy(nullptr), world(nullptr), active(false) {}
void Start(Player& p, Enemy& e, World& w);
void PlayerTurn();
void EnemyTurn();
bool CheckWin();
void End();
bool IsActive() const { return active; }
private:
Player* player;
Enemy* enemy;
World* world;
bool active;
};
20 changes: 20 additions & 0 deletions lab2/game/include/Dialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include <string>
#include <vector>

class Dialog {
public:
Dialog(const std::string& text = "");
void Show();
void NextLine();
bool HasChoices() const;
void SelectChoice(int choice);
void End();
void AddChoice(const std::string& choice);
void SetText(const std::string& newText);
private:
std::string text;
int currentLine;
bool hasChoices;
std::vector<std::string> choices;
};
26 changes: 26 additions & 0 deletions lab2/game/include/Enemy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
class Player; // forward declare

class Enemy {
public:
Enemy();
Enemy(int health, int attack);
void Attack(Player& player);
void Defend();
void Think(Player& player);
void TakeDamage(int dmg);
void DropLoot();

int GetHP() const;
bool IsDead() const { return hp <= 0; }
bool HasBuff() const;
void SetMagical(bool magical) { isMagical = magical; }
bool IsMagical() const { return isMagical; }
void Reset(); // Reset enemy to initial state
private:
int hp;
int attackPower;
bool defending;
bool isMagical;
bool hasBuff;
};
41 changes: 41 additions & 0 deletions lab2/game/include/Game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once
#include <iostream>
#include <string>
#include "Player.h"
#include "Enemy.h"
#include "Battle.h"
#include "World.h"

class Game {
public:
void Init();
void Run();
void Render();
void Update();
void Exit();
private:
void PrintHelp();
void HandleCommand(const std::string& line);
void ShowShop();
void BuyItem(const std::string& name);
void SellItem(const std::string& name);
void UseSkill(const std::string& name);
void CastSpell(const std::string& name);
bool inBattle = false;
int bonusNoAttackTurns = 0; // дополнительный ход без атаки после run/defend
Player player;
Enemy enemy;
Battle battle;
World world;
// bool inShop = false; // Unused field - commented out
bool questActive = false;
bool questCompleted = false;
bool secondQuestActive = false;
bool secondQuestCompleted = false;
bool gameFinished = false;
// simple shop: name -> price
std::vector<std::pair<std::string,int>> shopGoods;
// int battleEnemyIdx = -1; // Unused field - commented out
int battleEnemyX = -1;
int battleEnemyY = -1;
};
17 changes: 17 additions & 0 deletions lab2/game/include/Inventory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include "Item.h"
#include <vector>
#include <string>

class Inventory {
public:
~Inventory();
void Add(Item& item);
void Remove(Item& item);
Item* Find(std::string name);
void List();
void UseItem(std::string name);
const std::vector<Item*>& GetItems() const { return items; }
private:
std::vector<Item*> items;
};
18 changes: 18 additions & 0 deletions lab2/game/include/Item.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include <string>
class Player;

class Item {
public:
Item(const std::string& name = "", const std::string& description = "", int value = 0);
virtual ~Item() = default;
virtual void Use(Player& p);
virtual std::string GetName() const;
virtual std::string GetDescription() const;
virtual int GetValue() const;
virtual Item* Clone() const;
protected:
std::string name;
std::string description;
int value;
};
20 changes: 20 additions & 0 deletions lab2/game/include/Logger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include <string>
#include <vector>

class Logger {
public:
enum LogLevel { DEBUG, INFO, WARNING, ERROR };

Logger();
void Log(std::string msg);
void Error(std::string msg);
void Warning(std::string msg);
void Info(std::string msg);
void SaveToFile();
void SetLogLevel(LogLevel level);
LogLevel GetLogLevel() const;
private:
LogLevel logLevel;
std::vector<std::string> logMessages;
};
16 changes: 16 additions & 0 deletions lab2/game/include/Magic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "Skill.h"
#include "Item.h"

class Magic : public Skill {
public:
Magic(const std::string& name = "", const std::string& description = "", int manaCost = 0, int power = 0);
void Cast(Player& p, Enemy& e);
int GetManaCost() const;
void Enchant(Item& item);
void Upgrade();
void Cooldown();
private:
int manaCost;
int power;
};
16 changes: 16 additions & 0 deletions lab2/game/include/MapTile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

class MapTile {
public:
MapTile() : type('.'), occupied(false), walkable(true) {}
bool IsWalkable() const { return walkable && !occupied; }
void SetType(char t) { type = t; }
char GetType() const { return type; }
void SetOccupied(bool o) { occupied = o; }
bool IsOccupied() const { return occupied; }
void SetWalkable(bool w) { walkable = w; }
private:
char type;
bool occupied;
bool walkable;
};
12 changes: 12 additions & 0 deletions lab2/game/include/Menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

class Menu {
public:
void ShowMain();
void ShowInventory();
void ShowStats();
void HandleInput();
void ExitMenu();
void ShowBattleMenu();
void ShowShopMenu();
};
Loading
Loading