@@ -200,7 +200,10 @@ def populate_non_wiki_item(self):
200
200
self .item_dict ["equipable_weapon" ] = False
201
201
self .item_dict ["incomplete" ] = True
202
202
203
- self .item_dict ["icon" ] = self .icons [self .item_id_str ]
203
+ try :
204
+ self .item_dict ["icon" ] = self .icons [self .item_id_str ]
205
+ except KeyError :
206
+ self .item_dict ["icon" ] = self .icons ["blank" ]
204
207
205
208
def populate_wiki_item (self ):
206
209
self .populate_from_cache_data ()
@@ -212,7 +215,10 @@ def populate_wiki_item(self):
212
215
self .item_dict ["equipable_by_player" ] = False
213
216
self .item_dict ["equipable_weapon" ] = False
214
217
215
- self .item_dict ["icon" ] = self .icons [self .item_id_str ]
218
+ try :
219
+ self .item_dict ["icon" ] = self .icons [self .item_id_str ]
220
+ except KeyError :
221
+ self .item_dict ["icon" ] = self .icons ["blank" ]
216
222
217
223
def populate_from_cache_data (self ):
218
224
"""Populate an item using raw cache data.
@@ -504,27 +510,37 @@ def populate_from_wiki_data_equipment(self) -> bool:
504
510
if attack_speed is not None :
505
511
self .item_dict ["weapon" ]["attack_speed" ] = infobox_cleaner .caller (attack_speed , "speed" )
506
512
else :
507
- print ( ">>> populate_from_wiki_data_equipment: No attack_speed" )
508
- exit ( 1 )
513
+ # If not present, set to 0
514
+ self . item_dict [ "weapon" ][ "attack_speed" ] = 0
509
515
510
516
# Weapon type
511
517
# Extract the CombatStyles template
512
518
infobox_combat_parser = WikitextTemplateParser (self .item_wikitext )
513
519
has_infobox = infobox_combat_parser .extract_infobox ("combatstyles" )
514
- if not has_infobox :
515
- # No combatstyles template found for the item!
516
- print ("populate_from_wiki_data_equipment: No combatstyles" )
517
- exit (1 )
518
520
519
- # Set the infobox bonuses template
520
- combat_template = infobox_combat_parser .template
521
- weapon_type = infobox_cleaner .caller (combat_template , "weapon_type" )
522
- self .item_dict ["weapon" ]["weapon_type" ] = weapon_type
523
- try :
524
- self .item_dict ["weapon" ]["stances" ] = self .weapon_stances [weapon_type ]
525
- except KeyError :
526
- print ("populate_from_wiki_data_equipment: Weapon type error" )
527
- exit (1 )
521
+ if has_infobox :
522
+ # There is a combatstyles infobox, parse it
523
+ # Set the infobox bonuses template
524
+ combat_template = infobox_combat_parser .template
525
+ weapon_type = infobox_cleaner .caller (combat_template , "weapon_type" )
526
+ weapon_type = weapon_type .lower ()
527
+ self .item_dict ["weapon" ]["weapon_type" ] = weapon_type
528
+ try :
529
+ self .item_dict ["weapon" ]["stances" ] = self .weapon_stances [weapon_type ]
530
+ except KeyError :
531
+ print ("populate_from_wiki_data_equipment: Weapon type error" )
532
+ exit (1 )
533
+
534
+ else :
535
+ # No combatstyles infobox, try get data from bonuses
536
+ weapon_type = self .extract_infobox_value (bonuses_template , "combatstyle" )
537
+ weapon_type = weapon_type .lower ()
538
+ self .item_dict ["weapon" ]["weapon_type" ] = weapon_type
539
+ try :
540
+ self .item_dict ["weapon" ]["stances" ] = self .weapon_stances [weapon_type ]
541
+ except KeyError :
542
+ print ("populate_from_wiki_data_equipment: Weapon type error" )
543
+ exit (1 )
528
544
529
545
# Finally, set the equipable_weapon property to true
530
546
self .item_dict ["equipable_weapon" ] = True
0 commit comments