Up: The libtarot test suite [Contents][Index]
If a player has the petit as the only trump (and does not posess the excuse), then the deal is not valid.
#ifdef HAVE_CONFIG_H #include <config.h> #endif /* HAVE_CONFIG_H */ #include <tarot.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #ifndef LOCALEDIR #define LOCALEDIR "/usr/share/locale" #endif /* NOT LOCALEDIR */ int main () { TarotGame *game; size_t i; static const char *card_names[] = { "1T", "KH", "QH", "CH", "JH", "10H", "9H", "8H", "7H", "6H", "5H", "4H", "3H", "2H", "AH", "KC", "QC", "CC" }; TarotCard cards[sizeof (card_names) / sizeof (card_names[0])]; TarotGameEvent *event; if (tarot_init (LOCALEDIR) != 0) { fprintf (stderr, "Error: could not initialize libtarot.\n"); return EXIT_FAILURE; } game = tarot_game_alloc (); for (i = 0; i < sizeof (cards) / sizeof (cards[0]); i++) { cards[i] = tarot_string_to_card_c (card_names[i]); assert (cards[i] != ((TarotCard) (-1))); } event = tarot_game_event_alloc_deal (1, sizeof (cards) / sizeof (cards[0]), cards); if (tarot_game_add_event (game, event) == TAROT_GAME_OK) { fprintf (stderr, "Error: the petit sec as accepted.\n"); return EXIT_FAILURE; } tarot_game_event_free (event); /* Also give the excuse */ cards[1] = TAROT_EXCUSE; event = tarot_game_event_alloc_deal (1, sizeof (cards) / sizeof (cards[0]), cards); if (tarot_game_add_event (game, event) != TAROT_GAME_OK) { fprintf (stderr, "Error: the petit sec was refused for wrong reasons.\n"); return EXIT_FAILURE; } tarot_game_event_free (event); tarot_game_free (game); tarot_quit (); return EXIT_SUCCESS; }