示例#1
0
文件: five99.c 项目: yrchen/Athena
int p_five()
{
   int i=0;
   srandom(time(0));

restart:
  setutmpmode(FIVE);
  showtitle("天地五子棋", BOARDNAME);

  outs("┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐\n");
for(sum=0;sum<20;sum++)
  outs("├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤\n");
  outs("└┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┘\n");


   gotoxy(48,1); outs("=-=-=-=-=-=-=-=-=-=");
   gotoxy(48,2); outs("|   天地五子棋    |");
   gotoxy(48,3); outs("=-=-=-=-=-=-=-=-=-=");
   who(0); who(1);

   gotoxy(45,17); outs(" ↓↑→← >> 控制方向");
   gotoxy(45,18); outs("  空白鍵  >> 確定");
   gotoxy(45,19); outs("     2    >> 二號玩家換人");
   gotoxy(45,20); outs("     b    >> 悔棋");
   gotoxy(45,21); outs("     r    >> 重新開始");
   gotoxy(45,22); outs("     q    >> 離開");

   for(m=1;m<22;m++)
    for(n=1;n<22;n++)
      chess[m][n]=0;

   sum=fturn=0;
   m=n=mm=nn=11;
   for(;;)
   {
     if(role[fturn]==1)
     {
       int tmp=fplayer(fturn+1);
       if(tmp==1) goto restart;
       if(tmp==2) return;
     }
     else
     {
       int hk=think(fturn+1);
       if(hk)
       {
         i=show_win(hk);
         if(i=='q'||i=='n') return;
         goto restart;
       }
     }
     fturn=abs(fturn-1);
   }
}
示例#2
0
文件: scrolls.c 项目: kioy/TA-Demo2
void
read_scroll(void)
{
    THING *obj;
    PLACE *pp;
    int y, x;
    int ch;
    int i;
    int discardit = FALSE;
    struct room *cur_room;
    THING *orig_obj;
    coord mp;

    obj = get_item("read", SCROLL);
    if (obj == NULL)
	return;
    if (obj->o_type != SCROLL)
    {
	if (!terse)
	    msg("there is nothing on it to read");
	else
	    msg("nothing to read");
	return;
    }
    /*
     * Calculate the effect it has on the poor guy.
     */
    if (obj == cur_weapon)
	cur_weapon = NULL;
    /*
     * Get rid of the thing
     */
    discardit = (obj->o_count == 1);
    leave_pack(obj, FALSE, FALSE);
    orig_obj = obj;

    switch (obj->o_which)
    {
	case S_CONFUSE:
	    /*
	     * Scroll of monster confusion.  Give him that power.
	     */
	    player.t_flags |= CANHUH;
	    msg("your hands begin to glow %s", pick_color("red"));
	when S_ARMOR:
	    if (cur_armor != NULL)
	    {
		cur_armor->o_arm--;
		cur_armor->o_flags &= ~ISCURSED;
		msg("your armor glows %s for a moment", pick_color("silver"));
	    }
	when S_HOLD:
	    /*
	     * Hold monster scroll.  Stop all monsters within two spaces
	     * from chasing after the hero.
	     */

	    ch = 0;
	    for (x = hero.x - 2; x <= hero.x + 2; x++)
		if (x >= 0 && x < NUMCOLS)
		    for (y = hero.y - 2; y <= hero.y + 2; y++)
			if (y >= 0 && y <= NUMLINES - 1)
			    if ((obj = moat(y, x)) != NULL && on(*obj, ISRUN))
			    {
				obj->t_flags &= ~ISRUN;
				obj->t_flags |= ISHELD;
				ch++;
			    }
	    if (ch)
	    {
		addmsg("the monster");
		if (ch > 1)
		    addmsg("s around you");
		addmsg(" freeze");
		if (ch == 1)
		    addmsg("s");
		endmsg();
		scr_info[S_HOLD].oi_know = TRUE;
	    }
	    else
		msg("you feel a strange sense of loss");
	when S_SLEEP:
	    /*
	     * Scroll which makes you fall asleep
	     */
	    scr_info[S_SLEEP].oi_know = TRUE;
	    no_command += rnd(SLEEPTIME) + 4;
	    player.t_flags &= ~ISRUN;
	    msg("you fall asleep");
	when S_CREATE:
	    /*
	     * Create a monster:
	     * First look in a circle around him, next try his room
	     * otherwise give up
	     */
	    i = 0;
	    for (y = hero.y - 1; y <= hero.y + 1; y++)
		for (x = hero.x - 1; x <= hero.x + 1; x++)
		    /*
		     * Don't put a monster in top of the player.
		     */
		    if (y == hero.y && x == hero.x)
			continue;
		    /*
		     * Or anything else nasty
		     * Also avoid a xeroc which is disguised as scroll
		     */
		    else if (moat(y, x) == NULL && step_ok(ch = winat(y, x)))
		    {
			if (ch == SCROLL
			    && find_obj(y, x)->o_which == S_SCARE)
				continue;
			else if (rnd(++i) == 0)
			{
			    mp.y = y;
			    mp.x = x;
			}
		    }
	    if (i == 0)
		msg("you hear a faint cry of anguish in the distance");
	    else
	    {
		obj = new_item();
		new_monster(obj, randmonster(FALSE), &mp);
	    }
	when S_ID_POTION:
	case S_ID_SCROLL:
	case S_ID_WEAPON:
	case S_ID_ARMOR:
	case S_ID_R_OR_S:
	{
	    int id_type[S_ID_R_OR_S + 1] =
		{ 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S };
	    /*
	     * Identify, let him figure something out
	     */
	    scr_info[obj->o_which].oi_know = TRUE;
	    msg("this scroll is an %s scroll", scr_info[obj->o_which].oi_name);
/*	    whatis(TRUE, id_type[obj->o_which]); */
	    if (idscr_md != TRUE)
		whatis(TRUE, id_type[obj->o_which]);
	    else
		whatis(FALSE, 0);
	}
	when S_MAP:
	    /*
	     * Scroll of magic mapping.
	     */
	    scr_info[S_MAP].oi_know = TRUE;
	    msg("oh, now this scroll has a map on it");
	    /*
	     * take all the things we want to keep hidden out of the window
	     */
	    for (y = 1; y < NUMLINES - 1; y++)
		for (x = 0; x < NUMCOLS; x++)
		{
		    pp = INDEX(y, x);
		    switch (ch = pp->p_ch)
		    {
			case DOOR:
			case STAIRS:
			    break;

			case '-':
			case '|':
			    if (!(pp->p_flags & F_REAL))
			    {
				ch = pp->p_ch = DOOR;
				pp->p_flags |= F_REAL;
			    }
			    break;

			case ' ':
			    if (pp->p_flags & F_REAL)
				goto def;
			    pp->p_flags |= F_REAL;
			    ch = pp->p_ch = PASSAGE;
			    /* FALLTHROUGH */

			case PASSAGE:
pass:
			    if (!(pp->p_flags & F_REAL))
				pp->p_ch = PASSAGE;
			    pp->p_flags |= (F_SEEN|F_REAL);
			    ch = PASSAGE;
			    break;

			case FLOOR:
			    if (pp->p_flags & F_REAL)
				ch = ' ';
			    else
			    {
				ch = TRAP;
				pp->p_ch = TRAP;
				pp->p_flags |= (F_SEEN|F_REAL);
			    }
			    break;

			default:
def:
			    if (pp->p_flags & F_PASS)
				goto pass;
			    ch = ' ';
			    break;
		    }
		    if (ch != ' ')
		    {
			if ((obj = pp->p_monst) != NULL)
			    obj->t_oldch = ch;
			if (obj == NULL || !on(player, SEEMONST))
			    mvaddch2(y, x, ch);
		    }
		}
	when S_FDET:
	    /*
	     * Potion of gold detection
	     */
	    ch = FALSE;
	    wclear(hw);
	    for (obj = lvl_obj; obj != NULL; obj = next(obj))
		if (obj->o_type == FOOD)
		{
		    ch = TRUE;
		    wmove(hw, obj->o_pos.y, obj->o_pos.x);
		    waddch2(hw, FOOD);
		}
	    if (ch)
	    {
		scr_info[S_FDET].oi_know = TRUE;
		show_win("Your nose tingles and you smell food.--More--");
	    }
	    else
		msg("your nose tingles");
	when S_TELEP:
	    /*
	     * Scroll of teleportation:
	     * Make him dissapear and reappear
	     */
	    {
		cur_room = proom;
		teleport();
		if (cur_room != proom)
		    scr_info[S_TELEP].oi_know = TRUE;
	    }
	when S_ENCH:
	    if (cur_weapon == NULL || cur_weapon->o_type != WEAPON)
		msg("you feel a strange sense of loss");
	    else
	    {
		cur_weapon->o_flags &= ~ISCURSED;
		if (rnd(2) == 0)
		    cur_weapon->o_hplus++;
		else
		    cur_weapon->o_dplus++;
		msg("your %s glows %s for a moment",
		    weap_info[cur_weapon->o_which].oi_name, pick_color("blue"));
	    }
	when S_SCARE:
	    /*
	     * Reading it is a mistake and produces laughter at her
	     * poor boo boo.
	     */
	    msg("you hear maniacal laughter in the distance");
	when S_REMOVE:
	    uncurse(cur_armor);
	    uncurse(cur_weapon);
	    uncurse(cur_ring[LEFT]);
	    uncurse(cur_ring[RIGHT]);
	    msg(choose_str("you feel in touch with the Universal Onenes",
			   "you feel as if somebody is watching over you"));
	when S_AGGR:
	    /*
	     * This scroll aggravates all the monsters on the current
	     * level and sets them running towards the hero
	     */
	    aggravate();
	    msg("you hear a high pitched humming noise");
	when S_PROTECT:
	    if (cur_armor != NULL)
	    {
		cur_armor->o_flags |= ISPROT;
		msg("your armor is covered by a shimmering %s shield",
		    pick_color("gold"));
	    }
	    else
		msg("you feel a strange sense of loss");
#ifdef MASTER
	otherwise:
	    msg("what a puzzling scroll!");
	    return;
#endif
    }
    obj = orig_obj;
    look(TRUE);	/* put the result of the scroll on the screen */
    status();

    call_it(&scr_info[obj->o_which]);

    if (discardit)
	discard(obj);
}
示例#3
0
文件: five99.c 项目: yrchen/Athena
static int fplayer(int race)
{
  int l;
    while(-1)
    {
      gotoxy(48,15); prints("目前位置(%2d,%2d)",m,n);
      put_box(mm,nn,0);
      put_box(m,n,race);
      mm=m; nn=n;
      l=igetkey();
      switch(l)
      {
//      case '1':
        case '2':
         if(role[l-'1']==1)
         {
           role[l-'1']=2; 
           attack[l-'1']=0;
         }
         else if(attack[l-'1']==0)
           attack[l-'1']=1;
         else
           role[l-'1']=1;

         who(l-'1');
         break;
        case 'q': return 2;
        case 'r': return 1;
        case 'b':
         if(sum>2)
         {
           int i;
           for(i=0;i<2;i++)
           {
             int x=repent[sum-1][1],y=repent[sum-1][2];
             put_chess(x,y,0);
             move(y+1,x*2); outs("┼");
             sum-=2;
           }
           for(i=sum;i>=sum-5;i--)
           {
             gotoxy(48,i-sum+13);
             if(i>0)
               prints("第%d步: %s (%2d,%2d)  ",i,(repent[i-1][0]==1)?"●":"○",
                 repent[i-1][1],repent[i-1][2]);
             else
               outs("                  ");
           }
         }
         break;
        case ' ':
         if(!chess[m-1][n-1])
         {
           int hk=put_chess(m,n,race);
           if(hk)
           {
             int dk = show_win(hk);
             if(dk=='n'||dk=='q') return 2;
             return 1;
           }
           return 0;
         }
         break;
        case KEY_DOWN:  //down
          if(legal(m,n+1)) n++; 
          break; 
        case KEY_UP:	//up
          if(legal(m,n-1)) n--; 
          break;
        case KEY_RIGHT:	//right
          if(legal(m+1,n)) m++; 
          break;
        case KEY_LEFT:	//left
          if(legal(m-1,n)) m--; 
          break;
      }
    }
}
示例#4
0
void
quaff()
{
    THING *obj, *tp, *mp;
    bool discardit = FALSE;
    bool show, trip;

    obj = get_item("quaff", POTION);
    /*
     * Make certain that it is somethings that we want to drink
     */
    if (obj == NULL)
	return;
    if (obj->o_type != POTION)
    {
	if (!terse)
	    msg("yuk! Why would you want to drink that?");
	else
	    msg("that's undrinkable");
	return;
    }
    if (obj == cur_weapon)
	cur_weapon = NULL;

    /*
     * Calculate the effect it has on the poor guy.
     */
    trip = on(player, ISHALU);
    discardit = (bool)(obj->o_count == 1);
    leave_pack(obj, FALSE, FALSE);
    switch (obj->o_which)
    {
	case P_CONFUSE:
	    do_pot(P_CONFUSE, !trip);
	when P_POISON:
	    pot_info[P_POISON].oi_know = TRUE;
	    if (ISWEARING(R_SUSTSTR))
		msg("you feel momentarily sick");
	    else
	    {
		chg_str(-(rnd(3) + 1));
		msg("you feel very sick now");
		come_down();
	    }
	when P_HEALING:
	    pot_info[P_HEALING].oi_know = TRUE;
	    if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
		pstats.s_hpt = ++max_hp;
	    sight();
	    msg("you begin to feel better");
	when P_STRENGTH:
	    pot_info[P_STRENGTH].oi_know = TRUE;
	    chg_str(1);
	    msg("you feel stronger, now.  What bulging muscles!");
	when P_MFIND:
	    player.t_flags |= SEEMONST;
	    fuse((void(*)())turn_see, TRUE, HUHDURATION, AFTER);
	    if (!turn_see(FALSE))
		msg("you have a %s feeling for a moment, then it passes",
		    choose_str("normal", "strange"));
	when P_TFIND:
	    /*
	     * Potion of magic detection.  Show the potions and scrolls
	     */
	    show = FALSE;
	    if (lvl_obj != NULL)
	    {
		wclear(hw);
		for (tp = lvl_obj; tp != NULL; tp = next(tp))
		{
		    if (is_magic(tp))
		    {
			show = TRUE;
			wmove(hw, tp->o_pos.y, tp->o_pos.x);
			waddch(hw, MAGIC);
			pot_info[P_TFIND].oi_know = TRUE;
		    }
		}
		for (mp = mlist; mp != NULL; mp = next(mp))
		{
		    for (tp = mp->t_pack; tp != NULL; tp = next(tp))
		    {
			if (is_magic(tp))
			{
			    show = TRUE;
			    wmove(hw, mp->t_pos.y, mp->t_pos.x);
			    waddch(hw, MAGIC);
			}
		    }
		}
	    }
	    if (show)
	    {
		pot_info[P_TFIND].oi_know = TRUE;
		show_win("You sense the presence of magic on this level.--More--");
	    }
	    else
		msg("you have a %s feeling for a moment, then it passes",
		    choose_str("normal", "strange"));
	when P_LSD:
	    if (!trip)
	    {
		if (on(player, SEEMONST))
		    turn_see(FALSE);
		start_daemon(visuals, 0, BEFORE);
		seenstairs = seen_stairs();
	    }
	    do_pot(P_LSD, TRUE);
	when P_SEEINVIS:
	    sprintf(prbuf, "this potion tastes like %s juice", fruit);
	    show = on(player, CANSEE);
	    do_pot(P_SEEINVIS, FALSE);
	    if (!show)
		invis_on();
	    sight();
	when P_RAISE:
	    pot_info[P_RAISE].oi_know = TRUE;
	    msg("you suddenly feel much more skillful");
	    raise_level();
	when P_XHEAL:
	    pot_info[P_XHEAL].oi_know = TRUE;
	    if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
	    {
		if (pstats.s_hpt > max_hp + pstats.s_lvl + 1)
		    ++max_hp;
		pstats.s_hpt = ++max_hp;
	    }
	    sight();
	    come_down();
	    msg("you begin to feel much better");
	when P_HASTE:
	    pot_info[P_HASTE].oi_know = TRUE;
	    after = FALSE;
	    if (add_haste(TRUE))
		msg("you feel yourself moving much faster");
	when P_RESTORE:
	    if (ISRING(LEFT, R_ADDSTR))
		add_str(&pstats.s_str, -cur_ring[LEFT]->o_arm);
	    if (ISRING(RIGHT, R_ADDSTR))
		add_str(&pstats.s_str, -cur_ring[RIGHT]->o_arm);
	    if (pstats.s_str < max_stats.s_str)
		pstats.s_str = max_stats.s_str;
	    if (ISRING(LEFT, R_ADDSTR))
		add_str(&pstats.s_str, cur_ring[LEFT]->o_arm);
	    if (ISRING(RIGHT, R_ADDSTR))
		add_str(&pstats.s_str, cur_ring[RIGHT]->o_arm);
	    msg("hey, this tastes great.  It make you feel warm all over");
	when P_BLIND:
	    do_pot(P_BLIND, TRUE);
	when P_LEVIT:
	    do_pot(P_LEVIT, TRUE);
#ifdef MASTER
	otherwise:
	    msg("what an odd tasting potion!");
	    return;
#endif
    }
    status();
    /*
     * Throw the item away
     */

    call_it(&pot_info[obj->o_which]);

    if (discardit)
	discard(obj);
    return;
}
void Application::init_connections(){


    CONNECT (player, pause(),                                       listen,				pause());
           CONNECT (player, search(int),							listen,			jump(int));
           CONNECT (player, sig_volume_changed(int),				listen,			setVolume(int));
           CONNECT (player, sig_rec_button_toggled(bool),			listen,			record_button_toggled(bool));
           CONNECT (player, setupLastFM(),                          ui_lastfm, 		show_win()); // IND
           CONNECT (player, baseDirSelected(const QString &),		library, 		baseDirSelected(const QString & ));
           CONNECT (player, reloadLibrary(), 						library, 		reloadLibrary());
           CONNECT (player, importDirectory(QString),				library,		importDirectory(QString));
           CONNECT (player, libpath_changed(QString),               library, 			setLibraryPath(QString));
           CONNECT (player, fileSelected(QStringList &),			playlist, 			psl_createPlaylist(QStringList&));
           CONNECT (player, play(),                                 playlist,			psl_play());
           CONNECT (player, stop(),                                 playlist,			psl_stop());
           CONNECT (player, forward(),                              playlist,			psl_forward());
           CONNECT (player, backward(),                             playlist,			psl_backward());
           CONNECT (player, sig_stream_selected(const QString&, const QString&), 		playlist, psl_play_stream(const QString&, const QString&));
           CONNECT (player, show_playlists(),						ui_playlist_chooser, 	show()); // IND
           CONNECT (player, skinChanged(bool),                      ui_playlist, 		change_skin(bool));
           CONNECT (player, show_small_playlist_items(bool),		ui_playlist,		psl_show_small_playlist_items(bool));
           CONNECT (player, sig_sound_engine_changed(QString&), 	plugin_loader,      psl_switch_engine(QString&));
           CONNECT (player, sig_show_stream_rec(bool),              ui_stream_rec,		psl_show(bool)); // IND
           CONNECT (player, sig_show_socket(),                      ui_socket_setup,    show()); // IND


           CONNECT (player, sig_correct_id3(const MetaData&), 	ui_id3_editor,		change_meta_data(const MetaData&)); // IND


           CONNECT (playlist, sig_selected_file_changed_md(const MetaData&),		player,		update_track(const MetaData&));
           CONNECT (playlist, sig_selected_file_changed_md(const MetaData&), 		listen, 		changeTrack(const MetaData & ));
           CONNECT (playlist, sig_selected_file_changed_md(const MetaData&),		lastfm,			psl_track_changed(const MetaData&));
           CONNECT (playlist, sig_no_track_to_play(),								listen,			stop());
           CONNECT (playlist, sig_goon_playing(),                                   listen,			play());
           CONNECT (playlist, sig_selected_file_changed(int),                       ui_playlist, 	track_changed(int));
           CONNECT (playlist, sig_playlist_created(vector<MetaData>&, int), 		ui_playlist, 	fillPlaylist(vector<MetaData>&, int));
           //CONNECT (&playlist, sig_cur_played_info_changed(const MetaData&),   	&player,  		update_info(const MetaData&));
           CONNECT (playlist, sig_playlist_prepared(int, vector<MetaData>&), 		playlists,      save_playlist_as_custom(int, vector<MetaData>&));
           CONNECT (playlist, sig_playlist_prepared(QString, vector<MetaData>&), 	playlists,      save_playlist_as_custom(QString, vector<MetaData>&));
           CONNECT (playlist, sig_library_changed(), 								ui_library, 	library_changed());
           CONNECT (playlist, sig_import_files(const vector<MetaData>&), 			library, 		importFiles(const vector<MetaData>&));
           CONNECT (playlist, sig_need_more_radio(),								lastfm, 		psl_radio_playlist_request());
           CONNECT (playlist, sig_radio_active(int),								player,         set_radio_active(int));
           CONNECT (playlist, sig_radio_active(int),								ui_playlist,	set_radio_active(int));

           // Can be done inside player
           CONNECT (playlist, sig_radio_active(int),								ui_playlist_chooser, set_radio_active(int));

           CONNECT (playlist, sig_data_for_id3_change(const vector<MetaData>&), 	ui_id3_editor,	change_meta_data(const vector<MetaData>&)); // IND

           CONNECT (ui_playlist, selected_row_changed(int), 					playlist, 	psl_change_track(int));
           CONNECT (ui_playlist, clear_playlist(),                              playlist, 	psl_clear_playlist());
           CONNECT (ui_playlist, playlist_mode_changed(const Playlist_Mode&),   playlist, 	psl_playlist_mode_changed(const Playlist_Mode&));
           CONNECT (ui_playlist, dropped_tracks(const vector<MetaData>&, int),  playlist, 	psl_insert_tracks(const vector<MetaData>&, int));
           CONNECT (ui_playlist, sound_files_dropped(QStringList&), 			playlist, 	psl_createPlaylist(QStringList&));
           CONNECT (ui_playlist, directory_dropped(const QString&, int),		playlist, 	psl_directoryDropped(const QString &, int ));
           CONNECT (ui_playlist, rows_removed(const QList<int>&),               playlist, 	psl_remove_rows(const QList<int>&));
           CONNECT (ui_playlist, sig_import_to_library(bool),					playlist,	psl_import_new_tracks_to_library(bool));

           CONNECT (listen, track_finished(),                                   playlist,	psl_next_track() );
           CONNECT (listen, sig_valid_strrec_track(const MetaData&),            playlist,  psl_valid_strrec_track(const MetaData&));
           CONNECT (listen, scrobble_track(const MetaData&),                    lastfm, 	psl_scrobble(const MetaData&));

           // should be sent to player
           CONNECT (listen, eq_presets_loaded(const vector<EQ_Setting>&),       ui_eq,	fill_eq_presets(const vector<EQ_Setting>&));
           CONNECT (listen, eq_found(const QStringList&),                       ui_eq, 	fill_available_equalizers(const QStringList&));

           CONNECT (listen, total_time_changed_signal(qint64),                  player,	total_time_changed(qint64));
           CONNECT (listen, timeChangedSignal(quint32),                         player,	setCurrentPosition(quint32) );

           CONNECT(library, sig_playlist_created(QStringList&), 			playlist, 		psl_createPlaylist(QStringList&));
           CONNECT(library, sig_import_result(bool),						playlist,		psl_import_result(bool));
           CONNECT(library, sig_import_result(bool),						ui_playlist,	import_result(bool));
           CONNECT(library, sig_reload_library_finished(),                  ui_library, 	reloading_library_finished());
           CONNECT(library, sig_reloading_library(QString&),				ui_library, 	reloading_library(QString&));
           CONNECT(library, sig_import_result(bool),						ui_library,	import_result(bool));
           CONNECT(library, sig_metadata_loaded(vector<MetaData>&), 		ui_library, 	fill_library_tracks(vector<MetaData>&));
           CONNECT(library, sig_all_albums_loaded(vector<Album>&),          ui_library, 	fill_library_albums(vector<Album>&));
           CONNECT(library, sig_all_artists_loaded(vector<Artist>&), 		ui_library, 	fill_library_artists(vector<Artist>&));
           CONNECT(library, sig_track_mime_data_available(const vector<MetaData>&), 		ui_library, 	track_info_available(const vector<MetaData>&));
           CONNECT(library, sig_tracks_for_playlist_available(vector<MetaData>&),           playlist, psl_createPlaylist(vector<MetaData>&));
           CONNECT(library, sig_import_result(bool),						playlists,		import_result(bool));
           CONNECT(library, sig_delete_answer(QString), 					ui_library, 	psl_delete_answer(QString));
           CONNECT(library, sig_play_next_tracks(const vector<MetaData>&),  playlist,		psl_play_next_tracks(const vector<MetaData>&));

           if(ui_id3_editor)
               CONNECT(library, sig_change_id3_tags(const vector<MetaData>&),	ui_id3_editor,	change_meta_data(const vector<MetaData>&)); // IND

           CONNECT(ui_library, sig_album_dbl_clicked(), 						library, 		psl_prepare_album_for_playlist());
           CONNECT(ui_library, sig_artist_dbl_clicked(), 						library, 		psl_prepare_artist_for_playlist());
           CONNECT(ui_library, sig_track_dbl_clicked(int),                      library, 		psl_prepare_track_for_playlist(int));
           CONNECT(ui_library, sig_artist_pressed(const QList<int>&),           library, 		psl_selected_artists_changed(const QList<int>&));
           CONNECT(ui_library, sig_album_pressed(const QList<int>&),            library, 		psl_selected_albums_changed(const QList<int>&));
           CONNECT(ui_library, sig_track_pressed(const QList<int>&),            library, 		psl_selected_tracks_changed(const QList<int>&));
           CONNECT(ui_library, sig_filter_changed(const Filter&),               library, 		psl_filter_changed(const Filter&));

           CONNECT(ui_library, sig_sortorder_changed(Sort::ArtistSort, Sort::AlbumSort, Sort::TrackSort),
                   library, 	 psl_sortorder_changed(Sort::ArtistSort, Sort::AlbumSort, Sort::TrackSort));

           CONNECT(ui_library, sig_show_id3_editor(const QList<int>&),              library, 		psl_change_id3_tags(const QList<int>&));
           CONNECT(ui_library, sig_delete_tracks(int),                              library,		psl_delete_tracks(int));
           CONNECT(ui_library, sig_delete_certain_tracks(const QList<int>&, int),	library,		psl_delete_certain_tracks(const QList<int>&, int));
           CONNECT(ui_library, sig_play_next_tracks(const QList<int>&),             library,		psl_play_next_tracks(const QList<int>&));
           CONNECT(ui_library, sig_play_next_all_tracks(),                          library,		psl_play_next_all_tracks());


           CONNECT(ui_lastfm, sig_activated(bool), player, psl_lfm_activated(bool));
           CONNECT(ui_lastfm, sig_activated(bool), ui_playlist, psl_lfm_activated(bool));
           CONNECT(ui_lastfm, new_lfm_credentials(QString, QString), 		lastfm, 		psl_login(QString, QString));


           CONNECT(ui_eq, eq_changed_signal(int, int),                          listen, 	eq_changed(int, int));
           CONNECT(ui_eq, eq_enabled_signal(bool),                              listen, 	eq_enable(bool));
           CONNECT(ui_eq, close_event(),                                        player, 	close_eq());


           CONNECT(ui_playlist, edit_id3_signal(),                                  playlist, 		psl_edit_id3_request());

           CONNECT(ui_id3_editor, id3_tags_changed(), 							ui_library, 	id3_tags_changed());
           CONNECT(ui_id3_editor, id3_tags_changed(vector<MetaData>&), 			playlist, 		psl_id3_tags_changed(vector<MetaData>&));
           CONNECT(ui_id3_editor, id3_tags_changed(vector<MetaData>&), 			player, 		psl_id3_tags_changed(vector<MetaData>&));


           CONNECT(lastfm,	sig_similar_artists_available(const QList<int>&),		playlist,		psl_similar_artists_available(const QList<int>&));
           CONNECT(lastfm,	sig_last_fm_logged_in(bool),							ui_playlist,	last_fm_logged_in(bool));
           CONNECT(lastfm,	sig_last_fm_logged_in(bool),							player,		last_fm_logged_in(bool));
           CONNECT(lastfm,	sig_new_radio_playlist(const vector<MetaData>&),		playlist,		psl_new_radio_playlist_available(const vector<MetaData>&));
           CONNECT(lastfm, sig_track_info_fetched(const MetaData&, bool, bool),     player,		lfm_info_fetched(const MetaData&, bool, bool));

           CONNECT(ui_playlist_chooser, sig_playlist_chosen(int),		playlists, load_single_playlist(int));
           CONNECT(ui_playlist_chooser, sig_delete_playlist(int),       playlists, delete_playlist(int));
           CONNECT(ui_playlist_chooser, sig_save_playlist(int), 		playlist, 	psl_prepare_playlist_for_save(int));
           CONNECT(ui_playlist_chooser, sig_save_playlist(QString), 	playlist, 	psl_prepare_playlist_for_save(QString));
           CONNECT(ui_playlist_chooser, sig_clear_playlist(),           playlist, 	psl_clear_playlist());
           CONNECT(ui_playlist_chooser, sig_closed(),                   player, 	close_playlist_chooser());

           CONNECT(playlists, sig_single_playlist_loaded(CustomPlaylist&),      playlist, 				psl_createPlaylist(CustomPlaylist&));
           CONNECT(playlists, sig_all_playlists_loaded(QMap<int, QString>&), 	ui_playlist_chooser, 	all_playlists_fetched(QMap<int, QString>&));
           CONNECT(playlists, sig_import_tracks(const vector<MetaData>&),       library, 				importFiles(const vector<MetaData>&));


            CONNECT(ui_lfm_radio, listen_clicked(const QString&, int),          lastfm,		psl_radio_init(const QString&, int));
            CONNECT(ui_lfm_radio, close_event(), 								player, 	close_lfm_radio());

            CONNECT(ui_stream, sig_play_stream(const QString&, const QString&), 	playlist, 	psl_play_stream(const QString&, const QString&));
            CONNECT(ui_stream, sig_close_event(), 									player, 	close_stream());


           CONNECT (ui_stream_rec, sig_stream_recorder_active(bool),	listen,		psl_strrip_set_active(bool));
           CONNECT (ui_stream_rec, sig_stream_recorder_active(bool),	player,     psl_strrip_set_active(bool));
           CONNECT (ui_stream_rec, sig_path_changed(const QString&), 	listen,		psl_strrip_set_path(const QString& ));
           CONNECT (ui_stream_rec, sig_complete_tracks(bool),           listen,		psl_strrip_complete_tracks(bool));
           CONNECT (ui_stream_rec, sig_create_playlist(bool),           listen,		psl_strrip_set_create_playlist(bool ));


           bool is_socket_active = set->getSocketActivated();
           if(is_socket_active){
               CONNECT (remote_socket, sig_play(),		playlist,			psl_play());
               CONNECT (remote_socket, sig_next(),		playlist,			psl_forward());
               CONNECT (remote_socket, sig_prev(),		playlist,			psl_backward());
               CONNECT (remote_socket, sig_stop(),		playlist,			psl_stop());
               CONNECT (remote_socket, sig_pause(),		listen,				pause());
               CONNECT (remote_socket, sig_setVolume(int),player,			setVolume(int));

               remote_socket->start();
           }
}
/*
 * quaff:
 *	Quaff a potion from the pack
 */
