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 ULTIMA4_GAME_ARMOR_H
24 #define ULTIMA4_GAME_ARMOR_H
25 
26 #include "ultima/ultima4/filesys/savegame.h"
27 #include "ultima/shared/std/containers.h"
28 #include "ultima/shared/std/string.h"
29 
30 namespace Ultima {
31 namespace Ultima4 {
32 
33 class ConfigElement;
34 class Armors;
35 
36 class Armor {
37 	friend class Armors;
38 public:
39 	// Getters
getType()40 	ArmorType getType() const {
41 		return _type;      /**< Returns the ArmorType of the armor */
42 	}
getName()43 	const Common::String &getName() const {
44 		return _name;      /**< Returns the name of the armor */
45 	}
getDefense()46 	int getDefense() const {
47 		return _defense;   /**< Returns the defense value of the armor */
48 	}
49 	/** Returns true if the class given can wear the armor */
canWear(ClassType klass)50 	bool canWear(ClassType klass) const {
51 		return _canUse & (1 << klass);
52 	}
53 
54 private:
55 	Armor(ArmorType armorType, const ConfigElement &conf);
56 
57 	ArmorType _type;
58 	Common::String _name;
59 	byte _canUse;
60 	int _defense;
61 	//unsigned short _mask;
62 };
63 
64 class Armors : public Std::vector<Armor *> {
65 private:
66 	void loadConf();
67 	bool _confLoaded;
68 public:
69 	/**
70 	 * Constructor
71 	 */
72 	Armors();
73 
74 	/**
75 	 * Destructor
76 	 */
77 	~Armors();
78 
79 	/**
80 	 * Returns armor by ArmorType.
81 	 */
82 	const Armor *get(ArmorType a);
83 
84 	/**
85 	 * Returns armor that has the given name
86 	 */
87 	const Armor *get(const Common::String &name);
88 };
89 
90 extern Armors *g_armors;
91 
92 } // End of namespace Ultima4
93 } // End of namespace Ultima
94 
95 #endif
96