diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..1a7db4f --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,31 @@ +name: workflow CI + +on: + push: + branches: + - branch1 + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install g++ libgtest-dev -y + + - name: Build project + run: make all + + - name: Build test + run: make test + + - name: Run tests + run: ./test diff --git a/Arch_description/ClassDiagram.png b/Arch_description/ClassDiagram.png new file mode 100644 index 0000000..8fe159b Binary files /dev/null and b/Arch_description/ClassDiagram.png differ diff --git a/Arch_description/ClassDiagram.txt b/Arch_description/ClassDiagram.txt new file mode 100644 index 0000000..c7a0038 --- /dev/null +++ b/Arch_description/ClassDiagram.txt @@ -0,0 +1,169 @@ +@startuml + +package Interface_facilities { +class Interface { +-Hand hand +-Playing_field ++void description(Card card) ++void display_cards() ++void put(Card card) +} +} + + + +package Graphics { +class Pl_field_graph { ++void display_pl_field(Playing_field PF) +} +class Hand_graph { ++void display_hand(Hand hand) +} +} + + + + +package AI_facilities { +class AI { ++Card determine_move() ++void move(Card card) +} +} + + + +package Gameplay { + +class Playing_field { +-Deck deck_player1 +-Deck deck_player2 + +-Deck dump_player1 +-Deck dump_player2 + +-vector melee_player1 +-vector archers_player1 +-vector siege_player1 + +-vector melee_player2 +-vector archers_player2 +-vector siege_player2 + +-uint strength_player1 +-uint strength_player2 + +-vector<"Line spell"> line_spells + ++void enum(vector line) ++void cleaning() +} + + +class Deck { +-vector + ++void pull() ++void insert() +} + +class Hand { +-Deck deck ++void put(Card card) ++void enum() +} + + + +abstract class Card { +-string title ++void pull() +} + + +abstract class Spell { +-string description ++void describe() ++void interact() +} + + +class "Line spell" { +-uint multiple ++void interact() +} + +class "General purpose spell" { ++void interact() +} + + + +class Creature { +-uint strength +-"Special ability" spAb +} + +abstract class "Special ability" { +-string description ++void describe() ++void interact() +} + + + +class "Hero" { ++void interact() +} +class "Spy" { ++void interact() +} +class "Strong bond" { ++void interact() +} +class "Medic" { ++void interact() +} +class "Surge of strength" { ++void interact() +} +class "Using a spell" { +-"Line spell" spell ++void interact() +} +class "Doppelganger" { ++void interact() +} +} + + + +Hand_graph <-- Hand +Pl_field_graph <-- Playing_field + +Interface *-- Playing_field + +Playing_field *-- Deck +Deck o-- Card +Deck <|--* Hand + +Interface *-- Hand +AI o-- Interface + +Card <|-- Creature +Card <|-- Spell + +Creature *-- "Special ability" +Spell <|-- "General purpose spell" +Spell <|-- "Line spell" + + +"Special ability" <|-- Hero +"Special ability" <|-- Spy +"Special ability" <|-- "Strong bond" +"Special ability" <|-- Medic +"Special ability" <|-- "Surge of strength" +"Special ability" <|-- "Using a spell" +"Line spell" --o "Using a spell" +"Special ability" <|-- Doppelganger +@enduml diff --git a/Arch_description/ComponentDiagram.png b/Arch_description/ComponentDiagram.png new file mode 100644 index 0000000..34fc4ac Binary files /dev/null and b/Arch_description/ComponentDiagram.png differ diff --git a/Arch_description/ComponentDiagram.txt b/Arch_description/ComponentDiagram.txt new file mode 100644 index 0000000..1c7cbf0 --- /dev/null +++ b/Arch_description/ComponentDiagram.txt @@ -0,0 +1,26 @@ +@startuml +package Players { +[AI] +[User] +} + +package Display { +[Game field display] +[Hand display] +[Card display] +} +package Gameplay { +[Game field] +[Hand] +[Card] +} + +User --> () Interface : use +AI --> () Interface : use +Interface --> Hand : manage +Hand --> Card : use +Hand --> [Game field] : change content +Hand --> [Hand display] : set +Card --> [Card display] : define +[Game field] --> [Game field display] : set +@enduml diff --git a/Arch_description/Description.txt b/Arch_description/Description.txt new file mode 100644 index 0000000..feff91c --- /dev/null +++ b/Arch_description/Description.txt @@ -0,0 +1,28 @@ +GLOBAL DESCRIPTION: + + A card game for two players or player and AI. + + THE MAIN GAME ENTITIES: + + There are such cards as Creatures, Spells and Leaders. + Leader affects the characteristics of Creatures and Spells' actions during all the game. + Spells affect the characteristics of Creatures and other spells from the moment the card is played until the end of the round. + There are three types of Creatures such as Siege cards, Long-range cards, Melee cards. Every Creature has strength. + + The Playing Field divided in half, each half intended for one player and divided into three lines for three differrent types of Creatures. + + A Strength of player's army is summ of all Creatures on player's half of playing field. + + GAMEPLAY: + + One game (a battle) devided into three rounds, the result of the battle is based on results of these three rounds. One round divided into moves. + + Leader may be choosen only in the beginning of a battle. + After choosing the Leader player recives 10 random selected cards from his deck, among these cards may be Spells and Creatures. Player may swap one or two of these cards to cards from the deck. + In the beginning of each round except first player takes one cards from the deck. + + One player lays out one card in one move. + + Round ends if both players stop their moves, in particular, if their cards are over. + If in the end of round Strengths of players' armies are equal, they both lose the round, else winner is that one whose army is stronger. + If one player won two rounds, he won in the battle. diff --git a/Arch_description/Requirements.txt b/Arch_description/Requirements.txt new file mode 100644 index 0000000..ac0bf8b --- /dev/null +++ b/Arch_description/Requirements.txt @@ -0,0 +1,5 @@ +The configuration during development + +OS: ubuntu 22.04 +c++ version: c++17 +compiler: g++-11 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..15bc3cb --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +PROJECT = LabWork2 + +TESTPROJECT = test + +CXX = g++ + +CXXFLAGS = -I. -std=c++17 -Werror -Wall -Wpedantic -g -fPIC + +TESTCXXFLAGS = $(CXXFLAGS) -lgtest -lgtest_main -lpthread + +DEPS = $(wildcard *.h) + +TEST-OBJ = test.o + +.PHONY: default + +default: all + +%.o: %.cpp $(DEPS) + $(CXX) -c -o $@ $< $(CXXFLAGS) + +$(PROJECT): main.o + $(CXX) -o $@ main.o $(CXXFLAGS) + +$(TESTPROJECT): $(TEST-OBJ) + $(CXX) -o $@ $^ $(TESTCXXFLAGS) + +.PHONY: test + +test: $(TESTPROJECT) + +all: $(PROJECT) + +clean: + rm -f *.o + rm -f $(PROJECT) + rm -f $(TESTPROJECT) diff --git a/README.md b/README.md index 2af3cf3..783a08d 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -# LabWork2 \ No newline at end of file +# LabWork2 +## Author + +Мызников Федор Денисович, группа 24.Б82-мм +## Contacts + +st129282@student.spbu.ru +## Description diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ab18ca3 --- /dev/null +++ b/main.cpp @@ -0,0 +1,7 @@ +//Myznikov Fedor Denisovich +//st129282@student.spbu.ru +//LabWork2 + + + +int main(int argc, char **argv) {} diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..3c8fd25 --- /dev/null +++ b/test.cpp @@ -0,0 +1,12 @@ +//Myznikov Fedor Denisovich +//st129282@student.spbu.ru +//LabWork2 + + +#include + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}