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

int rand_var (void);

char *arr_options[] = {"STEN", "SAX", "PASE"};


int win_condition(int userchoice, char **arr_options){
  int cpuchoice = rand_var();
  printf("%d\n", cpuchoice);
   
  if (cpuchoice == userchoice){
    printf("Datorn valde %s.\tOavgjort\n", arr_options[cpuchoice]);
  }
  else if(userchoice==cpuchoice - 1 || userchoice == cpuchoice + 2){
    printf("Datorn valde %s.\tDu vinner\n", arr_options[cpuchoice]);
  }
  else if(userchoice == cpuchoice - 2 || userchoice == cpuchoice +1){
    printf("Datorn valde %s.\tDu förlorar\n", arr_options[cpuchoice]);
  }
  /* switch (user_choice){ */
    
  /* case (cpu_choice): */
  /*   Printf("Oavgjort\n"); */
  /*   //counter++; */
  /*   break; */
    
  /* case(cpu_choice - 1): */
  /*   Printf("Du vinner!\n"); */
  /*   break; */
    
  /* case(cpu_choice + 2): */
  /*   Printf("Du vinner!\n"); */
  /*   break; */
    
  /* case (cpu_choice - 2): */
  /*   printf("Du förlorar\n"); */
  /*   break; */
  
  /* case (cpu_choice + 1): */
  /*  printf("Du förlorar\n"); */
  /*  break; */
 


  return 0;
}






int points=0;
int counter = 10;

char buff[256];

int rand_var(void)
{
  srand(time(NULL));
 
  return (rand() % 3);
}

int main () {
  
  //while (counter < 10){
    
    printf("Välj sten [0], sax [1], eller påse[2]\n");
  
    scanf("%c", buff);

    int int_buff = atoi(buff);
  
    if (int_buff <= 2){
      switch(buff[0]){
      
      case '0':
	printf("Du har valt %s\n", arr_options[int_buff]);
	win_condition(int_buff, &arr_options);
	break;
      
      
      case '1':
	printf("Du har valt %s\n", arr_options[int_buff]);
	break;
      
      case '2':
	printf("Du har valt %s\n", arr_options[int_buff]);
	break;
      }
    }
    //}
  return 0;
}

  
