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 37737c063d2b292b5a56f05ac52521252da7c465
parent 7b97092c96394725be9fca263697b8198c938d86
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 22 Jan 2025 14:47:37 +0100

Nouvelle pile d'arg joués

Fonctionne comme hand et played (ce qui est simple à coder même si c'est
pas forcément l'idéal)
Nécessite de la facto
Les args pourront au moins pour le moment être mis derrière n'importe
qu'elle carte ce qui n'a pas vraiment de sens mais soit

Diffstat:
Minterface.c | 41++++++++++++++++++++++++++++++++++-------
1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/interface.c b/interface.c @@ -18,7 +18,7 @@ typedef struct int curline; } pile; -enum pileid { HAND, PLAYED, ARGS }; +enum pileid { HAND, PLAYED, ARGS, PLAYEDARGS }; int max(int a, int b) { return a > b ? a : b; } @@ -48,13 +48,16 @@ pile createpile(char *name) { return p; } -void addcardtopile(char* cardname, pile* p) { +bool addcardtopile(char* cardname, pile* p) { /*On quitte si l'argument est vide ou s'il contient un espace*/ - if(cardname[0]=='\0' || strchr(cardname,' ')!=NULL){return;} + /* strchr ne fonctionne pas avec utf-8 mais pour le moment rien + * ne fonctionne en utf8 alors bon */ + if(cardname[0]=='\0' || strchr(cardname,' ')!=NULL){return false;} p->cards[p->cardCount] = malloc(CARD_NAME_SIZE); strcpy(p->cards[p->cardCount], cardname); p->cardCount++; p->curline=p->cardCount-1; + return true; } void removecardofpile(int cardposition, pile* p) { @@ -154,10 +157,15 @@ void display(pile** piles, pile curmenu, bool selection, char* cmd, char* res, c lineoffset=displaypile(*piles[HAND], curmenu, 0, 0, selection); lineoffset=displaypile(*piles[ARGS], curmenu, 0, lineoffset, selection); - displaypile(*piles[PLAYED], curmenu, CARD_NAME_SIZE+2, 0, selection); vr(CARD_NAME_SIZE,0,lineoffset); + int lo=displaypile(*piles[PLAYED], curmenu, CARD_NAME_SIZE+2, 0, selection); + + vr(CARD_NAME_SIZE*2,0,max(lineoffset,lo)); + + displaypile(*piles[PLAYEDARGS], curmenu, CARD_NAME_SIZE*2+2, 0, selection); + lineoffset=displaytextblock(cmd,0,lineoffset); lineoffset=displaytextblock(res,0,lineoffset); lineoffset=displaytextblock(intern,0,lineoffset); @@ -183,8 +191,10 @@ int main(int argc, char **argv) { pile hand=file2pile("hand"); pile played=createpile("played"); pile args=createpile("args"); - pile *piles[3]; - piles[HAND]=&hand;piles[PLAYED]=&played;piles[ARGS]=&args; + pile playedargs=createpile("playedargs"); + pile *piles[4]; + piles[HAND]=&hand;piles[PLAYED]=&played; + piles[ARGS]=&args;piles[PLAYEDARGS]=&playedargs; bool selection=false; bool quit=false; @@ -217,6 +227,13 @@ int main(int argc, char **argv) { selection=!selection; } if (piles[HAND]->cardCount > 0){ curmenu=&hand; } + } else if (curmenu->name=="playedargs") { + if (selection) { + addcardtopile(playedargs.cards[playedargs.curline],&args); + removecardofpile(playedargs.curline,&playedargs); + selection=!selection; + } + if (piles[ARGS]->cardCount > 0){ curmenu=&args; } } break; /* -> */ @@ -227,6 +244,12 @@ int main(int argc, char **argv) { removecardofpile(hand.curline,&hand); } if (piles[PLAYED]->cardCount > 0){ curmenu=&played; } + } else if (curmenu->name=="args") { + if (selection) { + addcardtopile(args.cards[args.curline],&playedargs); + removecardofpile(args.curline,&args); + } + if (piles[PLAYEDARGS]->cardCount > 0){ curmenu=&playedargs; } } break; case 13: @@ -238,7 +261,11 @@ int main(int argc, char **argv) { quit=true; break; case 109: - addcardtopile(res,&args); + if(addcardtopile(res,&args)>0) { + for(int i=0;i<=played.cardCount;i++) + { removecardofpile(i,&played); } + curmenu=&hand; + } default: break; }