Exemplo n.º 1
0
void load_ply_info_cb(struct db_result *result)
{
	//数据导入后的回调函数
	if(result){
		player_t ply = result->ud;
		if(result->result_set){
			redisReply *r = (redisReply*)result->result_set;	
			if(r->type != REDIS_REPLY_NIL){
				lua_State *L = tls_get(LUASTATE);
				if(0 != CALL_LUA_FUNC2(L,"CreateLuaPlayer",1,
						               PUSH_LUSRDATA(L,ply),
									   PUSH_TABLE3(L,
									   PUSH_STRING(L,r->element[0]->str),
									   PUSH_STRING(L,r->element[1]->str),
									   PUSH_STRING(L,r->element[2]->str))))
				{
					const char * error = lua_tostring(L, -1);
					lua_pop(L,1);
					printf("%s\n",error);
				}else
					ply->_luaply = create_luaObj(L,-1);							
			}else{
				//没有角色,通知客户端创建角色
				shortmsg2gate(CMD_GAME2C_CREATE,ply->_agentsession);					
			}
		}else{
			//数据库访问出错
			shortmsg2gate(CMD_GAME2GATE_BUSY,ply->_agentsession);	
			remove_player(ply);	
		}
	}
}
Exemplo n.º 2
0
void player_login(rpacket_t rpk,player_t ply)
{
	uint32_t gateident = rpk_read_uint32(rpk);
	const char *actname = rpk_read_string(rpk);
	ply = find_player_by_actname(actname);
	if(ply){
		//对象还未销毁
		if(ply->_agentsession != 0){
			//通知gate直接断掉连接
			shortmsg2gate(CMD_GAME2GATE_INVID_CON,gateident);
		}else{
			//重新绑定
		}		
	}else{
		ply = create_player(actname,gateident);
		if(!ply){
			//通知玩家系统繁忙
			shortmsg2gate(CMD_GAME2GATE_BUSY,gateident);
			return;
		}
		if(0 != load_player_info(ply)){
			shortmsg2gate(CMD_GAME2GATE_BUSY,gateident);
			remove_player(ply);
		}
	}
}
Exemplo n.º 3
0
/**
 * Handle a player ban request.
 *
 * @param data the request packet
 * @param len the length of data
 * @param cli_addr the address of the sender
 * @param cli_len the length of cli_addr
 */
void *c_req_ban(char *data, unsigned int len, struct player *pl)
{
	uint32_t ban_id;
	struct player *target;
	char *reason, *ptr;
	uint16_t duration;
	struct server *s = pl->in_chan->in_server;

	ptr = data + 24;
	ban_id = ru32(&ptr);
	duration = ru16(&ptr);

	target = get_player_by_public_id(s, ban_id);

	if (target != NULL) {
		send_acknowledge(pl);		/* ACK */
		if(player_has_privilege(pl, SP_ADM_BAN_IP, target->in_chan)) {
			reason = rstaticstring(29, &ptr);
			add_ban(s, new_ban(0, target->cli_addr->sin_addr, reason));
			logger(LOG_INFO, "Reason for banning player %s : %s", target->name, reason);
			s_notify_ban(pl, target, duration, reason);
			remove_player(s, target);
			free(reason);
		}
	}
	return NULL;
}
Exemplo n.º 4
0
static void	read_command(t_server *server, int sock)
{
  char		*buffer;
  int		ret;
  t_player	*tmp;

  if (!(buffer = get_next_line(sock)) || feof(fdopen(sock, "r")))
    {
      remove_player(server, sock);
      close(sock);
      FD_CLR(sock, &server->fds);
      return ;
    }
  ret = strlen(buffer);
  buffer[ret] = 0;
  if (buffer[ret - 1] == '\n')
    buffer[ret - 1] = 0;
  if (ret > 1 && buffer[ret - 2] == '\r')
    buffer[ret - 2] = 0;
  tmp = server->players;
  while (tmp && tmp->fd != sock)
    tmp = tmp->next;
  if (!tmp)
    return ;
  perform_cmd(server, tmp, buffer);
}
Exemplo n.º 5
0
/**
 * Handles a server kick request.
 *
 * @param data the request packet
 * @param len the length of data
 * @param cli_addr the address of the sender
 * @param cli_len the length of cli_addr
 */
