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 #include "quest.h"
22 #include "xfile.h"
23 #include "global.h"
24 #include "xgui.h"
25 
26 XQuest XQuest::quest;
27 
Store(XFile * f)28 void XQuest::Store(XFile * f)
29 {
30 	f->Write(&beelzvile_killed, sizeof(int));
31 	f->Write(&beelzvile_ordered, sizeof(int));
32 	f->Write(&hero_die, sizeof(int));
33 	f->Write(&hero_win, sizeof(int));
34 	f->Write(&orcs_killed, sizeof(int));
35 	f->Write(&total_orcs_killed, sizeof(int));
36 	f->Write(&guards_get_orc_slay, sizeof(int));
37 	f->Write(&yohjishiro_it_quest, sizeof(ITEM_TYPE));
38 	f->Write(&ahk_ulan_ordered, sizeof(int));
39 	f->Write(&ahk_ulan_killed, sizeof(int));
40 	f->Write(&ahk_ulan_quest);
41 	f->Write(&roderick_ordered);
42 	f->Write(&roderick_killed);
43 	f->Write(&roderick_quest);
44 	f->Write(&roderick_quest2);
45 	f->Write(&torin_quest);
46 }
47 
Restore(XFile * f)48 void XQuest::Restore(XFile * f)
49 {
50 	f->Read(&beelzvile_killed, sizeof(int));
51 	f->Read(&beelzvile_ordered, sizeof(int));
52 	f->Read(&hero_die, sizeof(int));
53 	f->Read(&hero_win, sizeof(int));
54 	f->Read(&orcs_killed, sizeof(int));
55 	f->Read(&total_orcs_killed, sizeof(int));
56 	f->Read(&guards_get_orc_slay, sizeof(int));
57 	f->Read(&yohjishiro_it_quest, sizeof(ITEM_TYPE));
58 	f->Read(&ahk_ulan_ordered, sizeof(int));
59 	f->Read(&ahk_ulan_killed, sizeof(int));
60 	f->Read(&ahk_ulan_quest);
61 	f->Read(&roderick_ordered);
62 	f->Read(&roderick_killed);
63 	f->Read(&roderick_quest);
64 	f->Read(&roderick_quest2);
65 	f->Read(&torin_quest);
66 }
67 
ShowQuests()68 void XQuest::ShowQuests()
69 {
70 	XGuiList list;
71 
72 	list.SetCaption(MSG_BROWN "### " MSG_YELLOW "Current Quests" MSG_BROWN " ###");
73 	int flag = 1;
74 	if (beelzvile_ordered && !beelzvile_killed)
75 	{
76 		list.AddItem(new XGuiItem_Text(
77 			"The Village Elder asked you to kill the demon who atttacks villagers "
78 			"and has occupied the caves to the west of the village.\n\n"));
79 		flag = 0;
80 	}
81 
82 	if (ahk_ulan_ordered)
83 	{
84 		list.AddItem(new XGuiItem_Text(
85 			"Gefeon asked you to kill Ahk-Ulan."));
86 		flag = 0;
87 	}
88 
89 	if (roderick_ordered)
90 	{
91 		list.AddItem(new XGuiItem_Text(
92 			"Ahk-Ulan asked you to kill Roderick."));
93 		flag = 0;
94 	}
95 
96 	if (roderick_quest == 1)
97 	{
98 		list.AddItem(new XGuiItem_Text(
99 			"Roderick, the King of Avanor has asked you to find an artifact called the 'Eye of Raa'"));
100 		flag = 0;
101 	}
102 
103 	if (roderick_quest2 == 1)
104 	{
105 		list.AddItem(new XGuiItem_Text(
106 			"Roderick, the King of Avanor has asked you to cleanse his family crypt."));
107 		flag = 0;
108 	}
109 
110 
111 	if (ahk_ulan_quest)
112 	{
113 		char buf[256];
114 		sprintf(buf, "Ahk-Ulan asked you to bring 3 parts of ancient machine. There are %d more parts left.", 4 - ahk_ulan_quest);
115 		list.AddItem(new XGuiItem_Text(buf));
116 		flag = 0;
117 	}
118 
119 	if (torin_quest == 1)
120 	{
121 		list.AddItem(new XGuiItem_Text(
122 			"Torin, the Dwarven King asked you to switch on gas pump at the bottom of gold mine."));
123 		flag = 0;
124 	}
125 
126 
127 
128 
129 	if (yohjishiro_it_quest != IT_UNKNOWN)
130 	{
131 		if (yohjishiro_it_quest == IT_RATTAIL)
132 			list.AddItem(new XGuiItem_Text("Yohjishiro asked you bring a rat tail."));
133 		else
134 			list.AddItem(new XGuiItem_Text("Yohjishiro asked you bring a bat wing."));
135 		flag = 0;
136 	}
137 
138 
139 
140 	if (flag)
141 	{
142 		list.AddItem(new XGuiItem_Text("You have no quests."));
143 	}
144 
145 	list.Run();
146 }
147 
148