1 /*
2 This file is part of "Avanor, the Land of Mystery" roguelike game
3 Home page: http://www.avanor.com/
4 Copyright (C) 2000-2003 Vadim Gaidukevich
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 #ifndef __XSCROLL_H
22 #define __XSCROLL_H
23 
24 #include "item.h"
25 #include "effect.h"
26 
27 enum SCROLL_NAME
28 {
29 	SCROLL_BURNING_HANDS,
30 	SCROLL_ICE_TOUCH,
31 	SCROLL_HEROISM,
32 	SCROLL_HEALING,
33 	SCROLL_POWER,
34 	SCROLL_IDENTIFY,
35 	SCROLL_MAGIC_ARROW,
36 	SCROLL_FIRE_BOLT,
37 	SCROLL_ICE_BOLT,
38 	SCROLL_LIGHTNING_BOLT,
39 	SCROLL_ACID_BOLT,
40 	SCROLL_SUMMON_MONSTER,
41 	SCROLL_CREATE_ITEM,
42 	SCROLL_CURE_DISEASE,
43 	SCROLL_CURE_POISON,
44 	SCROLL_BLINK,
45 	SCROLL_SELF_KNOWLEDGE,
46 	SCROLL_SEE_INVISIBLE,
47 	SCROLL_RECIPIE,
48 	SCROLL_RANDOM
49 };
50 
51 struct SCROLL_REC
52 {
SCROLL_RECSCROLL_REC53 	SCROLL_REC(char * rn, EFFECT eff, SCROLL_NAME scrn, int val, int rar) //generate scroll name
54 	{
55 		real_name = rn;
56 		effect = eff;
57 		scroll_name = scrn;
58 		identify = 0;
59 		value = val;
60 		total_value += rar;
61 		rarity = rar;
62 
63 		char * tmp = "euioa";
64 		int words = vRand() % 2 + 1;
65 		strcpy(name, "");
66 		for (int i = 0; i < words; i++)
67 		{
68 			int word_len = vRand() % (5 - words) + 3;
69 			for (int j = 0; j < word_len; j++)
70 			{
71 				char let[2] = "X"; //default letter;
72 				if (j % 2 == 0)
73 				{
74 					let[0] = tmp[vRand() % 5];
75 				} else
76 				{
77 					let[0] = (char)(vRand() % 26 + 'a');
78 				}
79 				strcat(name, let);
80 			}
81 			if (i < words - 1)
82 			{
83 				if(vRand() % 4 == 1)
84 				{
85 					strcat(name, "-");
86 				} else
87 				{
88 					strcat(name, " ");
89 				}
90 			}
91 		}
92 
93 	};
94 
95 	EFFECT effect;
96 	SCROLL_NAME scroll_name;
97 	int identify;
98 	char name[20];
99 	char * real_name;
100 	int value;
101 	int rarity;
102 
103 	void Store(XFile * f);
104 	void Restore(XFile * f);
105 	static int total_value;
106 	static int GetRandomDescription(SCROLL_NAME scrn);
107 };
108 
109 
110 class XScroll : public XItem
111 {
112 public:
113 	DECLARE_CREATOR(XScroll, XItem);
114 	XScroll(SCROLL_NAME _scrn = SCROLL_RANDOM);
XScroll(XScroll * copy)115 	XScroll(XScroll * copy):XItem((XItem*)copy) {descr = copy->descr; sc_name = copy->sc_name;}
MakeCopy()116 	virtual XObject * MakeCopy() { return new XScroll(this); }
117 	virtual int isIdentifed();
118 	virtual void Identify(int level);
119 	virtual void toString(char * buf);
120 	virtual int Compare(XObject * o);
121 	virtual int onRead(XCreature * cr);
122 	virtual void Store(XFile * f);
123 	virtual void Restore(XFile * f);
124 	static void StoreTable(XFile * f);
125 	static void RestoreTable(XFile * f);
126 	SCROLL_NAME sc_name;
127 protected:
128 	int descr;
129 };
130 
131 
132 #endif
133