pipe-game

Un jeu de cartes à piper les une dans les autres - retour accueil

git clone git://bebou.netlib.re/pipe-game
Log | Files | Refs | README |

commit 3d2c130294c5771319123cdddc93bac7a191074e
parent c73088b21e3a1d3b24a5a15c47ac019f5d4ae2e2
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Tue, 28 Jan 2025 22:37:41 +0100

Affichage :  on suit la progression de X et Y

Pour que les boites se suivent bien les une après les autres
Nécessité d'ajouter un type coordonnées
Adaptation de l'affichage des blocs de texte à venir

Diffstat:
Minterface.c | 42+++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/interface.c b/interface.c @@ -10,14 +10,18 @@ * Donc si on met 5 la taille max serait 4 caractères ? */ #define CARD_NAME_SIZE 25 -typedef struct -{ +typedef struct { char *name; int cardCount; char **cards; int curline; } pile; +typedef struct { + int x; + int y; +} coord; + enum pileid { HAND, PLAYED, ARGS, PLAYEDARGS, PLAYEDENNEMY, PLAYEDENNEMYARGS }; int max(int a, int b) { return a > b ? a : b; } @@ -155,6 +159,7 @@ void file2pile(FILE* fp, pile *p, pile **piles) { } void displaybox(int coloffset, int lineoffset, int width, int length) { + length<2 ? length=2 : length; hr(coloffset+1,lineoffset,width-1); hr(coloffset+1,lineoffset+length,width-1); vr(coloffset,lineoffset+1,length-1); @@ -165,10 +170,12 @@ void displaybox(int coloffset, int lineoffset, int width, int length) { tb_print(coloffset+width,lineoffset+length,TB_DEFAULT,TB_DEFAULT,"+"); } -int displaypile(pile p, pile curmenu, int coloffset, int lineoffset, bool selection) { +coord displaypile(pile p, pile curmenu, int coloffset, int lineoffset, bool selection) { int newlineoffset=lineoffset; int maxwidth=CARD_NAME_SIZE+2; int maxlen=p.cardCount+1; displaybox(coloffset,lineoffset,maxwidth,maxlen); + coord point; + point.x=coloffset+maxwidth; point.y=lineoffset+maxlen; coloffset++;lineoffset++; for (int i=0;i<p.cardCount;i++) { char *name = strcmp(p.cards[i],"none")==0 ? " " : p.cards[i] ; @@ -180,12 +187,11 @@ int displaypile(pile p, pile curmenu, int coloffset, int lineoffset, bool select tb_printf(coloffset, lineoffset+i, TB_DEFAULT, TB_DEFAULT, name); newlineoffset++; } - return newlineoffset+1; + return point; } int displaytextblock(char *text, int coloffset, int lineoffset) { int nbl=nblines(text); - nbl==0 ? nbl++ : nbl; displaybox(coloffset,lineoffset,20,nbl+1); coloffset++;lineoffset++; tb_printf(coloffset, lineoffset, TB_DEFAULT, TB_DEFAULT, text); @@ -205,32 +211,30 @@ int debug(int l, pile curmenu,struct tb_event ev) { } int display(pile** piles, pile curmenu, bool selection, char* cmd, char* res, char* intern, char* cmdennemy, char* resennemy, char* internennemy) { - int lineoffset1=0, lineoffset2=0; + coord p; tb_clear(); - displaypile(*piles[PLAYEDARGS], curmenu, 0, 0, selection); - displaypile(*piles[PLAYED], curmenu, CARD_NAME_SIZE+2, 0, selection); - lineoffset1=displaypile(*piles[HAND], curmenu, CARD_NAME_SIZE*2+2, 0, selection); - lineoffset1=displaypile(*piles[ARGS], curmenu, CARD_NAME_SIZE*2+2, lineoffset1, selection); - lineoffset2=displaypile(*piles[PLAYEDENNEMY], curmenu, CARD_NAME_SIZE*3+2, 0, selection); - displaypile(*piles[PLAYEDENNEMYARGS], curmenu, CARD_NAME_SIZE*4+2, 0, selection); - - int lo=lineoffset1; + p=displaypile(*piles[PLAYEDARGS], curmenu, 0, 0, selection); + coord p2=displaypile(*piles[PLAYED], curmenu, p.x, 0, selection); + p=displaypile(*piles[HAND], curmenu, p2.x, 0, selection); + p=displaypile(*piles[ARGS], curmenu, p2.x, p.y, selection); + p=displaypile(*piles[PLAYEDENNEMY], curmenu, p.x, 0, selection); + displaypile(*piles[PLAYEDENNEMYARGS], curmenu, p.x, 0, selection); - lineoffset1=displaytextblock(res,0,lo); + int lineoffset1=0; + lineoffset1=displaytextblock(res,0,30); lineoffset1=displaytextblock(intern,0,lineoffset1); lineoffset1=displaytextblock(cmd,0,lineoffset1); - lineoffset2=displaytextblock(resennemy,CARD_NAME_SIZE*3+2,lo); + int lineoffset2=displaytextblock(resennemy,CARD_NAME_SIZE*3+2,30); lineoffset2=displaytextblock(internennemy,CARD_NAME_SIZE*3+2,lineoffset2); lineoffset2=displaytextblock(cmdennemy,CARD_NAME_SIZE*3+2,lineoffset2); - lo=max(lineoffset1,lineoffset2); - lo=displaytextblock("\ + int lo=displaytextblock("\ * enter to select card\n\ * arrows to move selection\n\ * m to create arg (if no whitespace)\n\ -* e to end turn and output res\n",0,lo); +* e to end turn and output res\n",0,40); lo=hr(0,lo,CARD_NAME_SIZE*5);