Esempio n. 1
0
static int
is_pure(boolean talk)
{
    int purity;
    aligntyp original_alignment = u.ualignbase[A_ORIGINAL];

    if (wizard && talk) {
        if (u.ualign.type != original_alignment) {
            pline("You are currently %s instead of %s.",
                  align_str(u.ualign.type), align_str(original_alignment));
        } else if (u.ualignbase[A_CURRENT] != original_alignment) {
            pline("You have converted.");
        } else if (u.ualign.record < MIN_QUEST_ALIGN) {
            pline("You are currently %d and require %d.", u.ualign.record,
                  MIN_QUEST_ALIGN);
            if (yn_function("adjust?", ynchars, 'y') == 'y')
                u.ualign.record = MIN_QUEST_ALIGN;
        }
    }

    purity = (u.ualign.record >= MIN_QUEST_ALIGN &&
              u.ualign.type == original_alignment &&
              u.ualignbase[A_CURRENT] ==
              original_alignment) ? 1 : (u.ualignbase[A_CURRENT] !=
                                         original_alignment) ? -1 : 0;
    return purity;
}
Esempio n. 2
0
static void
convert_arg (char c)
{
        const char *str;

        switch (c) {

            case 'p':   str = plname;
                        break;
            case 'c':   str = (flags.female && urole.name.f) ?
                                urole.name.f : urole.name.m;
                        break;
            case 'r':   str = rank_of(u.ulevel, Role_switch, flags.female);
                        break;
            case 'R':   str = rank_of(MIN_QUEST_LEVEL, Role_switch,
                                flags.female);
                        break;
            case 's':   str = (flags.female) ? "sister" : "brother";
                        break;
            case 'S':   str = (flags.female) ? "daughter" : "son";
                        break;
            case 'l':   str = ldrname();
                        break;
            case 'i':   str = intermed();
                        break;
            case 'o':   str = the(artiname(urole.questarti));
                        break;
            case 'n':   str = neminame();
                        break;
            case 'g':   str = guardname();
                        break;
            case 'G':   str = align_gtitle(u.ualignbase[A_ORIGINAL]);
                        break;
            case 'H':   str = homebase();
                        break;
            case 'a':   str = align_str(u.ualignbase[A_ORIGINAL]);
                        break;
            case 'A':   str = align_str(u.ualign.type);
                        break;
            case 'd':   str = align_gname(u.ualignbase[A_ORIGINAL]);
                        break;
            case 'D':   str = align_gname(A_LAWFUL);
                        break;
            case 'C':   str = "chaotic";
                        break;
            case 'N':   str = "neutral";
                        break;
            case 'L':   str = "lawful";
                        break;
            case 'x':   str = Blind() ? "sense" : "see";
                        break;
            case 'Z':   str = dungeons[0].dname;
                        break;
            case '%':   str = "%";
                        break;
             default:   str = "";
                        break;
        }
        strcpy(cvt_buf, str);
}
Esempio n. 3
0
static const char *
convert_arg(char c)
{
    switch (c) {
    case 'p':
        return msg_from_string(u.uplname);
    case 'c':
        return (u.ufemale && urole.name.f) ? urole.name.f : urole.name.m;
    case 'r':
        return rank_of(u.ulevel, Role_switch, u.ufemale);
    case 'R':
        return rank_of(MIN_QUEST_LEVEL, Role_switch, u.ufemale);
    case 's':
        return (u.ufemale) ? "sister" : "brother";
    case 'S':
        return (u.ufemale) ? "daughter" : "son";
    case 'l':
    case 'n': {
        int i = c == 'l' ? urole.ldrnum : urole.neminum;;
        return msgcat(type_is_pname(&mons[i]) ? "" : "the ",
                      mons[i].mname);
    }
    case 'i':
        return urole.intermed;
    case 'o':
        return the(artiname(urole.questarti));
    case 'g':
        return mons[urole.guardnum].mname;
    case 'G':
        return align_gtitle(u.ualignbase[A_ORIGINAL]);
    case 'H':
        return urole.homebase;
    case 'a':
        return align_str(u.ualignbase[A_ORIGINAL]);
    case 'A':
        return align_str(u.ualign.type);
    case 'd':
        return align_gname(u.ualignbase[A_ORIGINAL]);
    case 'D':
        return align_gname(A_LAWFUL);
    case 'C':
        return "chaotic";
    case 'N':
        return "neutral";
    case 'L':
        return "lawful";
    case 'x':
        return Blind ? "sense" : "see";
    case 'Z':
        return msg_from_string(gamestate.dungeons[0].dname);
    case '%':
        return "%";
    default:
        return "";
    }
}
Esempio n. 4
0
static void describe_bg(int x, int y, int bg, char *buf)
{
    if (!bg)
	return;
    
    switch(bg) {
	case S_altar:
	    if (!In_endgame(&u.uz))
		sprintf(buf, "%s altar",
		    align_str(Amask2align(level->locations[x][y].altarmask & ~AM_SHRINE)));
	    else
		sprintf(buf, "aligned altar");
	    break;
	    
	case S_ndoor:
	    if (is_drawbridge_wall(x, y) >= 0)
		strcpy(buf,"open drawbridge portcullis");
	    else if ((level->locations[x][y].doormask & ~D_TRAPPED) == D_BROKEN)
		strcpy(buf,"broken door");
	    else
		strcpy(buf,"doorway");
	    break;
	    
	case S_cloud:
	    strcpy(buf, Is_airlevel(&u.uz) ? "cloudy area" : "fog/vapor cloud");
	    break;
	    
	default:
	    strcpy(buf, defexplain[bg]);
	    break;
    }
}
Esempio n. 5
0
/* show "welcome [back] to DynaHack" message at program startup */
static void welcome(
    boolean new_game)	/* false => restoring an old game */
{
    char buf[BUFSZ];
    boolean currentgend = Upolyd ? u.mfemale : flags.female;

    /*
     * The "welcome back" message always describes your innate form
     * even when polymorphed or wearing a helm of opposite alignment.
     * Alignment is shown unconditionally for new games; for restores
     * it's only shown if it has changed from its original value.
     * Sex is shown for new games except when it is redundant; for
     * restores it's only shown if different from its original value.
     */
    *buf = '\0';
    if (new_game || u.ualignbase[A_ORIGINAL] != u.ualignbase[A_CURRENT])
	sprintf(eos(buf), "%s", align_str(u.ualignbase[A_ORIGINAL]));
    if (!urole.name.f &&
	    (new_game ? (urole.allow & ROLE_GENDMASK) == (ROLE_MALE|ROLE_FEMALE) :
	     currentgend != u.initgend))
	sprintf(eos(buf), "%s", genders[currentgend].adj + 2);

    pline(new_game ? "%s,%s,欢迎来到LoongHack!  你是%s%s%s。"
		   : "%s,%s,%s%s%s,欢迎回到LoongHack!",
	  Hello(NULL), plname, buf, urace.adj,
	  (currentgend && urole.name.f) ? urole.name.f : urole.name.m + 2);

    if (*level->levname)
	pline("You named this level: %s.", level->levname);
}
Esempio n. 6
0
/* display a list of discovered artifacts; return their count */
int disp_artifact_discoveries(
    struct menulist *menu /* supplied by dodiscover() */
    )
{
    int i, m, otyp;
    char buf[BUFSZ];

    for (i = 0; i < NROFARTIFACTS; i++) {
	if (artidisco[i] == 0) break;	/* empty slot implies end of list */
	if (i == 0)
	    add_menuheading(menu, "Artifacts");
	m = artidisco[i];
	otyp = artilist[m].otyp;
	sprintf(buf, "  %s [%s %s]", artiname(m),
		align_str(artilist[m].alignment), simple_typename(otyp));
	add_menutext(menu, buf);
    }
    return i;
}
Esempio n. 7
0
void
ustatusline(void)
{
    const char *info = "";

    if (Sick) {
        info = msgcat(info, ", dying from");
        if (u.usick_type & SICK_VOMITABLE)
            info = msgcat(info, " food poisoning");
        if (u.usick_type & SICK_NONVOMITABLE) {
            if (u.usick_type & SICK_VOMITABLE)
                info = msgcat(info, " and");
            info = msgcat(info, " illness");
        }
    }
    if (Stoned)
        info = msgcat(info, ", solidifying");
    if (Slimed)
        info = msgcat(info, ", becoming slimy");
    if (Strangled)
        info = msgcat(info, ", being strangled");
    if (Vomiting)
        info = msgcat(info, ", nauseated");    /* !"nauseous" */
    if (Confusion)
        info = msgcat(info, ", confused");
    if (Blind) {
        info = msgcat(info, ", blind");
        if (u.ucreamed) {
            if ((long)u.ucreamed < Blinded || Blindfolded ||
                !haseyes(youmonst.data))
                info = msgcat(info, ", cover");
            info = msgcat(info, "ed by sticky goop");
        }       /* note: "goop" == "glop"; variation is intentional */
    }
    if (Stunned)
        info = msgcat(info, ", stunned");
    if (!u.usteed && Wounded_legs) {
        const char *what = body_part(LEG);

        if (LWounded_legs && RWounded_legs)
            what = makeplural(what);
        info = msgcat_many(info, ", injured ", what, NULL);
    }
    if (Glib)
        info = msgcat_many(info, ", slippery ",
                           makeplural(body_part(HAND)), NULL);
    if (u.utrap)
        info = msgcat(info, ", trapped");
    if (Fast)
        info = msgcat(info, Very_fast ? ", very fast" : ", fast");
    if (u.uundetected)
        info = msgcat(info, ", concealed");
    if (Invis)
        info = msgcat(info, ", invisible");
    if (u.ustuck) {
        if (sticks(youmonst.data))
            info = msgcat(info, ", holding ");
        else
            info = msgcat(info, ", held by ");
        info = msgcat(info, mon_nam(u.ustuck));
    }

    pline("Status of %s (%s%s):  Level %d  HP %d(%d)  Def %d%s.", u.uplname,
          (u.ualign.record >= 20) ? "piously " :
          (u.ualign.record > 13) ? "devoutly " :
          (u.ualign.record > 8) ? "fervently " :
          (u.ualign.record > 3) ? "stridently " :
          (u.ualign.record == 3) ? "" :
          (u.ualign.record >= 1) ? "haltingly " :
          (u.ualign.record == 0) ? "nominally " : "insufficiently ",
          align_str(u.ualign.type), Upolyd ? mons[u.umonnum].mlevel : u.ulevel,
          Upolyd ? u.mh : u.uhp, Upolyd ? u.mhmax : u.uhpmax,
          10 - get_player_ac(), info);
}
Esempio n. 8
0
void
mstatusline(struct monst *mtmp)
{
    aligntyp alignment;
    const char *info, *monnambuf;

    if (mtmp->ispriest || (mtmp->isminion && roamer_type(mtmp->data)))
        alignment = CONST_EPRI(mtmp)->shralign;
    else if (mtmp->isminion)
        alignment = EMIN(mtmp)->min_align;
    else {
        alignment = mtmp->data->maligntyp;
        alignment =
            (alignment > 0) ? A_LAWFUL :
            (alignment == A_NONE) ? A_NONE :
            (alignment < 0) ? A_CHAOTIC : A_NEUTRAL;
    }

    info = "";
    if (mtmp->mtame) {
        info = msgcat(info, ", tame");
        if (wizard) {
            info = msgprintf("%s (%d", info, mtmp->mtame);
            if (!mtmp->isminion)
                info = msgprintf("%s; hungry %u; apport %d", info,
                                 EDOG(mtmp)->hungrytime, EDOG(mtmp)->apport);
            info = msgcat(info, ")");
        }
    } else if (mtmp->mpeaceful)
        info = msgcat(info, ", peaceful");
    if (mtmp->meating)
        info = msgcat(info, ", eating");
    if (mtmp->mcan)
        info = msgcat(info, ", cancelled");
    if (mtmp->mconf)
        info = msgcat(info, ", confused");
    if (mtmp->mblinded || !mtmp->mcansee)
        info = msgcat(info, ", blind");
    if (mtmp->mstun)
        info = msgcat(info, ", stunned");
    if (mtmp->msleeping)
        info = msgcat(info, ", asleep");
    else if (mtmp->mfrozen || !mtmp->mcanmove)
        info = msgcat(info, ", can't move");
    /* [arbitrary reason why it isn't moving] */
    else if (mtmp->mstrategy & STRAT_WAITMASK)
        info = msgcat(info, ", meditating");
    else if (mtmp->mflee)
        info = msgcat(info, ", scared");
    if (mtmp->mtrapped)
        info = msgcat(info, ", trapped");
    if (mtmp->mspeed)
        info = msgcat(info,
                      mtmp->mspeed == MFAST ? ", fast" :
                      mtmp->mspeed == MSLOW ? ", slow" : ", ???? speed");
    if (mtmp->mundetected)
        info = msgcat(info, ", concealed");
    if (mtmp->minvis)
        info = msgcat(info, ", invisible");
    if (mtmp == u.ustuck)
        info = msgcat(info,
                      (sticks(youmonst.data)) ? ", held by you" : Engulfed
                      ? (is_animal(u.ustuck->data) ? ", swallowed you" :
                         ", engulfed you") : ", holding you");
    if (mtmp == u.usteed)
        info = msgcat(info, ", carrying you");

    /* avoid "Status of the invisible newt ..., invisible" */
    /* and unlike a normal mon_nam, use "saddled" even if it has a name */
    monnambuf = x_monnam(mtmp, ARTICLE_THE, NULL,
                         (SUPPRESS_IT | SUPPRESS_INVISIBLE), FALSE);

    pline("Status of %s (%s):  Level %d  HP %d(%d)  Def %d%s.", monnambuf,
          align_str(alignment), mtmp->m_lev, mtmp->mhp, mtmp->mhpmax,
          10 - find_mac(mtmp), info);
}
Esempio n. 9
0
/* smith-waterman alignment function */
int swalign (char seq1[], char seq2[], char bts1[], char bts2[], char aln[]) {

	int		mat[ MAXSEQ + 1 ][ MAXSEQ + 1 ]; // score matrix
	int		i, j;                            // matrix indices
	int		m, n;                            // sequences length
	char	btm[ MAXSEQ + 1 ][ MAXSEQ + 1 ]; // back trace mark
	int		d, u, l;                         // source score
	int		me, mi, mj;                      // max element and its indices
	int		bi;                              // back trace index, forward

	/* initialization the matrix */
	m = strlen( seq1 );
	n = strlen( seq2 );

	for ( i = 0; i <= m; i++ ) mat[i][0] = 0;
	for ( j = 0; j <= n; j++ ) mat[0][j] = 0;

	/* filling the matrix */
	for ( i = 1; i <= m; i ++ )
		for ( j = 1; j <= n; j++ ) {

			// diagonal
			d = mat[i-1][j-1] + score( seq1[i-1], seq2[j-1] ); 
			// up
			u = mat[i-1][j] + score( seq1[i-1], '-' ); 
			// left
			l = mat[i][j-1] + score( '-', seq2[j-1] );
			// find the max score
			mat[i][j] = max3( d, u, l );
			// mark the trace path
			btm[i][j] = mss( d, u, l );

		}

	/* back trace  */

	/*
	// print the back trace matrix
	for ( i = 0; i <= m; i++ ) {
		for ( j = 0; j <= n; j++ ) printf("%2d %c\t", mat[i][j], btm[i][j]);
		printf("\n");
	}
	*/
	
	// find max element and its indices
	me = 0;
	for ( i = 1; i <= m; i++ )
		for ( j = 1; j <= n; j++  ) {
			if ( mat[i][j] > me ) {
				me = mat[i][j];
				mi = i;
				mj = j;
			}
		}

	// back trace
	for ( i = mi, j = mj, bi = 0 ; i >= 0; bi++ )
		if ( btm[i][j] == '\\' ) {
			bts1[bi] = seq1[i - 1];
			bts2[bi] = seq2[j - 1];
			i--;
			j--;
		} else if ( btm[i][j] == '_')  {
			bts1[bi] = '-';
			bts2[bi] = seq2[j - 1];
			j--;
		} else if ( btm[i][j] == '|' ) {
			bts1[bi] = seq1[i - 1] ;
			bts2[bi] = '-';
			i--;
		} else {
			bts1[bi] = '\0';
			bts2[bi] = '\0';
			revseq(bts1);
			revseq(bts2);
			break;
		}

	// get aligment string
	align_str( bts1, bts2, aln );
	
	return me;

} // end of swalign