X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=kub%2Fkub.c;h=f9dfc3448cc94bb96a6cf32bf394f50bec5a8148;hb=a8925bfcf99614560389cafd813951d827c08d68;hp=0f538594b3b8040317f73e0ea6fc77c3f71b8c9f;hpb=775dfcb68992b085d25c508593ade8eca2f8980e;p=ttt diff --git a/kub/kub.c b/kub/kub.c index 0f53859..f9dfc34 100755 --- a/kub/kub.c +++ b/kub/kub.c @@ -137,7 +137,7 @@ static void deck_deal(game_t *game, deck_t *deck) { card_t temp; int rand_card; - int i, j, last = deck->num_cards, newline; + int i, j, newline; printf ("How many players(1-4) should I deal in? "); game->num_players = getchar(); @@ -153,9 +153,9 @@ static void deck_deal(game_t *game, deck_t *deck) { for (j = 0; j < 14; ++j) { - rand_card = ((last + 1.0) * rand()) / (RAND_MAX + 1.0); + rand_card = ((deck->num_cards + 1.0) * rand()) / (RAND_MAX + 1.0); temp = deck->cards[rand_card]; - deck->cards[rand_card] = deck->cards[last]; + deck->cards[rand_card] = deck->cards[deck->num_cards - 1]; game->players[i].hand.cards[j] = temp; deck->num_cards -= 1; game->players[i].hand.num_cards += 1; @@ -192,8 +192,8 @@ static void deck_shuffle(deck_t *deck) { rand_card = ((last + 1.0) * rand()) / (RAND_MAX + 1.0); temp = deck->cards[rand_card]; - deck->cards[rand_card] = deck->cards[last]; - deck->cards[last] = temp; + deck->cards[rand_card] = deck->cards[last - 1]; + deck->cards[last - 1] = temp; } } @@ -218,6 +218,7 @@ static void hand_print(game_t *game) int i; for (i = 0; i < game->players[0].hand.num_cards; ++i) { + printf ("Player 1 has these tiles:\n"); card_print(game->players[0].hand.cards[i]); } }