⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 store.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/*- * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */#ifndef lintstatic char sccsid[] = "@(#)store.c	5.4 (Berkeley) 5/13/91";#endif /* not lint *//*	store.c		Larn is copyrighted 1986 by Noah Morgan. */#include "header.h"static int dndcount=0,dnditm=0;/*	this is the data for the stuff in the dnd store	*/int maxitm=83;	/* number of items in the dnd inventory table	*/struct _itm itm[90] = {/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{ 2,		0,		OLEATHER,		0,		3	},{ 10,		0,		OSTUDLEATHER,	0,		2	},{ 40,		0,		ORING,			0,		2	},{ 85,		0,		OCHAIN,			0,		2	},{ 220,		0,		OSPLINT,		0,		1	},{ 400,		0,		OPLATE,			0,		1	},{ 900,		0,		OPLATEARMOR,	0,		1	},{ 2600,		0,		OSSPLATE,		0,		1	},{ 150,		0,		OSHIELD,		0,		1	},/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{ 2,		0,		ODAGGER,		0,		3	},{ 20,		0,		OSPEAR,			0,		3	},{ 80,		0,		OFLAIL,			0,		2	},{ 150,		0,		OBATTLEAXE,		0,		2	},{ 450,		0,		OLONGSWORD,		0,		2	},{ 1000,		0,		O2SWORD,		0,		2	},{ 5000,		0,		OSWORD,			0,		1	},{ 16500,	0,		OLANCE,			0,		1	},{ 6000,		0,	 OSWORDofSLASHING,	0,		0	},{ 10000,	0,		OHAMMER,		0,		0	},/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{ 150,		0,		OPROTRING,		1,		1	},{ 85,		0,		OSTRRING,		1,		1	},{ 120,		0,		ODEXRING,		1,		1	},{ 120,		0,		OCLEVERRING,	1,		1	},{ 180,		0,		OENERGYRING,	0,		1	},{ 125,		0,		ODAMRING,		0,		1	},{ 220,		0,		OREGENRING,		0,		1	},{ 1000,		0,		ORINGOFEXTRA,	0,		1	},{ 280,		0,		OBELT,			0,		1	},{ 400,		0,		OAMULET,		0,		1	},{ 6500,		0,		OORBOFDRAGON,	0,		0	},{ 5500,		0,		OSPIRITSCARAB,	0,		0	},{ 5000,		0,		OCUBEofUNDEAD,	0,		0	},{ 6000,		0,		ONOTHEFT,		0,		0	},{ 590,		0,		OCHEST,			6,		1	},{ 200,		0,		OBOOK,			8,		1	},{ 10,		0,		OCOOKIE,		0,		3	},/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{	20,		potionname,	OPOTION,	0,		6	},{	90,		potionname,	OPOTION,	1,		5	},{	520,	potionname,	OPOTION,	2,		1	},{ 	100,	potionname,	OPOTION,	3,		2	},{	50,		potionname,	OPOTION,	4,		2	},{	150,	potionname,	OPOTION,	5,		2	},{	70,		potionname,	OPOTION,	6,		1	},{	30,		potionname,	OPOTION,	7,		7	},{	200,	potionname,	OPOTION,	8,		1	},{	50,		potionname,	OPOTION,	9,		1	},{	80,		potionname,	OPOTION,	10,		1	},/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{	30,		potionname,	OPOTION,	11,		3	},{	20,		potionname,	OPOTION,	12,		5	},{	40,		potionname,	OPOTION,	13,		3	},{	35,		potionname,	OPOTION,	14,		2	},{	520,	potionname,	OPOTION,	15,		1	},{	90,		potionname,	OPOTION,	16,		2	},{	200,	potionname,	OPOTION,	17,		2	},{	220,	potionname,	OPOTION,	18,		4	},{	80,		potionname,	OPOTION,	19,		6	},{	370,	potionname,	OPOTION,	20,		3	},{	50,		potionname,	OPOTION,	22,		1	},{	150,	potionname,	OPOTION,	23,		3	},/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{ 100,	scrollname,		OSCROLL,	0,		2	},{ 125,	scrollname,		OSCROLL,	1,		2	},{ 60,	scrollname,		OSCROLL,	2,		4	},{ 10,	scrollname,		OSCROLL,	3,		4	},{ 100,	scrollname,		OSCROLL,	4,		3	},{ 200,	scrollname,		OSCROLL,	5,		2	},{ 110,	scrollname,		OSCROLL,	6,		1	},{ 500,	scrollname,		OSCROLL,	7,		2	},{ 200,	scrollname,		OSCROLL,	8,		2	},{ 250,	scrollname,		OSCROLL,	9,		4	},{ 20,	scrollname,		OSCROLL,	10,		5	},{ 30,	scrollname,		OSCROLL,	11,		3	},/*cost	  memory 	iven name	iven arg   how  gp	 pointer	  iven[]	ivenarg[]  many */{ 340,	scrollname,		OSCROLL,	12,		1	},{ 340,	scrollname,		OSCROLL,	13,		1	},{ 300,	scrollname,		OSCROLL,	14,		2	},{ 400,	scrollname,		OSCROLL,	15,		2	},{ 500,	scrollname,		OSCROLL,	16,		2	},{ 1000,	scrollname,		OSCROLL,	17,		1	},{ 500,	scrollname,		OSCROLL,	18,		1	},{ 340,	scrollname,		OSCROLL,	19,		2	},{ 220,	scrollname,		OSCROLL,	20,		3	},{ 3900,	scrollname,		OSCROLL,	21,		0	},{ 610,	scrollname,		OSCROLL,	22,		1	},{ 3000,	scrollname,		OSCROLL,	23,		0	} };/*	function for the dnd store */dnd_2hed()    {	lprcat("Welcome to the Larn Thrift Shoppe.  We stock many items explorers find useful\n");	lprcat(" in their adventures.  Feel free to browse to your hearts content.\n");	lprcat("Also be advised, if you break 'em, you pay for 'em.");	}static void dnditem();dnd_hed()	{	register int i;	for (i=dnditm; i<26+dnditm; i++)	dnditem(i);	cursor(50,18); lprcat("You have ");	}static voidhandsfull(){	lprcat("\nYou can't carry anything more!");	lflush();	nap(2200);}static voidoutofstock(){	lprcat("\nSorry, but we are out of that item.");	lflush();	nap(2200);}static void nogold(){	lprcat("\nYou don't have enough gold to pay for that!");	lflush();	nap(2200);}dndstore()  {  register int i;  dnditm = 0;  nosignal = 1; /* disable signals */  clear();  dnd_2hed();  if (outstanding_taxes>0)	{	lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep();	lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes);	lprcat("comply with the law, we cannot serve you at this time.  Soo Sorry.\n");	cursors();		lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();	i=0;	while (i!='\33') i=getchar();	drawscreen();  nosignal = 0; /* enable signals */ return;	}  dnd_hed();  while (1)	{	cursor(59,18); lprintf("%d gold pieces",(long)c[GOLD]);	cltoeoln(); cl_dn(1,20);	/* erase to eod */	lprcat("\nEnter your transaction ["); standout("space");	lprcat(" for more, "); standout("escape");	lprcat(" to leave]? ");	i=0;	while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12))  i=getchar();	if (i==12) { clear();  dnd_2hed();  dnd_hed(); }	else if (i=='\33')		{ drawscreen();  nosignal = 0; /* enable signals */ return; }	else if (i==' ')		{		cl_dn(1,4);		if ((dnditm += 26) >= maxitm) dnditm=0; dnd_hed();		}	else		{  /* buy something */		lprc(i);	/* echo the byte */		i += dnditm - 'a';		if (i>=maxitm) outofstock(); else		if (itm[i].qty <= 0) outofstock(); else		if (pocketfull()) handsfull(); else		if (c[GOLD] < itm[i].price*10) nogold(); else			{			if (itm[i].mem != 0) *itm[i].mem[itm[i].arg] = ' ';			c[GOLD] -= itm[i].price*10;			itm[i].qty--;  take(itm[i].obj,itm[i].arg);			if (itm[i].qty==0) dnditem(i);  nap(1001);			}		}	}  }/*	dnditem(index)	to print the item list;  used in dndstore() enter with the index into itm */static voiddnditem(i)	register int i;	{	register int j,k;	if (i >= maxitm)  return;	cursor( (j=(i&1)*40+1) , (k=((i%26)>>1)+5) );	if (itm[i].qty == 0)  { lprintf("%39s","");  return; }	lprintf("%c) ",(i%26)+'a');	if (itm[i].obj == OPOTION)		{ lprcat("potion of "); lprintf("%s",&potionname[itm[i].arg][1]); }	else if (itm[i].obj == OSCROLL)		{ lprcat("scroll of "); lprintf("%s",&scrollname[itm[i].arg][1]); }	else lprintf("%s",objectname[itm[i].obj]);	cursor( j+31,k );  lprintf("%6d",(long)(itm[i].price*10));	}/*	for the college of larn */char course[26]={0};	/*	the list of courses taken	*/char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };/*	function to display the header info for the school */sch_hed()	{	clear();	lprcat("The College of Larn offers the exciting opportunity of higher education to\n");	lprcat("all inhabitants of the caves.  Here is a list of the class schedule:\n\n\n");	lprcat("\t\t    Course Name \t       Time Needed\n\n");	if (course[0]==0) lprcat("\t\ta)  Fighters Training I         10 mobuls"); /*line 7 of crt*/	lprc('\n');	if (course[1]==0) lprcat("\t\tb)  Fighters Training II        15 mobuls");	lprc('\n');	if (course[2]==0) lprcat("\t\tc)  Introduction to Wizardry    10 mobuls");	lprc('\n');	if (course[3]==0) lprcat("\t\td)  Applied Wizardry            20 mobuls");	lprc('\n');	if (course[4]==0) lprcat("\t\te)  Behavioral Psychology       10 mobuls");	lprc('\n');	if (course[5]==0) lprcat("\t\tf)  Faith for Today             10 mobuls");	lprc('\n');	if (course[6]==0) lprcat("\t\tg)  Contemporary Dance          10 mobuls");	lprc('\n');	if (course[7]==0) lprcat("\t\th)  History of Larn              5 mobuls");	lprcat("\n\n\t\tAll courses cost 250 gold pieces.");	cursor(30,18);	lprcat("You are presently carrying ");	}oschool()	{	register int i;	long time_used;	nosignal = 1; /* disable signals */	sch_hed();	while (1)		{		cursor(57,18); lprintf("%d gold pieces.   ",(long)c[GOLD]); cursors();		lprcat("\nWhat is your choice ["); standout("escape");		lprcat(" to leave] ? ");  yrepcount=0;		i=0;  while ((i<'a' || i>'h') && (i!='\33') && (i!=12)) i=getchar();		if (i==12) { sch_hed();  continue; }		else if (i=='\33')			{ nosignal = 0; drawscreen();  /* enable signals */ return; }		lprc(i);		if (c[GOLD] < 250)  nogold();  else		if (course[i-'a'])			{ lprcat("\nSorry, but that class is filled."); nap(1000); }		else		if (i <= 'h')			{			c[GOLD] -= 250; time_used=0;			switch(i)				{				case 'a':	c[STRENGTH] += 2;  c[CONSTITUTION]++;							lprcat("\nYou feel stronger!");							cl_line(16,7);							break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -