/* Main function for ECE 209 Program 2: yzscore.
   Implements user interface, calls scoring functions.
   G. Byrd, Sept 2010
*/

#include <stdio.h>
#include <stdlib.h>

#include "yzscore.h"

int getRoll(int dice[]);

int main() {
  int dice[5] = {0};

  while (getRoll(dice) != EOF) {
    printf("Three of a kind: %d\n", score3(dice));
    printf("Four of a kind: %d\n", score4(dice));
    printf("Full house: %d\n", scoreFull(dice));
    printf("Small straight: %d\n", scoreSmall(dice));
    printf("Large straight: %d\n", scoreLarge(dice));
    printf("Yahtzee: %d\n", score5(dice));
    printf("Chance: %d\n", scoreChance(dice));
    printf("\n");
  }
  printf("\n");
  return EXIT_SUCCESS;
}

/* Read user data into array. */

int getRoll(int *dice) {
  int status = 0;
  int i = 0;
  int done = 0;
  while (!done) {
    printf("Roll: ");
    done = 1;
    for (i=0; i<5; i++) {
      status = scanf("%d", &dice[i]);
      if (status == EOF) break;
      if ((dice[i] < 1) || (dice[i] > 6)) done = 0;
    }
  }
  return status;
}

