Skip to content
Open
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
64 changes: 64 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"files.associations": {
"iostream": "cpp",
"ratio": "cpp",
"system_error": "cpp",
"array": "cpp",
"functional": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"string_view": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp"
}
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
59 changes: 43 additions & 16 deletions Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,56 @@
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
using namespace std;

#include "sources/player.hpp"
#include "sources/game.hpp"
#include "sources/card.hpp"
using namespace ariel;

int main() {
// Create two players with their names
Player p1("Alice");
Player p2("Bob");
int main()
{
// Player p1("Alice");
// Player p2("Bob");
// Game game(p1,p2);
// cout<<"stack size is"<<p1.stacksize()<<endl;
// cout<<"stack size is"<<p2.stacksize()<<endl;

Game game(p1,p2);
for (int i=0;i<5;i++) {
// game.playAll();

// int sum= p1.cardesTaken()+p2.cardesTaken()+p1.stacksize()+p2.stacksize();
// cout<<"sum is"<<sum<<endl;
// cout<<"p1 size is"<<p1.Start_stack.size()<<endl;
// cout<<"p2 size is"<<p2.Start_stack.size()<<endl;
// cout<<"p1 card taken is"<<p1.cardesTaken()<<endl;
// cout<<"p2 card taken is"<<p2.cardesTaken()<<endl;

// game.printLastTurn();
// game.printLog();
// game.printWiner();
// game.printStats();

// return 0;
// }

// Create two players with their names
Player p1("Alice");
Player p2("Bob");

Game game(p1, p2);
for (int i = 0; i < 5; i++)
{
game.playTurn();
}
game.printLastTurn(); // print the last turn stats. For example:
// Alice played Queen of Hearts Bob played 5 of Spades. Alice wins.
// Alice played 6 of Hearts Bob played 6 of Spades. Draw. Alice played 10 of Clubs Bob played 10 of Diamonds. draw. Alice played Jack of Clubs Bob played King of Diamonds. Bob wins.
cout << p1.stacksize() << endl; //prints the amount of cards left. should be 21 but can be less if a draw was played
cout << p2.cardesTaken() << endl; // prints the amount of cards this player has won.
game.playAll(); //playes the game untill the end
game.printWiner(); // prints the name of the winning player
game.printLog(); // prints all the turns played one line per turn (same format as game.printLastTurn())
game.printStats();// for each player prints basic statistics: win rate, cards won, <other stats you want to print>. Also print the draw rate and amount of draws that happand. (draw within a draw counts as 2 draws. )
}
game.printLastTurn(); // print the last turn stats. For example:
// Alice played Queen of Hearts Bob played 5 of Spades. Alice wins.
// Alice played 6 of Hearts Bob played 6 of Spades. Draw. Alice played 10 of Clubs Bob played 10 of Diamonds. draw. Alice played Jack of Clubs Bob played King of Diamonds. Bob wins.
cout << p1.stacksize() << endl; // prints the amount of cards left. should be 21 but can be less if a draw was played
cout << p2.cardesTaken() << endl; // prints the amount of cards this player has won.
game.playAll(); // playes the game untill the end
game.printWiner(); // prints the name of the winning player
game.printLog(); // prints all the turns played one line per turn (same format as game.printLastTurn())
game.printStats(); // for each player prints basic statistics: win rate, cards won, <other stats you want to print>. Also print the draw rate and amount of draws that happand. (draw within a draw counts as 2 draws. )
}
Empty file added objects/file.txt
Empty file.
12 changes: 12 additions & 0 deletions sources/card.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <stack>
#include <random>
#include "card.hpp"

using namespace std;

namespace ariel
{

}

131 changes: 131 additions & 0 deletions sources/card.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#pragma once
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

namespace ariel
{

class Card
{

public:
enum Suit
{
SPADES,
HEARTS,
CLUBS,
DIAMONDS
};

enum Cards{
ACE=1,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE,
TEN,
PRINCE,
QUEEN,
KING
};

private:
int value;
Suit suit;

public:
Card(int m_value, Suit m_suit) : value(m_value), suit(m_suit) {}

int getValue() const
{
return value;
}

Suit getSuit() const
{
return suit;
}

int get_size();

static vector<Card> Create_cards()
{

std::vector<Card> deck;
int index = 0;
for (int suit = Card::SPADES; suit <= Card::DIAMONDS; suit++)
{
for (int value = ACE; value <= KING; value++)
{
deck.push_back(Card(value, (Card::Suit)suit));

}

}
srand(time(0));
random_shuffle(deck.begin(), deck.end());


return deck;
}


string getSuitName() const
{
switch (suit)
{
case HEARTS:
return "Hearts";
case DIAMONDS:
return "Diamonds";
case CLUBS:
return "Clubs";
case SPADES:
return "Spades";
}
return "Unknown";
}

string getValueName() const
{
switch (value)
{
case ACE:
return "Ace";
case TWO:
return "2";
case THREE:
return "3";
case FOUR:
return "4";
case FIVE:
return "5";
case SIX:
return "6";
case SEVEN:
return "7";
case EIGHT:
return "8";
case NINE:
return "9";
case TEN:
return "10";
case PRINCE:
return "Prince";
case QUEEN:
return "Queen";
case KING:
return "King";
}
return "Unknown";
}
};
}
Loading