#NEWLINE# def make_weapon_table( env , node ) : #NEWLINE# #INDENT# '\n    Utility method to create a table for weapons\n    ' #NEWLINE# table = nodes . table ( ) #NEWLINE# tgroup = nodes . tgroup ( cols = 7 ) #NEWLINE# table += tgroup #NEWLINE# for i in range ( 7 ) : #NEWLINE# #INDENT# colspec = nodes . colspec ( colwidth = 1 ) #NEWLINE# tgroup += colspec #NEWLINE# #UNINDENT# rows = [ ] #NEWLINE# thead = nodes . thead ( ) #NEWLINE# row_node = make_row ( 'weapon' , 'damage' , 'critical range' , 'critical damage' , 'damage types' , 'type' , 'weight class' ) #NEWLINE# thead += row_node #NEWLINE# tgroup += thead #NEWLINE# for item_entry in ( x for x in env . pyherc_context . items if any ( ( ( z in x [ 'item' ] . tags ) for z in [ 'weapon' , 'ammunition' ] ) ) ) : #NEWLINE# #INDENT# item = item_entry [ 'item' ] #NEWLINE# if ( item . weapon_data is not None ) : #NEWLINE# #INDENT# damage_str = str . join ( ' / ' , [ str ( x [ 0 ] ) for x in item . weapon_data . damage ] ) #NEWLINE# damage_types_str = str . join ( ' / ' , [ str ( x [ 1 ] ) for x in item . weapon_data . damage ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( item . ammunition_data is not None ) : #NEWLINE# #INDENT# damage_str = str . join ( ' / ' , [ str ( x [ 0 ] ) for x in item . ammunition_data . damage ] ) #NEWLINE# damage_types_str = str . join ( ' / ' , [ str ( x [ 1 ] ) for x in item . ammunition_data . damage ] ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'simple weapon' in item . tags ) : #NEWLINE# #INDENT# weapon_type = 'simple' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'martial weapon' in item . tags ) : #NEWLINE# #INDENT# weapon_type = 'martial' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'exotic weapon' in item . tags ) : #NEWLINE# #INDENT# weapon_type = 'exotic' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# weapon_type = ' ' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( 'light weapon' in item . tags ) : #NEWLINE# #INDENT# weapon_weight = 'light' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'one-handed' in item . tags ) : #NEWLINE# #INDENT# weapon_weight = 'one-handed' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'two-handed' in item . tags ) : #NEWLINE# #INDENT# weapon_weight = 'two-handed' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# weapon_weight = ' ' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( item . weapon_data is not None ) : #NEWLINE# #INDENT# row_node = make_row ( item . name , damage_str , item . weapon_data . critical_range , item . weapon_data . critical_damage , damage_types_str , weapon_type , weapon_weight ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( item . ammunition_data is not None ) : #NEWLINE# #INDENT# row_node = make_row ( item . name , damage_str , item . ammunition_data . critical_range , item . ammunition_data . critical_damage , damage_types_str , weapon_type , weapon_weight ) #NEWLINE# #UNINDENT# #UNINDENT# rows . append ( row_node ) #NEWLINE# #UNINDENT# tbody = nodes . tbody ( ) #NEWLINE# tbody . extend ( rows ) #NEWLINE# tgroup += tbody #NEWLINE# return table