quaff()
{
    register THING *obj, *th;
    register bool discardit = FALSE;

    obj = get_item("quaff", POTION);
    /*
     * Make certain that it is somethings that we want to drink
     */
    if (obj == NULL)
	return;
    if (obj->o_type != POTION)
    {
	if (!terse)
	    msg("yuk! Why would you want to drink that?");
	else
	    msg("that's undrinkable");
	return;
    }
    if (obj == cur_weapon)
	cur_weapon = NULL;

    /*
     * Calculate the effect it has on the poor guy.
     */
    switch (obj->o_which)
    {
	case P_CONFUSE:
	    p_know[P_CONFUSE] = TRUE;
	    if (!on(player, ISHUH))
	    {
		if (on(player, ISHUH))
		    lengthen(unconfuse, rnd(8)+HUHDURATION);
		else
		    fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
		player.t_flags |= ISHUH;
		msg("wait, what's going on here. Huh? What? Who?");
	    }
	when P_POISON:
	    p_know[P_POISON] = TRUE;
	    if (!ISWEARING(R_SUSTSTR))
	    {
		chg_str(-(rnd(3)+1));
		msg("you feel very sick now");
	    }
	    else
		msg("you feel momentarily sick");
	when P_HEALING:
	    p_know[P_HEALING] = TRUE;
	    if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
		pstats.s_hpt = ++max_hp;
	    sight();
	    msg("you begin to feel better");
	when P_STRENGTH:
	    p_know[P_STRENGTH] = TRUE;
	    chg_str(1);
	    msg("you feel stronger, now.  What bulging muscles!");
	when P_MFIND:
	    player.t_flags |= SEEMONST;
	    fuse(turn_see, TRUE, HUHDURATION, AFTER);
	    if (mlist == NULL)
		msg("you have a strange feeling for a moment");
	    else
		p_know[P_MFIND] |= turn_see(FALSE);
	when P_TFIND:
	    /*
	     * Potion of magic detection.  Show the potions and scrolls
	     */
	    if (lvl_obj != NULL)
	    {
		register THING *tp;
		register bool show;

		show = FALSE;
		wclear(hw);
		for (tp = lvl_obj; tp != NULL; tp = next(tp))
		{
		    if (is_magic(tp))
		    {
			show = TRUE;
			mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
			p_know[P_TFIND] = TRUE;
		    }
		}
		for (th = mlist; th != NULL; th = next(th))
		{
		    for (tp = th->t_pack; tp != NULL; tp = next(tp))
		    {
			if (is_magic(tp))
			{
			    show = TRUE;
			    mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
			    p_know[P_TFIND] = TRUE;
			}
		    }
		}
		if (show)
		{
		    show_win(hw, 
			"You sense the presence of magic on this level.--More--");
		    break;
		}
	    }
	    msg("you have a strange feeling for a moment, then it passes");
	when P_PARALYZE:
	    p_know[P_PARALYZE] = TRUE;
	    no_command = HOLDTIME;
	    player.t_flags &= ~ISRUN;
	    msg("you can't move");
	when P_SEEINVIS:
	    if (!on(player, CANSEE))
	    {
		fuse(unsee, 0, SEEDURATION, AFTER);
		look(FALSE);
		invis_on();
	    }
	    sight();
	    msg("this potion tastes like %s juice", fruit);
	when P_RAISE:
	    p_know[P_RAISE] = TRUE;
	    msg("you suddenly feel much more skillful");
	    raise_level();
	when P_XHEAL:
	    p_know[P_XHEAL] = TRUE;
	    if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
	    {
		if (pstats.s_hpt > max_hp + pstats.s_lvl + 1)
		    ++max_hp;
		pstats.s_hpt = ++max_hp;
	    }
	    sight();
	    msg("you begin to feel much better");
	when P_HASTE:
	    p_know[P_HASTE] = TRUE;
	    if (add_haste(TRUE))
		msg("you feel yourself moving much faster");
	when P_RESTORE:
	    if (ISRING(LEFT, R_ADDSTR))
		add_str(&pstats.s_str, -cur_ring[LEFT]->o_ac);
	    if (ISRING(RIGHT, R_ADDSTR))
		add_str(&pstats.s_str, -cur_ring[RIGHT]->o_ac);
	    if (pstats.s_str < max_stats.s_str)
		pstats.s_str = max_stats.s_str;
	    if (ISRING(LEFT, R_ADDSTR))
		add_str(&pstats.s_str, cur_ring[LEFT]->o_ac);
	    if (ISRING(RIGHT, R_ADDSTR))
		add_str(&pstats.s_str, cur_ring[RIGHT]->o_ac);
	    msg("hey, this tastes great.  It make you feel warm all over");
	when P_BLIND:
	    p_know[P_BLIND] = TRUE;
	    if (!on(player, ISBLIND))
	    {
		player.t_flags |= ISBLIND;
		fuse(sight, 0, SEEDURATION, AFTER);
		look(FALSE);
	    }
	    msg("a cloak of darkness falls around you");
	when P_NOP:
	    msg("this potion tastes extremely dull");
	otherwise:
	    msg("what an odd tasting potion!");
	    return;
    }
    status();
    /*
     * Throw the item away
     */
    inpack--;
    if (obj->o_count > 1)
	obj->o_count--;
    else
    {
	detach(pack, obj);
        discardit = TRUE;
    }

    call_it(p_know[obj->o_which], &p_guess[obj->o_which]);

    if (discardit)
	discard(obj);
}
示例#7
0
read_scroll()
{
    register struct object *obj;
    register struct linked_list *item;
    register struct room *rp;
    register int i,j;
    register char ch, nch;
    register struct linked_list *titem;
    char buf[80];

    item = get_item("run", SCROLL);
    if (item == NULL)
	return;
    obj = (struct object *) ldata(item);
    if (obj->o_type != SCROLL)
    {
	if (!terse)
	    msg("There is no way to run it");
	else
	    msg("Nothing to run");
	return;
    }
    msg("As you run the device, it self-destructs.");
    /*
     * Calculate the effect it has on the poor guy.
     */
    if (obj == cur_weapon)
	cur_weapon = NULL;
    switch(obj->o_which)
    {
	when S_CONFUSE:
	    /*
	     * Scroll of monster confusion.  Give him that power.
	     */
	    msg("Your hands begin to glow red");
	    player.t_flags |= CANHUH;
	when S_LIGHT:
	    s_know[S_LIGHT] = TRUE;
	    if ((rp = roomin(&hero)) == NULL)
		msg("The corridor glows and then fades");
	    else
	    {
		addmsg("The room is lit");
		if (!terse)
		    addmsg(" by a shimmering blue light.");
		endmsg();
		rp->r_flags &= ~ISDARK;
		/*
		 * Light the room and put the player back up
		 */
		light(&hero);
		mvwaddch(cw, hero.y, hero.x, PLAYER);
	    }
	when S_ARMOR:
	    if (cur_armor != NULL)
	    {
		msg("Your armor glows faintly for a moment");
		cur_armor->o_ac--;
		cur_armor->o_flags &= ~ISCURSED;
	    }
	when S_HOLD:
	    /*
	     * Hold monster scroll.  Stop all monsters within two spaces
	     * from chasing after the hero.
	     */
	    {
		register int x,y;
		register struct linked_list *mon;

		for (x = hero.x-2; x <= hero.x+2; x++)
		    for (y = hero.y-2; y <= hero.y+2; y++)
			if (y > 0 && x > 0 && isupper(mvwinch(mw, y, x)))
			    if ((mon = find_mons(y, x)) != NULL)
			    {
				register struct thing *th;

				th = (struct thing *) ldata(mon);
				th->t_flags &= ~ISRUN;
				th->t_flags |= ISHELD;
			    }
	    }
	when S_SLEEP:
	    /*
	     * Scroll which makes you fall asleep
	     */
	    s_know[S_SLEEP] = TRUE;
	    msg("You fall asleep.");
	    no_command += 4 + rnd(SLEEPTIME);
	when S_CREATE:
	    /*
	     * Create a monster
	     * First look in a circle around him, next try his room
	     * otherwise give up
	     */
	    {
		register int x, y;
		register bool appear = 0;
		coord mp;

		/*
		 * Search for an open place
		 */
		for (y = hero.y; y <= hero.y+1; y++)
		    for (x = hero.x; x <= hero.x+1; x++)
		    {
			/*
			 * Don't put a monster in top of the player.
			 */
			if (y == hero.y && x == hero.x)
			    continue;
			/*
			 * Or anything else nasty
			 */
			if (step_ok(winat(y, x)))
			{
			    if (rnd(++appear) == 0)
			    {
				mp.y = y;
				mp.x = x;
			    }
			}
		    }
		if (appear)
		{
		    titem = new_item(sizeof (struct thing));
		    new_monster(titem, randmonster(FALSE), &mp);
		}
		else
		    msg("You hear a faint cry of anguish in the distance.");
	    }
	when S_IDENT:
	    /*
	     * Identify, let the rogue figure something out
	     */
	    msg("This nanodevice is an identify nanodevice");
	    s_know[S_IDENT] = TRUE;
	    whatis();
	when S_MAP:
	    /*
	     * Scroll of magic mapping.
	     */
	    s_know[S_MAP] = TRUE;
	    msg("Oh, now this nanodevice has a map on it.");
	    overwrite(stdscr, hw);
	    /*
	     * Take all the things we want to keep hidden out of the window
	     */
	    for (i = 0; i < lines(); i++)
		for (j = 0; j < cols(); j++)
		{
		    switch (nch = ch = mvwinch(hw, i, j))
		    {
			case SECRETDOOR:
			    mvaddch(i, j, nch = DOOR);
			case '-':
			case '|':
			case DOOR:
			case PASSAGE:
			case ' ':
			case STAIRS:
			    if (mvwinch(mw, i, j) != ' ')
			    {
				register struct thing *it;

				it = (struct thing *) ldata(find_mons(i, j));
				if (it->t_oldch == ' ')
				    it->t_oldch = nch;
			    }
			    break;
			default:
			    nch = ' ';
		    }
		    if (nch != ch)
			waddch(hw, nch);
		}
	    /*
	     * Copy in what he has discovered
	     */
	    overlay(cw, hw);
	    /*
	     * And set up for display
	     */
	    overwrite(hw, cw);
	when S_GFIND:
	    /*
	     * Potion of gold detection
	     */
	    {
		int gtotal = 0;

		wclear(hw);
		for (i = 0; i < MAXROOMS; i++)
		{
		    gtotal += rooms[i].r_goldval;
		    if (rooms[i].r_goldval != 0 &&
			mvwinch(stdscr, rooms[i].r_gold.y, rooms[i].r_gold.x)
			== GOLD)
			mvwaddch(hw,rooms[i].r_gold.y,rooms[i].r_gold.x,GOLD);
		}
		if (gtotal)
		{
		    s_know[S_GFIND] = TRUE;
		    show_win(hw,
			"You connect to the Net and detect credits locations.--More--");
		}
		else msg("You begin to feel a pull downward");
	    }
	when S_TELEP:
	    /*
	     * Scroll of teleportation:
	     * Make him dissapear and reappear
	     */
	    {
		int rm;
		struct room *cur_room;

		cur_room = roomin(&hero);
		rm = teleport();
		if (cur_room != &rooms[rm])
		    s_know[S_TELEP] = TRUE;
	    }
	when S_ENCH:
	    if (cur_weapon == NULL)
		msg("You feel a strange sense of loss.");
	    else
	    {
		cur_weapon->o_flags &= ~ISCURSED;
		if (rnd(100) > 50)
		    cur_weapon->o_hplus++;
		else
		    cur_weapon->o_dplus++;
		msg("Your %s glows blue for a moment.", w_names[cur_weapon->o_which]);
	    }
	when S_SCARE:
	    /*
	     * A monster will refuse to step on a scare monster scroll
	     * if it is dropped.  Thus reading it is a mistake and produces
	     * laughter at the poor rogue's boo boo.
	     */
	    msg("You hear maniacal laughter in the distance.");
	when S_REMOVE:
	    if (cur_armor != NULL)
		cur_armor->o_flags &= ~ISCURSED;
	    if (cur_weapon != NULL)
		cur_weapon->o_flags &= ~ISCURSED;
	    if (cur_ring[LEFT] != NULL)
		cur_ring[LEFT]->o_flags &= ~ISCURSED;
	    if (cur_ring[RIGHT] != NULL)
		cur_ring[RIGHT]->o_flags &= ~ISCURSED;
	    msg("You feel as if somebody is watching over you.");
	when S_AGGR:
	    /*
	     * This scroll aggravates all the monsters on the current
	     * level and sets them running towards the hero
	     */
	    aggravate();
	    msg("You hear a high pitched humming noise.");
	when S_NOP:
	    msg("This nanodevice seems to be empty.");
	when S_GENOCIDE:
	    msg("You have been granted the boon of genocide");
	    genocide();
	    s_know[S_GENOCIDE] = TRUE;
	otherwise:
	    msg("What a puzzling nanodevice!");
	    return;
    }
    look(TRUE);	/* put the result of the scroll on the screen */
    status();
    if (s_know[obj->o_which] && s_guess[obj->o_which])
    {
	cfree(s_guess[obj->o_which]);
	s_guess[obj->o_which] = NULL;
    }
    else if (!s_know[obj->o_which] && askme && s_guess[obj->o_which] == NULL)
    {
	msg(terse ? "Call it: " : "What do you want to call it? ");
	if (get_str(buf, cw) == NORM)
	{
	    s_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1);
	    strcpy(s_guess[obj->o_which], buf);
	}
    }
    /*
     * Get rid of the thing
     */
    inpack--;
    if (obj->o_count > 1)
	obj->o_count--;
    else
    {
	detach(pack, item);
        discard(item);
    }
}