Skip to content
Closed
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
31 changes: 31 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file added Arch_description/ClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
169 changes: 169 additions & 0 deletions Arch_description/ClassDiagram.txt
Original file line number Diff line number Diff line change
@@ -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<Creature*> melee_player1
-vector<Creature*> archers_player1
-vector<Creature*> siege_player1

-vector<Creature*> melee_player2
-vector<Creature*> archers_player2
-vector<Creature*> siege_player2

-uint strength_player1
-uint strength_player2

-vector<"Line spell"> line_spells

+void enum(vector<Creature*> line)
+void cleaning()
}


class Deck {
-vector<Creature*>

+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
Binary file added Arch_description/ComponentDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Arch_description/ComponentDiagram.txt
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions Arch_description/Description.txt
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions Arch_description/Requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The configuration during development

OS: ubuntu 22.04
c++ version: c++17
compiler: g++-11
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# LabWork2
# LabWork2
## Author

Мызников Федор Денисович, группа 24.Б82-мм
## Contacts

st129282@student.spbu.ru
## Description
7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//Myznikov Fedor Denisovich
//st129282@student.spbu.ru
//LabWork2



int main(int argc, char **argv) {}
12 changes: 12 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//Myznikov Fedor Denisovich
//st129282@student.spbu.ru
//LabWork2


#include <gtest/gtest.h>

int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}