Пример #1
0
void turn (int score[], int dice_values[], int size, int num_values[])
{
//Saw redundancy in the code, so instead of copy and pasting this 26 times, I made it into a function
printf("Roll 1\n");
roll_dice(dice_values, size);
show_dice(dice_values, size);
reroll(dice_values, size);
printf("Roll 2\n");
show_dice(dice_values, size);
reroll(dice_values, size);
printf("Roll 3\n");
show_dice(dice_values, size);
}
Пример #2
0
void		avance(t_msg *msg, t_client *client, t_map **map, t_opt *opt)
{
  e_direct	type;

  (void)opt;
  type = client->direct;
  sub_food(msg, client, "ok\n");
  msg->time = get_time_client(client, 7);
  if (type == SUD)
    client->map = (client->map->y + 1) < client->map->y_world ?
      &map[client->map->y + 1][client->map->x] : &map[0][client->map->x];
  else if (type == EST)
    client->map = (client->map->x + 1) < client->map->x_world ?
      &map[client->map->y][client->map->x + 1] : &map[client->map->y][0];
  else if (type == OUEST)
    client->map = (client->map->x - 1) >= 0 ?
      &map[client->map->y][client->map->x - 1] :
      &map[client->map->y][client->map->x_world - 1];
  else if (type == NORD)
    {
      client->map = (client->map->y - 1) >= 0 ?
	&map[client->map->y - 1][client->map->x] :
	&map[client->map->y_world - 1][client->map->x];
    }
  client->direct = type;
  giveposition(client, reroll(client));
}
Пример #3
0
int main(){
  int i;
  srand(time(NULL));

  reset_cata();

  for(i = 0; i < 13; i++){
    reset_dice();
    roll();
    reroll();
    reroll();
    assign_catagory();
    printf("\nYour score for round %d is %d!\n", i+1, score());
  }

  return 1;
}
Пример #4
0
void		gauche(t_msg *msg, t_client *client, t_map **map, t_opt *opt)
{
  (void)opt;
  if (map)
    {
      sub_food(msg, client, "ok\n");
      msg->time = get_time_client(client, 7);
      if (client->direct == SUD)
	client->direct = EST;
      else if (client->direct == EST)
	client->direct = NORD;
      else if (client->direct == NORD)
	client->direct = OUEST;
      else if (client->direct == OUEST)
	client->direct = SUD;
      giveposition(client, reroll(client));
    }
}
Пример #5
0
void		giveinvall(t_client *cl)
{
  t_client	*tmp;
  char		*str;
  int		size;

  size = snprintf(NULL, 0, "pin %d %d %d %d %d %d %d %d %d %d\n",
		  cl->id, cl->map->x, cl->map->y, cl->ress[0] / 126,
		  cl->ress[1], cl->ress[2], cl->ress[3], cl->ress[4],
		  cl->ress[5], cl->ress[6]) + 1;
  str = xmalloc((size + 1) * sizeof(char));
  snprintf(str, size, "pin %d %d %d %d %d %d %d %d %d %d\n",
	   cl->id, cl->map->x, cl->map->y, cl->ress[0] / 126,
	   cl->ress[1], cl->ress[2], cl->ress[3], cl->ress[4],
	   cl->ress[5], cl->ress[6]);
  tmp = reroll(cl);
  while (tmp && tmp->end != 1)
    {
      if (tmp->type == GRAPHIC)
	write(tmp->fd, str, strlen(str));
      tmp = tmp->nt;
    }
  free(str);
}
Пример #6
0
//Done By Daniel(Leader)
//check the monster location and the direction they go 
void monster(COORD& monster1,int& g_idirection)
{
    bool bcollision = false;
	//check the condition met  
    if(bcollision == false)
	{
		if(g_idirection == 0)
		{
			//when the condition met
			if(wall_left(monster1) == true)
			{
				bcollision = true;
			}
			else
			{ 
				monster1.X--;
			}
            }
            if(g_idirection == 1)
            {
                if(wall_right(monster1) == true)
				{
                    bcollision=true;
                }
                else
				{
					monster1.X++;
                }
            }
            if(g_idirection==2)
            {
               if(wall_down(monster1) == true)
			   {
				   bcollision=true;
			   }
			   else
			   {
				   monster1.Y++;
			   }
            }
            if(g_idirection == 3)
            {
                if(wall_up(monster1) == true)
				{
                    bcollision=true;
                }
                else
				{
					monster1.Y--;
                }
            }
			//check what wall they hit 
            if(wall_up(monster1) == false && wall_down(monster1) == false && wall_left(monster1) == false && wall_right(monster1) == false)
			{
                bcollision=true;
            }
            if(wall_up(monster1) == false && wall_down(monster1) == false && wall_left(monster1) == false)
			{
                bcollision=true;
            }
            if(wall_up(monster1) == false && wall_down(monster1) == false && wall_right(monster1) == false)
			{
                bcollision=true;
            }
            if(wall_up(monster1) == false && wall_left(monster1) == false && wall_right(monster1) == false)
			{
                bcollision=true;
            }
            if(wall_down(monster1) == false && wall_left(monster1) == false && wall_right(monster1) == false)
			{
                bcollision=true;
            }
    }
	//if the monster is going against the wall re-roll the direction
    if(bcollision == true)
	{
        reroll(g_idirection);
    }
}