unicode c'est de la merde, ci+1 retoure en ascii
This commit is contained in:
parent
8a122db98a
commit
69a6303031
2
Makefile
2
Makefile
|
@ -18,7 +18,7 @@ else
|
||||||
OPT=-Og -g
|
OPT=-Og -g
|
||||||
endif
|
endif
|
||||||
DEPFLAGS=-MP -MD
|
DEPFLAGS=-MP -MD
|
||||||
MACROS=HW PI=3.14
|
MACROS=
|
||||||
FLAGS=-Wall -Wextra $(foreach F,$(INCDIRS),-I$(F)) $(OPT) $(DEPFLAGS) $(foreach M,$(MACROS),-D$(M))
|
FLAGS=-Wall -Wextra $(foreach F,$(INCDIRS),-I$(F)) $(OPT) $(DEPFLAGS) $(foreach M,$(MACROS),-D$(M))
|
||||||
|
|
||||||
SRC=$(shell find . -name "*.$(EXT)" -path "./src/*")
|
SRC=$(shell find . -name "*.$(EXT)" -path "./src/*")
|
||||||
|
|
|
@ -13,7 +13,7 @@ class JDC{
|
||||||
|
|
||||||
void init(){
|
void init(){
|
||||||
this->len = 52;
|
this->len = 52;
|
||||||
int index = 0;
|
int index;
|
||||||
for (int i=0; i<4; i++){
|
for (int i=0; i<4; i++){
|
||||||
for (int y=0; y<13; y++){
|
for (int y=0; y<13; y++){
|
||||||
index = (i*13)+y;
|
index = (i*13)+y;
|
||||||
|
@ -65,7 +65,7 @@ class JDC{
|
||||||
return this->jdc[index];
|
return this->jdc[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string valeur(carte c){
|
static std::string valeur(carte c){
|
||||||
if ((int)c.valeur < 10) return std::to_string(c.valeur);
|
if ((int)c.valeur < 10) return std::to_string(c.valeur);
|
||||||
switch(c.valeur){
|
switch(c.valeur){
|
||||||
case T:
|
case T:
|
||||||
|
@ -83,7 +83,7 @@ class JDC{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string couleur(carte c){
|
static std::string couleur(carte c){
|
||||||
switch(c.couleur){
|
switch(c.couleur){
|
||||||
case PIC:
|
case PIC:
|
||||||
return "♠";
|
return "♠";
|
||||||
|
@ -100,6 +100,12 @@ class JDC{
|
||||||
|
|
||||||
std::string* ascii(carte c){
|
std::string* ascii(carte c){
|
||||||
std::string* s = new std::string[3];
|
std::string* s = new std::string[3];
|
||||||
|
//if (c == NULL){
|
||||||
|
// s[0] = "\033[38;5;235m╭──╮";
|
||||||
|
// s[1] = "│ȸȹ│";
|
||||||
|
// s[2] = "╰──╯\033[0m";
|
||||||
|
// return s;
|
||||||
|
//}
|
||||||
std::string co = this->couleur(c);
|
std::string co = this->couleur(c);
|
||||||
s[0] = "\033[38;5;235m╭──╮";
|
s[0] = "\033[38;5;235m╭──╮";
|
||||||
if (co == "♥" || co == "♦") s[1] = "│\033[31m"+this->valeur(c)+co+"\033[38;5;235m│";
|
if (co == "♥" || co == "♦") s[1] = "│\033[31m"+this->valeur(c)+co+"\033[38;5;235m│";
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
#ifndef SCREEN_HPP
|
||||||
|
#define SCREEN_HPP
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include "jdc.hpp"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct point{
|
||||||
|
T x;
|
||||||
|
T y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sprite{
|
||||||
|
std::string* s;
|
||||||
|
int row;
|
||||||
|
int col;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Screen{
|
||||||
|
public:
|
||||||
|
std::string** screen;
|
||||||
|
|
||||||
|
Screen(int col, int row){
|
||||||
|
this->col = col;
|
||||||
|
this->row = row;
|
||||||
|
|
||||||
|
this->screen = new std::string*;
|
||||||
|
for (int i=0; i<row; i++){
|
||||||
|
this->screen[i] = new std::string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
~Screen(){
|
||||||
|
for (int i=0; i<row; i++){
|
||||||
|
delete this->screen[i];
|
||||||
|
}
|
||||||
|
delete this->screen;
|
||||||
|
};
|
||||||
|
|
||||||
|
void background(){
|
||||||
|
for (int i=0; i<row; i++){
|
||||||
|
this->screen[i] = new std::string;
|
||||||
|
for (int y=0; y<col; y++){
|
||||||
|
if (y%2 && i%2) *(this->screen[i]) += "X";
|
||||||
|
else if (!(i%2) && !(y%2)) *(this->screen[i]) += "X";
|
||||||
|
else *(this->screen[i]) += "O";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void display(){
|
||||||
|
std::cout << "\033[1;48;5;22m" << std::endl;
|
||||||
|
for (int i=0; i<row; i++){
|
||||||
|
std::cout << *(this->screen[i]) << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << "\033[0m" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addCard(point<int> p, carte c){
|
||||||
|
this->screen[p.x]->replace(p.y, 4, "╭──╮");
|
||||||
|
this->screen[p.x+1]->replace(p.y+1, 1, JDC::valeur(c));
|
||||||
|
this->screen[p.x+1]->replace(p.y, 1, "│");
|
||||||
|
this->screen[p.x+1]->replace(p.y+5, 1, "│");
|
||||||
|
this->screen[p.x+1]->replace(p.y+4, 1, JDC::couleur(c));
|
||||||
|
this->screen[p.x+2]->replace(p.y, 4, "╰──╯");
|
||||||
|
};
|
||||||
|
|
||||||
|
int ligne(){
|
||||||
|
return this->row;
|
||||||
|
}
|
||||||
|
|
||||||
|
int colone(){
|
||||||
|
return this->col;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
int row;
|
||||||
|
int col;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
carte c = {III, TREFLE};
|
carte c = {III, TREFLE};
|
||||||
if (c.valeur == 3 && c.valeur == 3) std::cout << "\033[32mOK\033[0m" << std::endl;
|
if (c.valeur == 3 && c.couleur == TREFLE) std::cout << "\033[32mOK\033[0m" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include "screen.hpp"
|
||||||
|
#include "jdc.hpp"
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
Screen s(11, 5);
|
||||||
|
s.background();
|
||||||
|
s.display();
|
||||||
|
|
||||||
|
JDC jdc;
|
||||||
|
jdc.init();
|
||||||
|
jdc.shuffle();
|
||||||
|
|
||||||
|
point<int> p = {0, 0};
|
||||||
|
//sprite card = {jdc.ascii(jdc.top()), 3, 4};
|
||||||
|
s.addCard(p, jdc.top());
|
||||||
|
|
||||||
|
//card = {jdc.ascii(NULL), 3};
|
||||||
|
p = {0, 12};
|
||||||
|
s.addCard(p, jdc.get(0));
|
||||||
|
|
||||||
|
s.display();
|
||||||
|
}
|
|
@ -6,42 +6,42 @@ int main(){
|
||||||
jdc.init();
|
jdc.init();
|
||||||
|
|
||||||
jdc.shuffle();
|
jdc.shuffle();
|
||||||
//jdc.display();
|
jdc.display();
|
||||||
//jdc.shuffle();
|
jdc.shuffle();
|
||||||
//jdc.display();
|
jdc.display();
|
||||||
//
|
|
||||||
//carte c = jdc.top();
|
carte c = jdc.top();
|
||||||
//std::cout << "c : " << c.valeur << '+' << c.couleur << std::endl;
|
std::cout << "c : " << c.valeur << '+' << c.couleur << std::endl;
|
||||||
//std::cout << jdc.length() << std::endl;
|
std::cout << jdc.length() << std::endl;
|
||||||
//c = jdc.pop();
|
c = jdc.pop();
|
||||||
//std::cout << "c : " << c.valeur << '+' << c.couleur << std::endl;
|
std::cout << "c : " << c.valeur << '+' << c.couleur << std::endl;
|
||||||
//std::cout << jdc.length() << std::endl;
|
std::cout << jdc.length() << std::endl;
|
||||||
//
|
|
||||||
//c = jdc.get(0);
|
c = jdc.get(0);
|
||||||
//std::cout << "c : " << c.valeur << '+' << c.couleur << std::endl;
|
std::cout << "c : " << c.valeur << '+' << c.couleur << std::endl;
|
||||||
//std::cout << jdc.length() << std::endl;
|
std::cout << jdc.length() << std::endl;
|
||||||
//
|
|
||||||
//jdc.display();
|
jdc.display();
|
||||||
//std::cout << jdc.length() << std::endl;
|
std::cout << jdc.length() << std::endl;
|
||||||
//
|
|
||||||
//jdc.push({K, COEUR});
|
jdc.push({K, COEUR});
|
||||||
//jdc.display();
|
jdc.display();
|
||||||
//std::cout << jdc.length() << std::endl;
|
std::cout << jdc.length() << std::endl;
|
||||||
//
|
|
||||||
//std::cout << "bottom = " << jdc.valeur(jdc.get(0)) << jdc.couleur(jdc.get(0)) << std::endl;
|
std::cout << "bottom = " << jdc.valeur(jdc.get(0)) << jdc.couleur(jdc.get(0)) << std::endl;
|
||||||
//std::cout << "2 = " << jdc.valeur(jdc.get(2)) << jdc.couleur(jdc.get(2)) << std::endl;
|
std::cout << "2 = " << jdc.valeur(jdc.get(2)) << jdc.couleur(jdc.get(2)) << std::endl;
|
||||||
//
|
|
||||||
//std::cout << "top = " << jdc.valeur(jdc.top()) << jdc.couleur(jdc.top()) << std::endl;
|
std::cout << "top = " << jdc.valeur(jdc.top()) << jdc.couleur(jdc.top()) << std::endl;
|
||||||
//std::cout << jdc.couleur(jdc.top()).length() << std::endl;
|
std::cout << jdc.couleur(jdc.top()).length() << std::endl;
|
||||||
|
|
||||||
//std::cout << "\033[1;48;5;22m" << std::endl;
|
//std::cout << "\033[1;48;5;22m" << std::endl;
|
||||||
for (int y=0; y<52; y++){
|
//for (int y=0; y<52; y++){
|
||||||
std::string* ss = jdc.ascii(jdc.get(y));
|
// std::string* ss = jdc.ascii(jdc.get(y));
|
||||||
for (int i=0; i<3; i++){
|
// for (int i=0; i<3; i++){
|
||||||
std::cout << "\033[1;48;5;22;38;5;235m" << ss[i] << std::endl;
|
// std::cout << "\033[1;48;5;22;38;5;235m" << ss[i] << std::endl;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
std::cout << "\033[0m" << std::endl;
|
//std::cout << "\033[0m" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue