|
#include <vector>
|
|
#include "card.hpp"
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <sstream>
|
|
|
|
class CardGui
|
|
{
|
|
public:
|
|
std::string renderCard(std::string key)
|
|
{
|
|
Card card(key);
|
|
std::string card_template;
|
|
std::stringstream ss;
|
|
std::string extra_top = " ";
|
|
std::string extra_bottom = "_";
|
|
if(card.value == "10"){
|
|
extra_top = "";
|
|
extra_bottom = "";
|
|
}
|
|
ss << "________ \n";
|
|
ss << "|" << card.value << extra_top << " |\n";
|
|
ss << "| " << card.kind << " |\n";
|
|
ss << "| " << card.kind << " |\n";
|
|
ss << "| " << card.kind << " |\n";
|
|
ss << "|_____" << extra_bottom << card.value << "|\n";
|
|
card_template = ss.str();
|
|
return card_template;
|
|
}
|
|
|
|
std::string getLine(std::string card_template, int n)
|
|
{
|
|
std::stringstream ss(card_template);
|
|
std::string line;
|
|
for (int i = 0; i < n; i++)
|
|
std::getline(ss, line, '\n');
|
|
return line;
|
|
}
|
|
|
|
std::string renderCards(Card card1, Card card2){
|
|
std::vector<Card> cards = std::vector<Card>();
|
|
cards.push_back(card1);
|
|
cards.push_back(card2);
|
|
return this->renderCards(cards);
|
|
}
|
|
std::string renderCards(std::vector<Card> cards)
|
|
{
|
|
int lineHeight = 6;
|
|
std::stringstream ss;
|
|
std::vector<std::string> templates;
|
|
for (auto &card : cards)
|
|
{
|
|
templates.push_back(this->renderCard(card.key));
|
|
}
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
for (auto &tpl : templates)
|
|
{
|
|
ss << this->getLine(tpl, i) << " ";
|
|
}
|
|
ss << std::endl;
|
|
}
|
|
return ss.str();
|
|
}
|
|
};
|