void *c_req_kick_server(char *data, unsigned int len, struct player *pl)
{
	uint32_t target_id;
	char *reason, *ptr;
	struct player *target;
	struct server *s = pl->in_chan->in_server;

	if (len != 60) {
		logger(LOG_WARN, "c_req_kick_server, packet has invalid size : %i instead of %i.", len, 60);
		return NULL;
	}

	ptr = data + 24;
	target_id = ru32(&ptr);
	target = get_player_by_public_id(s, target_id);

	if (target != NULL) {
		send_acknowledge(pl);		/* ACK */
		if(player_has_privilege(pl, SP_OTHER_SV_KICK, target->in_chan)) {
			ptr = data + 28;
			reason = rstaticstring(29, &ptr);
			logger(LOG_INFO, "Reason for kicking player %s : %s", target->name, reason);
			s_notify_kick_server(pl, target, reason);
			remove_player(s, pl);
			free(reason);
		}
	}

	return NULL;
}
Exemplo n.º 6
0
void	finish(t_server *server, int id)
{
  int	i[2];

  if (server->players)
    dprintf(server->players->fd, "FINISH %d\n", id);
  if (server->players && server->players->next)
    dprintf(server->players->next->fd, "FINISH %d\n", id);
  while (server->players)
    {
      close(server->players->fd);
      FD_CLR(server->players->fd, &server->fds);
      remove_player(server, server->players->fd);
    }
  server->count = server->started = 0;
  i[0] = 0;
  while (i[0] < server->map->width)
    {
      i[1] = 0;
      while (i[1] < server->map->height)
	{
	  if (server->map->data[i[1]][i[0]] == OLD_COIN)
	    server->map->data[i[1]][i[0]] = COIN;
	  i[1]++;
	}
      i[0]++;
    }
}
Exemplo n.º 7
0
void reset_bord_player()
{
    for (int j=0;j<=4 ;j++)
    {
     for (int k=0 ;k<=4;k++)    
     {
         if (j==4&&k==0||j==4&&k==4||j==0&&k==4||j==0&&k==0)
            add_tiger_player(j,k);
         else
            remove_player(j,k);
     }
    }
}
Exemplo n.º 8
0
static void
test_world_player_foreach(CuTest *tc)
{
    const char *err = "world.c PLAYER_FOREACH macro FAIL";
    const char *username = "******";
    int max = MAX_PLAYERS;
    int mid = max / 2;
    player_t *player;
    player_t *plist[max];
    int i;

    if (max % 2 == 1) {
        CuFail(tc, "world.c PLAYER_FOREACH macro FAIL -- "
               "Rerun tests with even number of max players");
    }

    for (i = 0; i < max; ++i) {
        player = get_unused_player_slot();
        CuAssertIntEquals_Msg(tc, err, i + 1, player->index);
        player->username = username;
        if (i == mid - 1) {
            remove_player(player);
            continue;
        }

        plist[i] = player;
    }

    i = 0;
    player = NULL;
    PLAYER_LIST_FOREACH(player) {
        if (player->index == UNUSED) {
            ++i;
            continue;
        }

        CuAssertPtrEquals_Msg(tc, err, plist[i++], player);
    }

    player = get_unused_player_slot();
    CuAssertIntEquals_Msg(tc, err, mid, player->index);

    player = get_unused_player_slot();
    CuAssertPtrEquals_Msg(tc, err, NULL, player);

#if UNIT_TESTING_VERBOSITY_LEVEL >= 1
    printf("world.c PLAYER_FOREACH macro PASS\n");
#endif
}
Exemplo n.º 9
0
void  game_service::on_main_thread_update()
{

		boost::posix_time::ptime  pt1 = boost::posix_time::microsec_clock::local_time();

		auto iter = players_.begin();


		for(;iter != players_.end();)
		{
			player_ptr pp = iter->second;

		    if(!pp.get())
			{
				++iter;
				continue;
			}

			if(pp->last_op_time.is_not_a_date_time())
			{
				++iter;
				continue;
			}

			if( (pt1-pp->last_op_time).total_seconds() > KICK_OUT_SECONDS )
			{
				
				auto conn = pp->from_socket_.lock();
				if (conn.get()){
					conn->close();
				}

				if(!pp->is_connection_lost_){
					pp->on_connection_lost();
					remove_player(pp);
					iter = players_.erase(iter);
				}
		
			}
			else
			{
				++iter;
			}
		}
}
Exemplo n.º 10
0
void server::distribute_changes()
{
  char cmd;

  for (view *f=player_list; f; f=f->next)
  {
    cmd=SCMD_SET_INPUT;
    next_out.write((uint8_t *)&cmd,1);
    uint16_t pn=lstl(f->player_number);
    next_out.write((uint8_t *)&pn,2);

    signed char inp[5];
    inp[0]=f->x_suggestion;
    inp[1]=f->y_suggestion;
    inp[2]=f->b1_suggestion;
    inp[3]=f->b2_suggestion;
    inp[4]=f->b3_suggestion;
    next_out.write((uint8_t *)inp,5);
  }

  if (sync_check)
  {
    cmd=SCMD_SYNC;
    uint32_t x=lltl(make_sync_uint32());
    next_out.write((uint8_t *)&cmd,1);
    next_out.write((uint8_t *)&x,4);
  }

  for (f=player_list; f; )
  {
    view *n=f->next;
    if (!f->local_player() && f->connect)
      if (!send_pkt(f->connect,next_out))
        remove_player(f);
    f=n;
  }

}
Exemplo n.º 11
0
void		expulse(t_server *s, t_player *p, char *param)
{
  t_player	*front;
  t_player	*tmp;
  t_tile	*tile;
  static char	str[500];

  (void)param;
  if (p->next_t == NULL && s->game.map[p->x + p->y * s->x].players == p)
    communication_sendto(p->client_data, "ko\n", 1);
  else
    {
      front = s->game.map[p->x + p->y * s->x].players;
      remove_player(&front, &tmp, p);
      tile = get_front_tile(s, p);
      p->next_t = NULL;
      update_expulsed(s, tile, front, tmp);
      s->game.map[p->x + p->y * s->x].players = p;
      communication_sendto(p->client_data, "ok\n", 1);
      memset(str, 0, 500);
      sprintf(str, "pex %d\n", p->id);
      communication_broadcast(s->display_list, str);
    }
}
Exemplo n.º 12
0
// incomplete
Data Connect4::minimax(int level){
	std::vector<Data> v;
	// Data v[8];
	for(int i=1; i<=7; ++i){
		if(!insert(i)) continue;
		else{
			if(level==max_level) v.push_back(weight(i));
			else v.push_back(minimax(level+1));
			remove_player(i);
		}
	}
	// dhange se return kar
	Data temp = v[0];
	for(Data &i : v){
		if(level%2==0){
			if(temp.first > i.first)
			temp = i;
		}else{
			if(temp.first < i.first)
			temp = i;
		}
	}
	return temp;
}
Exemplo n.º 13
0
void server::collect_inputs()
{
  out_socket *collect_server=NULL;
  for (view *f=player_list; f; )
  {
    view *next=f->next;
    if (is_server)
    {
      if (f->connect)
      {
    packet pk;
    if (get_pkt(f->connect,pk))
    {
      while (!pk.eop())
      {
        uint8_t cmd;
        if (pk.read((uint8_t *)&cmd,1)==1)
          if (!process_command(f,cmd,pk))
          { remove_player(f); f=NULL; }
      }
    } else
    {
      remove_player(f);
      f=NULL;
    }

      } else
      {
        f->get_input();
    add_change_log(f,next_out,1);
      }
    }
    else
    {
      if (f->local_player())
      {
        f->get_input();
    if (f->connect && !send_inputs(f))
          remove_from_server(f);
    else if (f->connect)
          collect_server=f->connect;  // take note that we should collect the input back from the server
      }
    }
    f=next;
  }

  if (collect_server)
  {
    packet pk;
    if (!get_pkt(collect_server,pk))
    {
      for (view *f=player_list; f; f=f->next)
        if (f->local_player())
      remove_from_server(f);
    }

    if (!client_do_packet(pk))
      printf("Error occurred while processing packet from server\n");
  }

  if (is_server && in)
    distribute_changes();

}
Exemplo n.º 14
0
void timer_handler( int signum )
{
    char buf[MAX_SMESG_LEN+1], * x = &buf[7]; /* buffer for outgoing messages */
    PQUEUE *temp, *r;
    int i, j;

    #ifdef DEBUG_BARF
        BARF( "timer expired", signum );
    #endif

    switch( server_status ) {
        case SHUFFL://TODO: remove DC players before here?
            if( (c_in_tab+p_in_lob) < min_ppplaying ) {/* !Enough Players */
                #ifdef DEBUG_BARF
                    BARF( "!enough players", c_in_tab+p_in_lob );
                #endif
                if( p_in_tab ) { /* Re-Enqueue Table Players Into Lobby */
                    c_in_tab = p_in_tab = 0; /* Stand Up */
                    while( (temp = warlord.next) ) { //TODO: just append remainder of warlord list to lobby and reset scumbag
                        /* Remove DC Players */
                        if( warlord.who->status != DIS_CONN ) {
                            ++p_in_lob;
                            warlord.who->status = IN_LOBBY;
                            lobby_last->who = warlord.who;
                            lobby_last = lobby_last->next = CALLOC( 1, PQUEUE ); /* WARNING: assumes calloc is successfull */
                        } else init_player( warlord.who-player );//init_p( warlord.who );
                        warlord.who = warlord.next->who;
                        warlord.next = warlord.next->next;
                        free( temp );
                    } /* End de-queue While */
//TODO: WORKING: append warlord to lobby and hold dc players in another ll
//                     lobby_last->who = warlord.who;
//                     lobby_last->next = warlord.next;
//                     lobby_last = scumbag;
//                     warlord.who = NULL; warlord.next = NULL;
                    scumbag = &warlord;
//                     //TODO: remove dc players from appended section, set status
                    send_slobb_mesg();
                }/* End Moved Players to Lobby If */
                server_status = ENQING;
                hand_status = HAND_1; /* Reset Hand For Next Players */
                return;
            } /* End !Enough Players Remain to Play If */

            if( hand_status == HAND_1 ) need_club3 = true;
            else {
                server_status = SWAPIN;
                #ifdef DEBUG_BARF
                    BARF( "PLAYING ANOTHER HAND", hand_status );
                #endif
            }/* End !HAND_1 Else */

            /* Move to Table */
            p_in_tab = 0; /* Everyone Stand Up */
            while( (temp = warlord.next) ) {
                /* Remove DC Players */
                if( warlord.who->status != DIS_CONN ) {
                    table[p_in_tab] = warlord.who;
                    ++table[p_in_tab++]->hands; /* SGUI  - Track Qt Played Hands */
                } else init_player( warlord.who-player );//init_p( warlord.who );
                warlord.who = warlord.next->who;
                warlord.next = warlord.next->next;
                free( temp );
            } /* End de-queue While */
            scumbag = &warlord;

            /* Move in From Lobby if Room */
            if(( p_in_tab < MAX_PPPLAYING )&&( p_in_lob )) {
                sprintf( buf, "[slobb|" ); /* Correct qt Filled in Later */

                /* Sit at Table */
                while( p_in_tab < MAX_PPPLAYING ) {
                    if( !lobby_head.who ) break;
                    table[p_in_tab++] = lobby_head.who;
                    lobby_head.who = lobby_head.next->who;
                    temp = lobby_head.next;
                    lobby_head.next = lobby_head.next->next;
                    free( temp ); --p_in_lob;
                }/* End Room@Table While */

                *x++ = '0'+ (int)( p_in_lob / 10 );
                *x++ = '0'+ ( p_in_lob % 10 );
                *x++ = '|';

                lobby_last = r = &lobby_head;
                while( r->who ) {
                    sprintf( x, "%s,", r->who->name );
                    x += 9;
                    lobby_last = r;
                    r = r->next;
                }/* End Current Player Exists Else */
                *(x-1) = ']'; *x = 0;
                broadcast( buf, 10+(9*p_in_lob) );
            }/* End New Players Join If */
            c_in_tab = p_in_tab;
            for( i = c_in_tab; i < MAX_PPPLAYING; i++ ) table[i] = NULL;

            /* Deal */
            assert( p_in_tab >= DEF_MIN_PLAYERS );
//             deal( time( NULL ) );
            if( deal( time( NULL ) ) ) { /* Returns True if Failed */
                /* If Got Here then !Enough Players Anymore */
                for( i = 0; i < p_in_tab; i++ ) {
                    lobby_last->who = table[i];
                    lobby_last = lobby_last->next = CALLOC( 1, PQUEUE ); /* WARNING: assumes calloc is successfull */
                    ++p_in_lob;
                } /* End Re-Enqueue For */
                send_slobb_mesg();
                server_status = ENQING;
                return;
            }/* End Failed Deal If */

            sprintf( buf, "[shand|" );
            for( i = 0; i < c_in_tab; i++ ) {
                x = &buf[7];
                for( j = 0; j < MAX_PHAND_LEN; j++ ) {
                    *x++ = '0'+ (int)( table[i]->hand[j] / 10 );
                    *x++ = '0'+ ( table[i]->hand[j] % 10 );
                    *x++ = ',';
                }/* End card in hand For */
                 *(x-1) = ']'; *x = 0;
                if( Write( table[i]->socketfd, buf, 61 ) < 0 )
                    ERROR( "write", strerror(errno), i );
            }/* End table[i] For */

            if( server_status != SWAPIN ) {
                send_tabl_mesg();
                server_status = ACTIVE;
            } else { /* Request Swap */
                char* cd = &(table[p_in_tab-1]->hand[MAX_PHAND_LEN-1]);
                while( *cd == 52 ) --cd; /* Find Highest Card */
                swapped_cd = *cd;
                assert( (unsigned)swapped_cd < 52 );/* ERROR CHECK */
                if( use_gui ) /* Decrement Count -- SGUI */
                    --deck[swapped_cd]->count[(swapped_cd-(swapped_cd%4))/4];
                deck[swapped_cd] = table[0]; /* Give Warlord Swappeed Card */
                if( use_gui ) /* Increment Count -- SGUI */
                    ++deck[swapped_cd]->count[(swapped_cd-(swapped_cd%4))/4];
                /* Update Scores For SGUI */
                ++table[0]->score; --table[p_in_tab-1]->score;
                /* Notify Clients of Change */
                ( swapped_cd < 10 ) ?
                    sprintf( buf, "[swapw|%c%d]", '0', swapped_cd ):
                    sprintf( buf, "[swapw|%d]", swapped_cd );
                if( Write( table[0]->socketfd, buf, 10 ) < 0 )
                    ERROR( "write", strerror(errno), table[0]->socketfd );
            }/* End SWAPIN Else */

            timer.it_value.tv_sec = ertimeout;
            setitimer( ITIMER_REAL, &timer, NULL );
            break;
        case ACTIVE:
            #ifdef DEBUG_BARF
                BARF( "Testing: server_status is ACTIVE.", ACTIVE );
            #endif
            for( i = 0; i < MAX_PPPLAYING; i++ )
                if( player[i].status == ACTIVE_P ) break;
            /* No Break */
        case SWAPIN:
            #ifdef DEBUG_BARF
                if( server_status != ACTIVE )
                    BARF( "Testing: server_status is SWAPIN", SWAPIN );
            #endif
            if( server_status != ACTIVE ) i = table[0] - &player[0];
            if( strike( i, PLAY_TIMEOUT ) )
                remove_player( i, buf, gfds );
            else if( server_status == ACTIVE ) send_tabl_mesg();
            timer.it_value.tv_sec = ertimeout;
            setitimer( ITIMER_REAL, &timer, NULL );
            break;
        default: /* ENQING */
            #ifdef DEBUG_BARF
                ERROR( "timer_h", "Timer went off while ENQING", signum );
            #endif
            break;
    }/* End server_status Switch */
    return;
}/* End timer_handler Func */
Exemplo n.º 15
0
void	remove_player_from_pos(t_clientIA *player, t_map *map, Uint x, Uint y)
{
  remove_player(player, map->map[y][x]);
}
Exemplo n.º 16
0
int main()
{
    //initialize allegro
    allegro_init();
    install_keyboard();
    install_mouse();      
    //initialize video mode to 640x480
    set_color_depth(32);
    int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    install_sound(DIGI_AUTODETECT, MIDI_NONE, "") ;

    pointer = load_bitmap("pointer.bmp", NULL);
    board=load_bitmap("bord.bmp",NULL);
    tiger=load_bitmap("tiger.bmp",NULL);
    goat=load_bitmap("goat.bmp",NULL);
    target=load_bitmap("target.bmp",NULL);
    buffer = create_bitmap(640,480);
    // mouse
    set_mouse_sprite(pointer);
    set_mouse_sprite_focus(15,15);
    show_mouse(screen);
    //top
    top:;
    
    count_dead_goat = 0;
    count_steps = 0;
    
    reset_bord_player();
    textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
    show_bord_player();
    turn=2;  
//background sound
        background=load_sample("background.wav");
        play_sample(background, volume, panning, pitch, TRUE);

//wait
int tempx,tempy,temp_player ;    
while (!key[KEY_ESC])
{
//grab the current mouse values
mx = mouse_x;
my = mouse_y;
mb = (mouse_b & 1);

    

 temp_player= check_location_available(getx(mx),getx(my));
if (temp_player!=3 && mb==1)
{
    if (turn==1 && temp_player==1)
    {
             textout_ex(buffer, font, "TIGER'S TURN", 480, 1, 1, -1);
              textout_ex(buffer, font, "FIND TIGER PLACE",480, 1 , white, -1);
                  tempx=getx(mx);
                  tempy=gety(my);
                turn=11;
    }
    else if(turn==11 && temp_player==0)
    {
         if(check_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
        add_tiger_player(getx(mx),gety(my));
//sound
        sound=load_sample("tiger.wav");
        play_sample(sound, volume, panning, pitch, FALSE);
        remove_player(tempx,tempy);
        turn=2;
         textout_ex(buffer, font, "FIND TIGER PLACE", 480, 1, 1, -1);
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
         }
         else if(check_jump_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
        add_tiger_player(getx(mx),gety(my));
        remove_player(tempx,tempy);
//sound
        sound=load_sample("tiger.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

        remove_player((tempx+getx(mx))/2,(tempy+gety(my))/2);
        turn=2;
         textout_ex(buffer, font, "FIND TIGER PLACE", 480, 1, 1, -1);
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
         count_dead_goat++;
         }

         
    }
    else if(turn==2  && temp_player==2 && count_steps>=20)
    {
         turn=22;
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , 1, -1);
         textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , white, -1);
                  tempx=getx(mx);
                  tempy=gety(my);

    }
    else if(turn==22 && temp_player==0)
    {
         if(check_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
//sound
        sound=load_sample("goat.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

             add_goat_player(getx(mx),gety(my));
              remove_player(tempx,tempy);
    turn=1;
         textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , 1, -1);
         textout_ex(buffer, font, "TIGER'S TURN", 480, 1, white, -1);
         }
    }
    else if(turn==2 && temp_player==0 && count_steps<20)
    {
         count_steps++;
    add_goat_player(getx(mx),gety(my));
//sound
        sound=load_sample("goat.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

    turn=1;
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , 1, -1);
         textout_ex(buffer, font, "TIGER'S TURN", 480, 1, white, -1);

    }
    if ( check_game_over()==1)
    {
         textout_ex(buffer, font, "GOAT WINS", 480, 30, white, -1);
         goto end;
         }
    else if ( check_game_over()==2)
    {
         textout_ex(buffer, font, "TIGER WINS", 480, 30, white, -1);
         goto end;
         }
    

    show_bord_player();
}
       if (turn==11)
    {     

          jump=check_possible_jump_movement(tempx,tempy);     
          move=check_possible_movement(tempx,tempy);
          show_possible_jump_movement(tempx,tempy);
          show_possible_movement(tempx,tempy);
          if( jump==0 && move==0 )
          {
          turn=1;
          textout_ex(buffer, font,"FIND TIGER PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "TIGER'S TURN",480, 1 , white, -1);
          show_bord_player();          
          }
    }
       if (turn==22)
    {
          move=check_possible_movement(tempx,tempy);
          show_possible_movement(tempx,tempy);          
          if (move==0)
          {
          turn=2;
          textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , 1, -1);
          textout_ex(buffer, font, "GOAT'S TURN", 480, 1, white, -1);
          show_bord_player();
          }

     
    }
    

/* uncheck tiget or goat to move
     if(turn==11 && mb==2)
     {  turn=1;
          textout_ex(buffer, font,"FIND TIGER PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "TIGER'S TURN",480, 1 , white, -1);
          show_bord_player();          
        }
     if(turn==22 && mb==2)
     {  turn=2;
          textout_ex(buffer, font,"FIND GOAT PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
            show_bord_player();
     }
*/


     
//pause
rest(10);
}
end:;



allegro_message("game over");    
//sound        
        sound=load_sample("clapping.wav");
        play_sample(sound, volume, panning, pitch, FALSE);
          textout_ex(screen, font, "PLAY AGAIN?(Y/N)",480, 10 , white, -1);        
while (!key[KEY_N])
{
 if(key[KEY_Y])
    goto top;
}
    set_mouse_sprite(NULL);
    destroy_sample(sound);        
    destroy_sample(background);    
    destroy_bitmap(pointer);
    destroy_bitmap(board);
    destroy_bitmap(tiger);
    destroy_bitmap(goat);
    destroy_bitmap(buffer);
    destroy_bitmap(target);
    allegro_exit();    
    return 0;
}