Ejemplo n.º 1
0
void
changestats(bool ingameflag)
{
	static char flag[2] =	/* for printing values of bools */
	{ 'F', 'T' };
	struct player *playerp;	/* pointer to structure to alter */
	const char *prompt;	/* pointer to prompt string */
	int c;			/* input */
	int today;		/* day of year of today */
	int temp;		/* temporary variable */
	long loc;		/* location in player file */
	time_t now;		/* time now */
	double dtemp;		/* temporary variable */
	bool *bptr;		/* pointer to bool item to change */
	double *dptr;		/* pointer to double item to change */
	short *sptr;		/* pointer to short item to change */

	clear();

	for (;;) {
		/* get name of player to examine/alter */
		mvaddstr(5, 0, "Which character do you want to look at ? ");
		getstring(Databuf, SZ_DATABUF);
		truncstring(Databuf);

		if (Databuf[0] == '\0')
			userlist(ingameflag);
		else
			break;
	}

	loc = -1L;

	if (!ingameflag)
		/* use 'Player' structure */
		playerp = &Player;
	else if (strcmp(Databuf, Player.p_name) == 0) {
		/* alter/examine current player */
		playerp = &Player;
		loc = Fileloc;
	} else
		/* use 'Other' structure */
		playerp = &Other;

	/* find player on file */
	if (loc < 0L && (loc = findname(Databuf, playerp)) < 0L) {
		/* didn't find player */
		clear();
		mvaddstr(11, 0, "Not found.");
		return;
	}

	time(&now);
	today = localtime(&now)->tm_yday;

	clear();

	for (;;) {
		/* print player structure, and prompt for action */
		mvprintw(0, 0, "A:Name         %s\n", playerp->p_name);

		if (Wizard)
			printw("B:Password     %s\n", playerp->p_password);
		else
			addstr("B:Password     XXXXXXXX\n");

		printw(" :Login        %s\n", playerp->p_login);

		printw("C:Experience   %.0f\n", playerp->p_experience);
		printw("D:Level        %.0f\n", playerp->p_level);
		printw("E:Strength     %.0f\n", playerp->p_strength);
		printw("F:Sword        %.0f\n", playerp->p_sword);
		printw(" :Might        %.0f\n", playerp->p_might);
		printw("G:Energy       %.0f\n", playerp->p_energy);
		printw("H:Max-Energy   %.0f\n", playerp->p_maxenergy);
		printw("I:Shield       %.0f\n", playerp->p_shield);
		printw("J:Quickness    %.0f\n", playerp->p_quickness);
		printw("K:Quicksilver  %.0f\n", playerp->p_quksilver);
		printw(" :Speed        %.0f\n", playerp->p_speed);
		printw("L:Magic Level  %.0f\n", playerp->p_magiclvl);
		printw("M:Mana         %.0f\n", playerp->p_mana);
		printw("N:Brains       %.0f\n", playerp->p_brains);

		if (Wizard || playerp->p_specialtype != SC_VALAR)
			mvaddstr(0, 40, descrstatus(playerp));

		mvprintw(1, 40, "O:Poison       %0.3f\n", playerp->p_poison);
		mvprintw(2, 40, "P:Gold         %.0f\n", playerp->p_gold);
		mvprintw(3, 40, "Q:Gem          %.0f\n", playerp->p_gems);
		mvprintw(4, 40, "R:Sin          %0.3f\n", playerp->p_sin);
		if (Wizard) {
			mvprintw(5, 40, "S:X-coord      %.0f\n", playerp->p_x);
			mvprintw(6, 40, "T:Y-coord      %.0f\n", playerp->p_y);
		} else {
			mvaddstr(5, 40, "S:X-coord      ?\n");
			mvaddstr(6, 40, "T:Y-coord      ?\n");
		}

		mvprintw(7, 40, "U:Age          %ld\n", playerp->p_age);
		mvprintw(8, 40, "V:Degenerated  %d\n", playerp->p_degenerated);

		mvprintw(9, 40, "W:Type         %d (%s)\n",
		    playerp->p_type, descrtype(playerp, FALSE) + 1);
		mvprintw(10, 40, "X:Special Type %d\n", playerp->p_specialtype);
		mvprintw(11, 40, "Y:Lives        %d\n", playerp->p_lives);
		mvprintw(12, 40, "Z:Crowns       %d\n", playerp->p_crowns);
		mvprintw(13, 40, "0:Charms       %d\n", playerp->p_charms);
		mvprintw(14, 40, "1:Amulets      %d\n", playerp->p_amulets);
		mvprintw(15, 40, "2:Holy Water   %d\n", playerp->p_holywater);

		temp = today - playerp->p_lastused;
		if (temp < 0)
			/* last year */
			temp += 365;
		mvprintw(16, 40, "3:Lastused     %d  (%d)\n", playerp->p_lastused, temp);

		mvprintw(18, 8, "4:Palantir %c  5:Blessing %c  6:Virgin %c  7:Blind %c",
		    flag[playerp->p_palantir],
		    flag[playerp->p_blessing],
		    flag[playerp->p_virgin],
		    flag[playerp->p_blindness]);

		if (!Wizard)
			mvprintw(19, 8, "8:Ring    %c",
			    flag[playerp->p_ring.ring_type != R_NONE]);
		else
			mvprintw(19, 8, "8:Ring    %d  9:Duration %d",
			    playerp->p_ring.ring_type, playerp->p_ring.ring_duration);

		if (!Wizard
		    && (ingameflag || strcmp(Login, playerp->p_login) != 0)) {
			/* in game or not examining own character */
			if (ingameflag) {
				more(LINES - 1);
				clear();
				return;
			} else
				cleanup(TRUE);
			/* NOTREACHED */
		}

		mvaddstr(20, 0, "!:Quit       ?:Delete");
		mvaddstr(21, 0, "What would you like to change ? ");

		if (Wizard)
			c = getanswer(" ", TRUE);
		else
			/* examining own player; allow to change name and password */
			c = getanswer("!BA", FALSE);

		switch (c) {
		case 'A':	/* change name */
		case 'B':	/* change password */
			if (!Wizard) {
				/* prompt for password */
				mvaddstr(23, 0, "Password ? ");
				Echo = FALSE;
				getstring(Databuf, 9);
				Echo = TRUE;
				if (strcmp(Databuf, playerp->p_password) != 0)
					continue;
			}
			if (c == 'A') {
				/* get new name */
				mvaddstr(23, 0, "New name: ");
				getstring(Databuf, SZ_NAME);
				truncstring(Databuf);
				if (Databuf[0] != '\0')
					if (Wizard || findname(Databuf, &Other) < 0L)
						strcpy(playerp->p_name, Databuf);
			} else {
				/* get new password */
				if (!Wizard)
					Echo = FALSE;

				do {
					/* get two copies of new password until they match */
					/* get first copy */
					mvaddstr(23, 0, "New password ? ");
					getstring(Databuf, SZ_PASSWORD);
					if (Databuf[0] == '\0')
						break;

					/* get second copy */
					mvaddstr(23, 0, "One more time ? ");
					getstring(playerp->p_password, SZ_PASSWORD);
				} while (strcmp(playerp->p_password, Databuf) != 0);

				Echo = TRUE;
			}

			continue;

		case 'C':	/* change experience */
			prompt = "experience";
			dptr = &playerp->p_experience;
			goto DALTER;

		case 'D':	/* change level */
			prompt = "level";
			dptr = &playerp->p_level;
			goto DALTER;

		case 'E':	/* change strength */
			prompt = "strength";
			dptr = &playerp->p_strength;
			goto DALTER;

		case 'F':	/* change swords */
			prompt = "sword";
			dptr = &playerp->p_sword;
			goto DALTER;

		case 'G':	/* change energy */
			prompt = "energy";
			dptr = &playerp->p_energy;
			goto DALTER;

		case 'H':	/* change maximum energy */
			prompt = "max energy";
			dptr = &playerp->p_maxenergy;
			goto DALTER;

		case 'I':	/* change shields */
			prompt = "shield";
			dptr = &playerp->p_shield;
			goto DALTER;

		case 'J':	/* change quickness */
			prompt = "quickness";
			dptr = &playerp->p_quickness;
			goto DALTER;

		case 'K':	/* change quicksilver */
			prompt = "quicksilver";
			dptr = &playerp->p_quksilver;
			goto DALTER;

		case 'L':	/* change magic */
			prompt = "magic level";
			dptr = &playerp->p_magiclvl;
			goto DALTER;

		case 'M':	/* change mana */
			prompt = "mana";
			dptr = &playerp->p_mana;
			goto DALTER;

		case 'N':	/* change brains */
			prompt = "brains";
			dptr = &playerp->p_brains;
			goto DALTER;

		case 'O':	/* change poison */
			prompt = "poison";
			dptr = &playerp->p_poison;
			goto DALTER;

		case 'P':	/* change gold */
			prompt = "gold";
			dptr = &playerp->p_gold;
			goto DALTER;

		case 'Q':	/* change gems */
			prompt = "gems";
			dptr = &playerp->p_gems;
			goto DALTER;

		case 'R':	/* change sin */
			prompt = "sin";
			dptr = &playerp->p_sin;
			goto DALTER;

		case 'S':	/* change x coord */
			prompt = "x";
			dptr = &playerp->p_x;
			goto DALTER;

		case 'T':	/* change y coord */
			prompt = "y";
			dptr = &playerp->p_y;
			goto DALTER;

		case 'U':	/* change age */
			mvprintw(23, 0, "age = %ld; age = ", playerp->p_age);
			dtemp = infloat();
			if (dtemp != 0.0)
				playerp->p_age = (long)dtemp;
			continue;

		case 'V':	/* change degen */
			mvprintw(23, 0, "degen = %d; degen = ", playerp->p_degenerated);
			dtemp = infloat();
			if (dtemp != 0.0)
				playerp->p_degenerated = (int)dtemp;
			continue;

		case 'W':	/* change type */
			prompt = "type";
			sptr = &playerp->p_type;
			goto SALTER;

		case 'X':	/* change special type */
			prompt = "special type";
			sptr = &playerp->p_specialtype;
			goto SALTER;

		case 'Y':	/* change lives */
			prompt = "lives";
			sptr = &playerp->p_lives;
			goto SALTER;

		case 'Z':	/* change crowns */
			prompt = "crowns";
			sptr = &playerp->p_crowns;
			goto SALTER;

		case '0':	/* change charms */
			prompt = "charm";
			sptr = &playerp->p_charms;
			goto SALTER;

		case '1':	/* change amulet */
			prompt = "amulet";
			sptr = &playerp->p_amulets;
			goto SALTER;

		case '2':	/* change holy water */
			prompt = "holy water";
			sptr = &playerp->p_holywater;
			goto SALTER;

		case '3':	/* change last-used */
			prompt = "last-used";
			sptr = &playerp->p_lastused;
			goto SALTER;

		case '4':	/* change palantir */
			prompt = "palantir";
			bptr = &playerp->p_palantir;
			goto BALTER;

		case '5':	/* change blessing */
			prompt = "blessing";
			bptr = &playerp->p_blessing;
			goto BALTER;

		case '6':	/* change virgin */
			prompt = "virgin";
			bptr = &playerp->p_virgin;
			goto BALTER;

		case '7':	/* change blindness */
			prompt = "blindness";
			bptr = &playerp->p_blindness;
			goto BALTER;

		case '8':	/* change ring type */
			prompt = "ring-type";
			sptr = &playerp->p_ring.ring_type;
			goto SALTER;

		case '9':	/* change ring duration */
			prompt = "ring-duration";
			sptr = &playerp->p_ring.ring_duration;
			goto SALTER;

		case '!':	/* quit, update */
			if (Wizard &&
			    (!ingameflag || playerp != &Player)) {
				/* turn off status if not modifying self */
				playerp->p_status = S_OFF;
				playerp->p_tampered = T_OFF;
			}

			writerecord(playerp, loc);
			clear();
			return;

		case '?':	/* delete player */
			if (ingameflag && playerp == &Player)
				/* cannot delete self */
				continue;

			freerecord(playerp, loc);
			clear();
			return;

		default:
			continue;
		}
DALTER:
		mvprintw(23, 0, "%s = %f; %s = ", prompt, *dptr, prompt);
		dtemp = infloat();
		if (dtemp != 0.0)
			*dptr = dtemp;
		continue;

SALTER:
		mvprintw(23, 0, "%s = %d; %s = ", prompt, *sptr, prompt);
		dtemp = infloat();
		if (dtemp != 0.0)
			*sptr = (short)dtemp;
		continue;

BALTER:
		mvprintw(23, 0, "%s = %c; %s = ", prompt, flag[*bptr],
		    prompt);
		c = getanswer("\nTF", TRUE);
		if (c == 'T')
			*bptr = TRUE;
		else if (c == 'F')
			*bptr = FALSE;
		continue;
	}
}
Ejemplo n.º 2
0
void
neatstuff(void)
{
	double temp;	/* for temporary calculations */
	int ch;		/* input */

	switch ((int)ROLL(0.0, 100.0)) {
	case 1:
	case 2:
		if (Player.p_poison > 0.0) {
			mvaddstr(4, 0, "You've found a medic!  How much will you offer to be cured ? ");
			temp = floor(infloat());
			if (temp < 0.0 || temp > Player.p_gold) {
				/* negative gold, or more than available */
				mvaddstr(6, 0, "He was not amused, and made you worse.\n");
				Player.p_poison += 1.0;
			} else if (drandom() / 2.0 > (temp + 1.0) / MAX(Player.p_gold, 1))
				/* medic wants 1/2 of available gold */
				mvaddstr(5, 0, "Sorry, he wasn't interested.\n");
			else {
				mvaddstr(5, 0, "He accepted.");
				Player.p_poison = MAX(0.0, Player.p_poison - 1.0);
				Player.p_gold -= temp;
			}
		}
		break;

	case 3:
		mvaddstr(4, 0, "You've been caught raping and pillaging!\n");
		Player.p_experience += 4000.0;
		Player.p_sin += 0.5;
		break;

	case 4:
		temp = ROLL(10.0, 75.0);
		mvprintw(4, 0, "You've found %.0f gold pieces, want them ? ", temp);
		ch = getanswer("NY", FALSE);

		if (ch == 'Y')
			collecttaxes(temp, 0.0);
		break;

	case 5:
		if (Player.p_sin > 1.0) {
			mvaddstr(4, 0, "You've found a Holy Orb!\n");
			Player.p_sin -= 0.25;
		}
		break;

	case 6:
		if (Player.p_poison < 1.0) {
			mvaddstr(4, 0, "You've been hit with a plague!\n");
			Player.p_poison += 1.0;
		}
		break;

	case 7:
		mvaddstr(4, 0, "You've found some holy water.\n");
		++Player.p_holywater;
		break;

	case 8:
		mvaddstr(4, 0, "You've met a Guru. . .");
		if (drandom() * Player.p_sin > 1.0)
			addstr("You disgusted him with your sins!\n");
		else if (Player.p_poison > 0.0) {
			addstr("He looked kindly upon you, and cured you.\n");
			Player.p_poison = 0.0;
		} else {
			addstr("He rewarded you for your virtue.\n");
			Player.p_mana += 50.0;
			Player.p_shield += 2.0;
		}
		break;

	case 9:
		mvaddstr(4, 0, "You've found an amulet.\n");
		++Player.p_amulets;
		break;

	case 10:
		if (Player.p_blindness) {
			mvaddstr(4, 0, "You've regained your sight!\n");
			Player.p_blindness = FALSE;
		}
		break;

	default:		/* deal with poison */
		if (Player.p_poison > 0.0) {
			temp = Player.p_poison * Statptr->c_weakness
			    * Player.p_maxenergy / 600.0;
			if (Player.p_energy > Player.p_maxenergy / 10.0
			    && temp + 5.0 < Player.p_energy)
				Player.p_energy -= temp;
		}
		break;
	}
}