Add panels for different kinds of equipment
Closes #27, #28 and #33
... | ... |
@@ -123,6 +123,13 @@ |
123 | 123 |
[s/first-child {:font-weight :bold} |
124 | 124 |
(content-after ": ")]]) |
125 | 125 |
|
126 |
+(defclass regular-list [] |
|
127 |
+ {:padding-left 0} |
|
128 |
+ [:li {:list-style :inside |
|
129 |
+ :list-style-type "'* '"} |
|
130 |
+ [s/first-child {:font-weight :bold |
|
131 |
+ :margin-right :0.5rem}]]) |
|
132 |
+ |
|
126 | 133 |
(defclass equipment-panel [] |
127 | 134 |
{} |
128 | 135 |
title-style |
... | ... |
@@ -145,6 +145,12 @@ |
145 | 145 |
(defn- capacity [x] |
146 | 146 |
(some-> x :capacity)) |
147 | 147 |
|
148 |
+(defn- armor-class [x] |
|
149 |
+ (let [ac (-> x :armor_class)] |
|
150 |
+ (spaced (ac :base) |
|
151 |
+ (when (ac :dex_bonus) "+ Dex modifier") |
|
152 |
+ (when (ac :max_bonus) (parenthesize (str "max " (ac :max_bonus))))))) |
|
153 |
+ |
|
148 | 154 |
(defn- short-spell-description [spell] |
149 | 155 |
(spaced |
150 | 156 |
(-> spell :level ordinal) |
... | ... |
@@ -196,15 +202,65 @@ |
196 | 202 |
[:span at-higher-levels]])) |
197 | 203 |
[license-notice spell]]) |
198 | 204 |
|
199 |
-(defn equipment-panel [item] |
|
205 |
+ |
|
206 |
+(defn gear-panel [item] |
|
200 | 207 |
[:article {:class (styles/equipment-panel)} |
201 | 208 |
[heading item] |
202 | 209 |
[:span.kind |
203 | 210 |
(spaced |
204 | 211 |
(-> item :equipment_category :name) |
205 |
- (cond |
|
206 |
- (item :gear_category) (-> item :gear_category :name string/lower-case parenthesize) |
|
207 |
- (item :vehicle_category) (-> item :vehicle_category string/lower-case parenthesize)))] |
|
212 |
+ (-> item :gear_category :name string/lower-case parenthesize))] |
|
213 |
+ [property-list |
|
214 |
+ :Weight |
|
215 |
+ (weight item) |
|
216 |
+ :Cost |
|
217 |
+ (spaced |
|
218 |
+ (cost item) |
|
219 |
+ (some->> item :quantity (str "for ") parenthesize))] |
|
220 |
+ [description item] |
|
221 |
+ [license-notice item]]) |
|
222 |
+ |
|
223 |
+(defn pack-panel [pack] |
|
224 |
+ [:article {:class (styles/equipment-panel)} |
|
225 |
+ [heading pack] |
|
226 |
+ [:span.kind |
|
227 |
+ (spaced |
|
228 |
+ (-> pack :equipment_category :name) |
|
229 |
+ (-> pack :gear_category :name string/lower-case parenthesize))] |
|
230 |
+ [property-list |
|
231 |
+ :Cost (cost pack)] |
|
232 |
+ [:ul {:class (styles/regular-list)} |
|
233 |
+ (for [x (pack :contents)] |
|
234 |
+ ^{:key (-> x :item :url)} |
|
235 |
+ [:li |
|
236 |
+ [:span [code (-> x :item :name)]] |
|
237 |
+ (when (> (x :quantity) 1) |
|
238 |
+ [:span (-> x :quantity parenthesize)])])] |
|
239 |
+ [license-notice pack]]) |
|
240 |
+ |
|
241 |
+(defn tool-panel [item] |
|
242 |
+ [:article {:class (styles/equipment-panel)} |
|
243 |
+ [heading item] |
|
244 |
+ [:span.kind |
|
245 |
+ (spaced (-> item :equipment_category :name string/lower-case) |
|
246 |
+ (-> item :tool_category string/lower-case parenthesize))] |
|
247 |
+ [property-list |
|
248 |
+ :Weight |
|
249 |
+ (weight item) |
|
250 |
+ :Cost |
|
251 |
+ (spaced |
|
252 |
+ (cost item) |
|
253 |
+ (some->> item :quantity (str "for ") parenthesize))] |
|
254 |
+ [description item] |
|
255 |
+ [license-notice item]]) |
|
256 |
+ |
|
257 |
+(defn vehicle-panel [item] |
|
258 |
+ [:article {:class (styles/equipment-panel)} |
|
259 |
+ [heading item] |
|
260 |
+ [:span.kind |
|
261 |
+ (spaced |
|
262 |
+ (-> item :equipment_category :name string/lower-case) |
|
263 |
+ (-> item :vehicle_category string/lower-case parenthesize))] |
|
208 | 264 |
[property-list |
209 | 265 |
:Speed |
210 | 266 |
(speed item) |
... | ... |
@@ -213,12 +269,31 @@ |
213 | 269 |
:Weight |
214 | 270 |
(weight item) |
215 | 271 |
:Cost |
216 |
- (spaced |
|
217 |
- (cost item) |
|
218 |
- (some->> item :quantity (str "for ") parenthesize))] |
|
272 |
+ (cost item)] |
|
219 | 273 |
[description item] |
220 | 274 |
[license-notice item]]) |
221 | 275 |
|
276 |
+(defn armor-panel [armor] |
|
277 |
+ [:article {:class (styles/equipment-panel)} |
|
278 |
+ [heading armor] |
|
279 |
+ [:span.kind (spaced (-> armor :armor_category string/lower-case) "armor")] |
|
280 |
+ [property-list |
|
281 |
+ "Armor Class" |
|
282 |
+ (armor-class armor) |
|
283 |
+ :Strength |
|
284 |
+ (when (> (armor :str_minimum) 0) |
|
285 |
+ (str (armor :str_minimum) "+")) |
|
286 |
+ :Stealth |
|
287 |
+ (when (armor :stealth_disadvantage) |
|
288 |
+ "disadvantage") |
|
289 |
+ :Weight |
|
290 |
+ (weight armor) |
|
291 |
+ :Cost |
|
292 |
+ (cost armor)] |
|
293 |
+ |
|
294 |
+ [description armor] |
|
295 |
+ [license-notice armor]]) |
|
296 |
+ |
|
222 | 297 |
(defn weapon-panel [weapon] |
223 | 298 |
(let [weapon-kind (-> weapon :weapon_range string/lower-case) |
224 | 299 |
weapon-category (-> weapon :weapon_category string/lower-case)] |
... | ... |
@@ -246,6 +321,18 @@ |
246 | 321 |
(cost weapon)] |
247 | 322 |
[license-notice weapon]])) |
248 | 323 |
|
324 |
+ |
|
325 |
+(defn equipment-panel [item] |
|
326 |
+ (case (-> item :equipment_category :index keyword) |
|
327 |
+ :weapon [weapon-panel item] |
|
328 |
+ :armor [armor-panel item] |
|
329 |
+ :adventuring-gear (case (-> item :gear_category :index) |
|
330 |
+ "equipment-packs" [pack-panel item] |
|
331 |
+ [gear-panel item]) |
|
332 |
+ :tools [tool-panel item] |
|
333 |
+ :mounts-and-vehicles [vehicle-panel item])) |
|
334 |
+ |
|
335 |
+ |
|
249 | 336 |
(defn spell-list-panel [spells] |
250 | 337 |
[:article {:class (styles/spell-list-panel)} |
251 | 338 |
[heading "Spells"] |
... | ... |
@@ -295,9 +382,7 @@ |
295 | 382 |
(is-equipment-list? x) [equipment-list-panel x] |
296 | 383 |
(is-spell-list? x) [spell-list-panel x] |
297 | 384 |
(is-spell? x) (spell-panel x) |
298 |
- (is-equipment? x) (cond |
|
299 |
- (is-weapon? x) [weapon-panel x] |
|
300 |
- :else [equipment-panel x]) |
|
385 |
+ (is-equipment? x) [equipment-panel x] |
|
301 | 386 |
(is-error? x) [error-message x])]) |
302 | 387 |
|
303 | 388 |
(defn history [] |