1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ULTIMA_ULTIMA1_CORE_PARTY_H
24 #define ULTIMA_ULTIMA1_CORE_PARTY_H
25 
26 #include "ultima/shared/core/party.h"
27 #include "ultima/ultima1/spells/blink.h"
28 #include "ultima/ultima1/spells/create.h"
29 #include "ultima/ultima1/spells/destroy.h"
30 #include "ultima/ultima1/spells/kill_magic_missile.h"
31 #include "ultima/ultima1/spells/ladder_down.h"
32 #include "ultima/ultima1/spells/ladder_up.h"
33 #include "ultima/ultima1/spells/open_unlock.h"
34 #include "ultima/ultima1/spells/prayer.h"
35 #include "ultima/ultima1/spells/steal.h"
36 
37 namespace Ultima {
38 namespace Ultima1 {
39 
40 enum WeaponType {
41 	WEAPON_HANDS = 0, WEAPON_DAGGER = 1, WEAPON_MACE = 2, WEAPON_AXE = 3, WEAPON_ROPE_SPIKES = 4,
42 	WEAPON_SWORD = 5, WEAPON_GREAT_SWORD = 6, WEAPON_BOW_ARROWS = 7, WEAPON_AMULET = 8,
43 	WEAPON_WAND = 9, WEAPON_STAFF = 10, WEAPON_TRIANGLE = 11, WEAPON_PISTOL = 12,
44 	WEAPON_LIGHT_SWORD = 13, WEAPON_PHAZOR = 14, WEAPON_BLASTER = 15
45 };
46 
47 enum ArmorType {
48 	ARMOR_SKIN = 0, ARMOR_LEATHER_armour = 1, ARMOR_CHAIN_MAIL = 2, ARMOR_PLATE_MAIL = 3,
49 	ARMOR_VACUUM_SUIT = 4, ARMOR_REFLECT_SUIT = 5
50 };
51 
52 class Ultima1Game;
53 class Character;
54 
55 /**
56  * Derived weapon class
57  */
58 class Weapon : public Shared::Weapon {
59 private:
60 	Ultima1Game *_game;
61 	Character *_character;
62 	WeaponType _type;
63 public:
64 	/**
65 	 * Constructor
66 	 */
67 	Weapon(Ultima1Game *game, Character *c, WeaponType weaponType);
68 
69 	/**
70 	 * Change the quantity by a given amount
71 	 */
changeQuantity(int delta)72 	void changeQuantity(int delta) override {
73 		if (_type != WEAPON_HANDS)
74 			_quantity = (uint)CLIP((int)_quantity + delta, 0, 9999);
75 	}
76 
77 	/**
78 	 * Gets the magic damage a given weapon does
79 	 */
80 	uint getMagicDamage() const;
81 
82 	/**
83 	 * Gets how much the weapon can be bought for
84 	 */
85 	uint getBuyCost() const;
86 
87 	/**
88 	 * Gets how much the weapon can sell for
89 	 */
90 	uint getSellCost() const;
91 };
92 
93 /**
94  * Derived armor class
95  */
96 class Armour : public Shared::Armour {
97 private:
98 //	Ultima1Game *_game;
99 	Character *_character;
100 	ArmorType _type;
101 public:
102 	/**
103 	 * Constructor
104 	 */
105 	Armour(Ultima1Game *game, Character *c, ArmorType armorType);
106 
107 	/**
108 	 * Change the quantity by a given amount
109 	 */
changeQuantity(int delta)110 	void changeQuantity(int delta) override {
111 		if (_type != ARMOR_SKIN)
112 			_quantity = (uint)CLIP((int)_quantity + delta, 0, 9999);
113 	}
114 
115 	/**
116 	 * Gets how much the weapon can be bought for
117 	 */
118 	uint getBuyCost() const;
119 
120 	/**
121 	 * Gets how much the weapon can sell for
122 	 */
123 	uint getSellCost() const;
124 };
125 
126 
127 /**
128  * Implements the data for a playable character within the game
129  */
130 class Character : public Shared::Character {
131 private:
132 //	Ultima1Game *_game;
133 
134 	Weapon _weaponHands;
135 	Weapon _weaponDagger;
136 	Weapon _weaponMace;
137 	Weapon _weaponAxe;
138 	Weapon _weaponRopeSpikes;
139 	Weapon _weaponSword;
140 	Weapon _weaponGreatSword;
141 	Weapon _weaponBowArrows;
142 	Weapon _weaponAmulet;
143 	Weapon _weaponWand;
144 	Weapon _weaponStaff;
145 	Weapon _weaponTriangle;
146 	Weapon _weaponPistol;
147 	Weapon _weaponLightSword;
148 	Weapon _weaponPhazor;
149 	Weapon _weaponBlaster;
150 
151 	Armour _armourSkin;
152 	Armour _armourLeatherArmor;
153 	Armour _armourChainMail;
154 	Armour _armourPlateMail;
155 	Armour _armourVacuumSuit;
156 	Armour _armourReflectSuit;
157 
158 	Spells::Blink _spellBlink;
159 	Spells::Create _spellCreate;
160 	Spells::Destroy _spellDestroy;
161 	Spells::Kill _spellKill;
162 	Spells::LadderDown _spellLadderDown;
163 	Spells::LadderUp _spellLadderUp;
164 	Spells::MagicMissile _spellMagicMissile;
165 	Spells::Open _spellOpen;
166 	Spells::Prayer _spellPrayer;
167 	Spells::Steal _spellSteal;
168 	Spells::Unlock _spellUnlock;
169 public:
170 	/**
171 	 * Constructor
172 	 */
173 	Character(Ultima1Game *game);
~Character()174 	virtual ~Character() {}
175 
176 	/**
177 	 * Setup the party
178 	 */
179 	void setup();
180 
181 	/**
182 	 * Return the equipped weapon
183 	 */
equippedWeapon()184 	Weapon *equippedWeapon() const { return static_cast<Weapon *>(_weapons[_equippedWeapon]); }
185 
186 	/**
187 	 * Return the equipped armor
188 	 */
equippedArmour()189 	Armour *equippedArmour() const { return static_cast<Armour *>(_armour[_equippedArmour]); }
190 
191 	/**
192 	 * Return the equipped spell
193 	 */
equippedSpell()194 	Spells::Spell *equippedSpell() const { return static_cast<Spells::Spell *>(_spells[_equippedSpell]); }
195 };
196 
197 /**
198  * Implements the party
199  */
200 class Party : public Shared::Party {
201 public:
202 	/**
203 	 * Constructor
204 	 */
205 	Party(Ultima1Game *game);
206 
207 	/**
208 	 * Setup the party
209 	 */
210 	void setup();
211 
212 	/**
213 	 * Operator casting
214 	 */
215 	operator Character *() const { return static_cast<Character *>(_characters.front()); }
216 
217 	/**
218 	 * Operator casting
219 	 */
220 	operator Character &() const { return *static_cast<Character *>(_characters.front()); }
221 };
222 
223 } // End of namespace Ultima1
224 } // End of namespace Ultima
225 
226 #endif
227