1 /*
2 * armour.h
3 * Copyright (C) 2009-2011, 2012 Joachim de Groot <jdegroot@web.de>
4 *
5 * NLarn is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * NLarn is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef __ARMOUR_H_
20 #define __ARMOUR_H_
21
22 #include "effects.h"
23 #include "items.h"
24 #include "utils.h"
25
26 typedef enum _armour_class
27 {
28 AC_BOOTS,
29 AC_CLOAK,
30 AC_GLOVES,
31 AC_HELMET,
32 AC_SHIELD,
33 AC_SUIT,
34 AC_MAX
35 } armour_class;
36
37 typedef enum _armour_t
38 {
39 AT_CLOAK,
40 AT_LGLOVES,
41 AT_LBOOTS,
42 AT_LHELMET,
43 AT_LEATHER,
44 AT_WSHIELD,
45 AT_SLEATHER,
46 AT_RINGMAIL,
47 AT_LSHIELD,
48 AT_CHAINHOOD,
49 AT_CHAINMAIL,
50 AT_SPLINTMAIL,
51 AT_PHELMET,
52 AT_PBOOTS,
53 AT_SPEEDBOOTS,
54 AT_PLATEMAIL,
55 AT_SSHIELD,
56 AT_SPLATEMAIL,
57 AT_INVISCLOAK,
58 AT_ELVENCHAIN,
59 AT_MAX
60 } armour_t;
61
62 typedef struct _armour_data
63 {
64 armour_t id;
65 const char *name;
66 int ac;
67 armour_class category;
68 item_material_t material;
69 effect_t et; /* for uniques: effect on the item */
70 int weight; /* used to determine inventory weight */
71 int price; /* base price in the shops */
72 armour_t disguise; /* item used for description until armour type is identified */
73 unsigned
74 obtainable: 1, /* available in the shop? */
75 unique: 1; /* generated only once */
76 } armour_data;
77
78 /* external vars */
79
80 extern const armour_data armours[AT_MAX];
81
82 /* inline functions */
armour_effect(item * armour)83 static inline effect_t armour_effect(item *armour)
84 {
85 g_assert(armour->id < AT_MAX);
86 return armours[armour->id].et;
87 }
88
armour_disguise(item * armour)89 static inline armour_t armour_disguise(item *armour)
90 {
91 g_assert(armour->id < AT_MAX);
92 return armours[armour->id].disguise;
93 }
94
armour_unique(item * armour)95 static inline gboolean armour_unique(item *armour)
96 {
97 g_assert(armour->id < AT_MAX);
98 return armours[armour->id].unique;
99 }
100
armour_base_ac(item * armour)101 static inline guint armour_base_ac(item *armour)
102 {
103 g_assert(armour->id < AT_MAX);
104 return armours[armour->id].ac;
105 }
106
armour_ac(item * armour)107 static inline guint armour_ac(item *armour)
108 {
109 int ac = armour_base_ac(armour)
110 + item_condition_bonus(armour);
111
112 return (guint)max(ac, 0);
113 }
114
115 /* macros */
116
117 #define armour_name(armour) (armours[(armour)->id].name)
118 #define armour_class(armour) (armours[(armour)->id].category)
119 #define armour_material(armour) (armours[(armour)->id].material)
120 #define armour_weight(armour) (armours[(armour)->id].weight)
121 #define armour_price(armour) (armours[(armour)->id].price)
122
123 #endif
124