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 6080a9ef006fc561b447937f774d09d7bc167e81 parent 7312fe7716f3dd871a655ce2821d672ffad021ae Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Mon, 20 Jan 2025 17:24:06 +0100 typedef la struct pile pour moins de struct Diffstat:
M | interface.c | | | 24 | ++++++++++++------------ |
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/interface.c b/interface.c @@ -9,23 +9,23 @@ * Donc si on met 5 la taille max serait 4 caractères ? */ #define CARD_NAME_SIZE 25 -struct pile +typedef struct { int cardCount; char **cards; int curline; -}; +} pile; int max(int a, int b) { return a > b ? a : b; } -void addcardtopile(char* cardname, struct pile* p) { +void addcardtopile(char* cardname, pile* p) { p->cards[p->cardCount] = malloc(CARD_NAME_SIZE); strcpy(p->cards[p->cardCount], cardname); p->cardCount++; p->curline=p->cardCount-1; } -void removecardofpile(int cardposition, struct pile* p) { +void removecardofpile(int cardposition, pile* p) { p->cardCount--; for(int i=cardposition;i<p->cardCount;i++) { p->cards[i]=p->cards[i+1]; @@ -33,7 +33,7 @@ void removecardofpile(int cardposition, struct pile* p) { if (p->curline>0) { p->curline--; } } -void moveselection(struct pile* p, char* direction, bool selection) { +void moveselection(pile* p, char* direction, bool selection) { int step; if (direction == "up") { step = -1; } else { step = 1; } @@ -48,7 +48,7 @@ void moveselection(struct pile* p, char* direction, bool selection) { } } -void updatecmd(char* cmd, const struct pile p) { +void updatecmd(char* cmd, const pile p) { if (p.cardCount == 0 ) { return; } strcat(cmd,"( cat ./"); strcat(cmd,p.cards[0]); @@ -67,9 +67,9 @@ void updateres(char *res, const char *cmd, FILE *fp) { } } -struct pile file2pile(FILE *fp) { - struct pile pi; - struct pile *p=π +pile file2pile(FILE *fp) { + pile pi; + pile *p=π p->cardCount=0; p->curline=0; p->cards = malloc(LIST_SIZE); @@ -83,7 +83,7 @@ struct pile file2pile(FILE *fp) { } -void display(struct pile* h, struct pile* p, int handcurline, int playedcurline, char* curmenu,bool selection, char* cmd, char* res) { +void display(pile* h, pile* p, int handcurline, int playedcurline, char* curmenu,bool selection, char* cmd, char* res) { tb_clear(); int i; int j; int w; int biggestpile=max(p->cardCount,h->cardCount); @@ -125,9 +125,9 @@ int main(int argc, char **argv) { char cmd[2000]; cmd[0]='\0'; - struct pile hand=file2pile(fp); struct pile *h=&hand; + pile hand=file2pile(fp); pile *h=&hand; hand.curline=0; - struct pile played; struct pile *p=&played; + pile played; pile *p=&played; played.cards=malloc(LIST_SIZE); played.cardCount=0; played.curline=0;