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 __XBOOK_H 22 #define __XBOOK_H 23 24 #include "item.h" 25 #include "spelldef.h" 26 27 enum BOOK_NAME { 28 BOOK_BURNING_HANDS, 29 BOOK_ICE_TOUCH, 30 BOOK_CURE_LIGHT_WOUNDS, 31 BOOK_DRAIN_LIFE, 32 BOOK_IDENTIFY, 33 BOOK_MAGIC_ARROW, 34 BOOK_FIRE_BOLT, 35 BOOK_ICE_BOLT, 36 BOOK_LIGHTNING_BOLT, 37 BOOK_ACID_BOLT, 38 BOOK_CURE_DISEASE, 39 BOOK_CURE_POISON, 40 BOOK_BLINK, 41 BOOK_SELF_KNOWLEDGE, 42 BOOK_RANDOM 43 }; 44 45 struct BOOK_REC 46 { 47 BOOK_REC(int rarity, BOOK_NAME bn, SPELL_NAME sn); 48 int name_index; 49 BOOK_NAME book_name; 50 SPELL_NAME spell_name; 51 int identify; 52 int rarity; 53 54 void Store(XFile * f); 55 void Restore(XFile * f); 56 57 static int GetBook(BOOK_NAME); //number in array of books 58 59 static int current_descr; 60 static int total_value; 61 }; 62 63 class XBook:public XItem 64 { 65 public: 66 DECLARE_CREATOR(XBook, XItem) 67 XBook(BOOK_NAME bn = BOOK_RANDOM); XBook(XBook * copy)68 XBook(XBook * copy) : XItem((XItem*)copy) 69 { 70 descr = copy->descr; 71 reader_guid = copy->reader_guid; 72 left_to_read = copy->left_to_read; 73 } MakeCopy()74 virtual XObject * MakeCopy() { return new XBook(this); } 75 virtual int isIdentifed(); 76 virtual void Identify(int level); 77 virtual void toString(char * buf); 78 virtual int Compare(XObject * o); 79 virtual int onRead(XCreature * reader); 80 static void StoreTable(XFile * f); 81 static void RestoreTable(XFile * f); 82 virtual void Store(XFile * f); 83 virtual void Restore(XFile * f); 84 int left_to_read; 85 protected: 86 int descr; 87 XGUID reader_guid; 88 }; 89 90 #endif 91