예제 #1
0
파일: loc.py 프로젝트: olympiag3/olymap
def write_loc_routes_out(v, data, outf):
    if u.return_type(v) != 'city':
        write_province_destinations(v, data, outf)
    else:
        header_printed = False
        host_prov = data[v['LI']['wh'][0]]
        # If city is in a mountain, can't move from city to ocean
        if u.return_type(host_prov) != 'mountain':
            dest_loc_list = host_prov['LO']['pd']
            i = int(0)
            for pd in dest_loc_list:
                try:
                    pd_loc = data[pd]
                    if u.return_type(pd_loc) == 'ocean':
                        if not header_printed:
                            outf.write('<H4>Routes leaving {}:</H4\n'.format(v['na'][0]))
                            outf.write('<ul>\n')
                        pd_name = pd_loc['na'][0]
                        pd_loc_id = u.return_unitid(pd_loc)
                        out_distance = u.calc_exit_distance(v, pd_loc)
                        outf.write('<li>{}, to {} [{}], {}, {} {}</li>\n'
                                   .format(pd_directions[i],
                                           pd_name,
                                           anchor(to_oid(pd_loc_id)),
                                           data[u.region(pd_loc_id, data)]['na'][0],
                                           out_distance,
                                           'day' if out_distance == 1 else 'days'))
                except KeyError:
                    pass
                i = i + 1
        if not header_printed:
            outf.write('<H4>Routes leaving {}:</H4\n'.format(v['na'][0]))
            outf.write('<ul>\n')
        out_distance = u.calc_exit_distance(v, host_prov)
        outf.write('<li>Out, to {} [{}], {} {}</li>\n'
                   .format(host_prov['na'][0],
                           anchor(to_oid(u.return_unitid(host_prov))),
                           out_distance,
                           'day' if out_distance == 1 else 'days'))
        if 'LI' in v:
            if 'hl' in v['LI']:
                here_list = v['LI']['hl']
                for here in here_list:
                    here_record = data[here]
                    if u.is_road_or_gate(here_record):
                        to_record = data[here_record['GA']['tl'][0]]
                        if u.return_kind(here_record) == 'gate':
                            name = 'Gate'
                        else:
                            name = here_record['na'][0]
                        if not header_printed:
                            outf.write('<H4>Routes leaving {}:</H4\n'.format(v['na'][0]))
                            outf.write('<ul>\n')
                        write_province_destination(v,
                                                   to_record,
                                                   name,
                                                   data,
                                                   outf)
        if header_printed:
            outf.write('</ul>\n')
예제 #2
0
파일: loc.py 프로젝트: pombredanne/olypy
def write_loc_controlled_by(v, data, outf):
    if 'LI' in v and 'hl' in v['LI']:
        here_list = v['LI']['hl']
        if len(here_list) > 0:
            for loc in here_list:
                try:
                    charac = data[loc]
                except KeyError:
                    pass
                else:
                    if 'MI' in charac and 'gc' in charac['MI']:
                        if charac['MI']['gc'][0] != '0':
                            dest_loc = data[charac['MI']['gc'][0]]
                            dest_loc2 = data[dest_loc['LI']['wh'][0]]
                            outf.write('<p>Province controlled by ')
                            dest_name = dest_loc['na'][0]
                            dest_id = anchor(to_oid(u.return_unitid(dest_loc)))
                            dest_type = u.return_type(dest_loc)
                            outf.write('{} [{}], {}'.format(
                                dest_name, dest_id, dest_type))
                            dest_type2 = u.return_type(dest_loc2)
                            if dest_type2 != 'city':
                                dest_name2 = dest_loc2['na'][0]
                                dest_id2 = anchor(
                                    to_oid(u.return_unitid(dest_loc2)))
                                outf.write(', in {} [{}]'.format(
                                    dest_name2, dest_id2))
                            else:
                                dest_loc2 = data[dest_loc2['LI']['wh'][0]]
                                dest_name2 = dest_loc2['na'][0]
                                dest_id2 = anchor(
                                    to_oid(u.return_unitid(dest_loc2)))
                                outf.write(', in {} [{}]'.format(
                                    dest_name2, dest_id2))
                            try:
                                garrison = data[dest_loc2['LI']['hl'][0]]
                            except KeyError:
                                pass
                            else:
                                garr_type = u.return_type(garrison)
                                if garr_type == 'garrison':
                                    # calculate top of pledge chain
                                    if 'LI' in dest_loc and 'hl' in dest_loc[
                                            'LI']:
                                        top_guy = u.top_ruler(
                                            dest_loc['LI']['hl'][0], data)
                                        try:
                                            top_dog = data[top_guy]
                                        except KeyError:
                                            pass
                                        else:
                                            a = top_dog['na'][0]
                                            b = anchor(to_oid(top_guy))
                                            outf.write(
                                                '<br>Ruled by {} [{}]'.format(
                                                    a, b))
                            outf.write('</p>\n')
예제 #3
0
파일: loc.py 프로젝트: pombredanne/olypy
def print_wearable_wielding(v, data, outf):
    attack_max = 0
    missile_max = 0
    defense_max = 0
    attack = ''
    missile = ''
    defense = ''
    if 'il' in v:
        item_list = v['il']
        if len(item_list) > 0:
            for items in range(0, len(item_list), 2):
                itemz = data[item_list[items]]
                if 'IM' in itemz:
                    if 'ab' in itemz['IM']:
                        if int(itemz['IM']['ab'][0]) > attack_max:
                            attack_max = int(itemz['IM']['ab'][0])
                            attack = u.return_unitid(itemz)
                    if 'mb' in itemz['IM']:
                        if int(itemz['IM']['mb'][0]) > missile_max:
                            missile_max = int(itemz['IM']['mb'][0])
                            missile = u.return_unitid(itemz)
                    if 'db' in itemz['IM']:
                        if int(itemz['IM']['db'][0]) > defense_max:
                            defense_max = int(itemz['IM']['db'][0])
                            defense = u.return_unitid(itemz)
        # found something
        if attack != '' or missile != '' or defense != '':
            if attack == missile:
                missile = ''
        if attack == defense:
            defense = ''
        if attack != '' or missile != '':
            if attack == '':
                missile_rec = data[missile]
                outf.write(', wielding {} [{}]'.format(
                    missile_rec['na'][0],
                    anchor(to_oid(u.return_unitid(missile_rec)))))
            elif missile == '':
                attack_rec = data[attack]
                outf.write(', wielding {} [{}]'.format(
                    attack_rec['na'][0],
                    anchor(to_oid(u.return_unitid(attack_rec)))))
            else:
                missile_rec = data[missile]
                attack_rec = data[attack]
                outf.write(', wielding {} [{}] and {} [{}]'.format(
                    attack_rec['na'][0],
                    anchor(to_oid(u.return_unitid(attack_rec))),
                    missile_rec['na'][0],
                    anchor(to_oid(u.return_unitid(missile_rec)))))
        if defense != '':
            defense_rec = data[defense]
            outf.write(', wearing {} [{}]'.format(
                defense_rec['na'][0],
                anchor(to_oid(u.return_unitid(defense_rec)))))
예제 #4
0
파일: loc.py 프로젝트: olympiag3/olymap
def write_ships(v, k, data, outf):
    outf.write('<li>\n')
    outf.write('{} [{}], {}'.format(v['na'][0],
                                    anchor(to_oid(k)),
                                    u.return_type(v)))
    if 'SL' in v:
        if 'bs' in v['SL']:
            storm = data[v['SL']['bs'][0]]
            if 'na' in storm:
                name = storm['na'][0]
            else:
                name = u.return_type(storm)
            outf.write(', bound {}-storm {} [{}] (strength: {})'.format(u.return_type(storm),
                                                                        name,
                                                                        anchor(to_oid(v['SL']['bs'][0])),
                                                                        storm['MI']['ss'][0]))
    if 'SL' in v:
        if 'de' in v['SL']:
            outf.write(', defense {}'.format(v['SL']['de'][0]))
        if 'eg' and 'er' in v['SL']:
            effort_given = int(v['SL']['eg'][0])
            effort_required = int(v['SL']['er'][0])
            pct_complete = int(float(effort_given / effort_required)*100)
            outf.write(', {}% completed'.format(pct_complete))
        if 'da' in v['SL']:
            outf.write(', {}% damaged'.format(v['SL']['da'][0]))
    pct_load = ship.calc_pct_loaded(data, k, v)
    if pct_load > 0:
        outf.write(', {}% loaded'.format(pct_load))
    if 'LI' in v and 'hl' in v['LI']:
        sub_here_list = v['LI']['hl']
        if len(sub_here_list) > 0:
            first_here = data[sub_here_list[0]]
            if u.return_kind(first_here) == 'char':
                outf.write(', owner:')
    outf.write('</li>\n')
    # see if stuff stacked under it
    if 'LI' in v and 'hl' in v['LI']:
        sub_here_list = v['LI']['hl']
        if len(sub_here_list) > 0:
            outf.write('<ul>\n')
            for sub_hl in sub_here_list:
                sub_sub_here = data[sub_hl]
                if u.return_kind(sub_sub_here) == 'loc':
                    write_sub_locs(v, sub_sub_here, sub_hl, data, outf)
                elif u.return_kind(sub_sub_here) == 'char':
                    write_characters(sub_sub_here,
                                     u.return_unitid(sub_sub_here),
                                     data, outf)
            outf.write('</ul>\n')
예제 #5
0
파일: ship.py 프로젝트: pombredanne/olypy
def write_ship_non_prominent(v, k, data, outf):
    seen_here_list = loop_here(data, k, False, True)
    list_length = len(seen_here_list)
    if list_length > 1:
        first_time = True
        printed_items = False
        for un in seen_here_list:
            unit_rec = data[un]
            if 'il' in unit_rec:
                item_list = unit_rec['il']
                for items in range(0, len(item_list), 2):
                    item_rec = data[item_list[items]]
                    if 'IT' in item_rec and 'pr' in item_rec[
                            'IT'] and item_rec['IT']['pr'][0] == '1':
                        pass
                    else:
                        if int(item_list[items + 1]) > 0:
                            weight = 0
                            qty = int(item_list[items + 1])
                            if 'wt' in item_rec['IT']:
                                weight = int(item_rec['IT']['wt'][0])
                            total_weight = int(qty * weight)
                            if first_time and total_weight > 0:
                                outf.write(
                                    '<p>Non-Prominent Items Onboard:</p>\n')
                                outf.write(
                                    '<table border="1" cellpadding="5">\n')
                                outf.write(
                                    '<tr><th>Possessor</th><th>Item</th><th>Qty</th><th>Weight</th></tr>'
                                )
                                first_time = False
                            if total_weight > 0:
                                printed_items = True
                                outf.write('<tr>')
                                outf.write('<td>{} [{}]</td>'.format(
                                    unit_rec['na'][0], anchor(to_oid(un))))
                                outf.write('<td>{} [{}]</td>'.format(
                                    item_rec['na'][0],
                                    anchor(to_oid(item_list[items]))))
                                outf.write(
                                    f'<td style="text-align:right">{qty:,d}</td>'
                                )
                                outf.write(
                                    f'<td style="text-align:right">{total_weight:,d}</td>'
                                )
                                outf.write('</tr>\n')
        if printed_items:
            outf.write('</table>\n')
예제 #6
0
def write_unit_list(data, outf, v):
    if 'PL' in v and 'un' in v['PL']:
        unit_list = v['PL']['un']
        unit_list.sort()
        outf.write('<tr><td valign="top">Unit List:</td><td>')
        outf.write('<table>\n')
        columns = int(math.ceil(len(unit_list) / 3))
        for unit in range(0, columns):
            outf.write('<tr>')
            if (columns * 0) + unit < len(unit_list):
                char = data[unit_list[(columns * 0) + unit]]
                if 'na' in char:
                    name = char['na'][0]
                else:
                    name = u.return_type(char).capitalize()
                if name == 'Ni':
                    name = data[char['CH']['ni'][0]]['na'][0].capitalize()
                outf.write('<td>{} [{}]</td>'.format(name,
                                                     anchor(to_oid(u.return_unitid(char)))))
            else:
                outf.write('<td></td>')
            if (columns * 1) + unit < len(unit_list):
                char = data[unit_list[(columns * 1) + unit]]
                if 'na' in char:
                    name = char['na'][0]
                else:
                    name = u.return_type(char).capitalize()
                if name == 'Ni':
                    name = data[char['CH']['ni'][0]]['na'][0].capitalize()
                outf.write('<td>{} [{}]</td>'.format(name,
                                                     anchor(to_oid(u.return_unitid(char)))))
            else:
                outf.write('<td></td><td></td>')
            if (columns * 2) + unit < len(unit_list):
                char = data[unit_list[(columns * 2) + unit]]
                if 'na' in char:
                    name = char['na'][0]
                else:
                    name = u.return_type(char).capitalize()
                if name == 'Ni':
                    name = data[char['CH']['ni'][0]]['na'][0].capitalize()
                outf.write('<td>{} [{}]</td>'.format(name,
                                                     anchor(to_oid(u.return_unitid(char)))))
            else:
                outf.write('<td></td><td></td>')
            outf.write('</tr>\n')
        outf.write('</table>\n')
        outf.write('</td></tr>')
예제 #7
0
파일: loc.py 프로젝트: olympiag3/olymap
def write_sub_locs(loc, sub_loc, k, data, outf):
    outf.write('<li>')
    outf.write('{} [{}], {}'.format(sub_loc['na'][0],
                                    anchor(to_oid(k)),
                                    u.return_type(sub_loc)))
    if 'LO' in sub_loc and 'hi' in sub_loc['LO']:
        outf.write(', hidden')
    out_distance = u.calc_exit_distance(loc, sub_loc)
    if out_distance > 0:
        outf.write(', {} {}'.format(out_distance,
                                    'day' if out_distance == 1 else 'days'))
    if 'SL' in sub_loc and 'de' in sub_loc['SL']:
        outf.write(', defense {}'.format(sub_loc['SL']['de'][0]))
    if 'castle' in u.return_type(sub_loc):
        if 'SL' in sub_loc:
            if 'cl' in sub_loc['SL']:
                if sub_loc['SL']['cl'][0] != '0':
                    outf.write(', level {}'.format(sub_loc['SL']['cl'][0]))
    if 'mine' in u.return_type(sub_loc):
        if 'SL' in sub_loc and 'sd' in sub_loc['SL']:
            if sub_loc['SL']['sd'][0] != '0':
                outf.write(', level {}'.format(int(sub_loc['SL']['sd'][0]) / 3))
    if 'SL' in sub_loc:
        if 'eg' and 'er' in sub_loc['SL']:
            effort_given = int(sub_loc['SL']['eg'][0])
            effort_required = int(sub_loc['SL']['er'][0])
            pct_complete = int(float(effort_given / effort_required)*100)
            outf.write(', {}% completed'.format(pct_complete))
    if 'SL' in sub_loc and 'da' in sub_loc['SL']:
        outf.write(', {}% damaged'.format(sub_loc['SL']['da'][0]))
    if 'LI' in sub_loc and 'hl' in sub_loc['LI']:
        sub_here_list = sub_loc['LI']['hl']
        if len(sub_here_list) > 0:
            first_here = data[sub_here_list[0]]
            if u.return_kind(first_here) == 'char':
                outf.write(', owner:')
    outf.write('</li>\n')
    # see if stuff stacked under it
    if 'LI' in sub_loc and 'hl' in sub_loc['LI']:
        sub_here_list = sub_loc['LI']['hl']
        if len(sub_here_list) > 0:
            outf.write('<ul>\n')
            for sub_hl in sub_here_list:
                sub_sub_here = data[sub_hl]
                if u.return_kind(sub_sub_here) == 'loc':
                    write_sub_locs(sub_loc,
                                   sub_sub_here,
                                   sub_hl,
                                   data,
                                   outf)
                elif u.return_kind(sub_sub_here) == 'char':
                    write_characters(sub_sub_here,
                                     u.return_unitid(sub_sub_here),
                                     data, outf)
                elif u.return_kind(sub_sub_here) == 'ship':
                    write_ships(sub_sub_here,
                                u.return_unitid(sub_sub_here),
                                data,
                                outf)
            outf.write('</ul>\n')
예제 #8
0
파일: loc.py 프로젝트: olympiag3/olymap
def write_loc_page_header(v, k, data, outf):
    outf.write('<H3>')
    loc_type = u.return_type(v)
    outf.write('{} [{}]'.format(v['na'][0], to_oid(k)))
    outf.write(', {}'.format(loc_type))
    if u.return_type(v) != 'region':
        outf.write(', in')
        if loc_type == 'city':
            outf.write(' province ')
        try:
            loc2 = data[v['LI']['wh'][0]]
            outf.write(' {} [{}]'.format(loc2['na'][0],
                                         anchor(to_oid(u.return_unitid(loc2)))))
        except KeyError:
            pass
    # if 'city' in loc_type:
    #    outf.write(' [{}]'.format(anchor(to_oid(v['LI']['wh'][0]))))
    if 'SL' in v and 'sh' in v['SL']:
        outf.write(', safe haven')
    if 'LO' in v and 'hi' in v['LO']:
        outf.write(', hidden')
    if loc_type != 'ocean' and u.loc_depth(u.return_type(v)) == 2 \
            and data[u.region(k, data)]['na'][0] != 'faery' and data[u.region(k, data)]['na'][0] != 'hades':
        civ_level = 'wilderness'
        if 'LO' in v and 'lc' in v['LO']:
            if v['LO']['lc'][0] == '0':
                civ_level = 'wilderness'
            else:
                civ_level = 'civ-' + v['LO']['lc'][0]
        outf.write(', {}'.format(civ_level))
    outf.write('</H3>\n')
예제 #9
0
파일: storm.py 프로젝트: olympiag3/olymap
def write_bound_ship(data, k, outf, storm_chain):
    ship_list = storm_chain[k]
    if len(ship_list) > 0:
        for ship in ship_list:
            ship_rec = data[ship]
            outf.write('<tr><td>Bound Ship: </td><td>{} [{}]</td></tr>\n'.format(ship_rec['na'][0],
                                                                                 anchor(to_oid(ship))))
예제 #10
0
def write_char_pledged_to(v, data, outf):
    # CM/pl
    if 'CM' in v and 'pl' in v['CM']:
        pledged_to = data[v['CM']['pl'][0]]
        outf.write('<tr>')
        outf.write('<td>Pledged To:</td>')
        outf.write('<td>{} [{}]</td></tr>\n'.format(
            pledged_to['na'][0], anchor(to_oid(u.return_unitid(pledged_to)))))
예제 #11
0
def write_char_faction(v, data, outf):
    # CH/lo
    if 'CH' in v and 'lo' in v['CH']:
        player = data[v['CH']['lo'][0]]
        outf.write('<tr>')
        outf.write('<td>Faction:</td>')
        outf.write('<td>{} [{}]</td></tr>\n'.format(
            player['na'][0], anchor(to_oid(u.return_unitid(player)))))
예제 #12
0
def write_char_location(data, outf, v):
    if 'LI' in v and 'wh' in v['LI']:
        loc = data[v['LI']['wh'][0]]
        anch = anchor(to_oid(v['LI']['wh'][0]))
        outf.write('<tr>')
        outf.write('<td>Where:</td><td>{} [{}]</td>'.format(
            loc['na'][0], anch))
        outf.write('</tr>\n')
예제 #13
0
파일: loc.py 프로젝트: olympiag3/olymap
def write_loc_skills_report(v, data, outf):
    if 'SL' in v and 'te' in v['SL']:
        skills_list = v['SL']['te']
        if len(skills_list) > 0:
            outf.write('<H4> Skills taught here:</H4>\n')
            outf.write('<ul>\n')
            for skill in skills_list:
                outf.write('<li>{} [{}]</li>\n'.format(data[skill]['na'][0],
                                                       anchor(to_oid(skill))))
            outf.write('</ul>\n')
예제 #14
0
파일: loc.py 프로젝트: pombredanne/olypy
def write_storms(v, k, outf):
    outf.write('<li>\n')
    if 'na' in v:
        name = v['na'][0]
    else:
        name = u.return_type(v).capitalize()
    outf.write('{} [{}], {}'.format(name, anchor(to_oid(k)), u.return_type(v)))
    if 'MI' in v and 'ss' in v['MI']:
        outf.write(' (strength: {})'.format(v['MI']['ss'][0]))
    outf.write('</li>\n')
예제 #15
0
def write_char_stacked_under(v, data, outf):
    # LI/wh
    if 'LI' in v and 'wh' in v['LI']:
        charu = data[v['LI']['wh'][0]]
        # if it's not a 'char' type, then it's a location/ship
        # and I handle that in location row
        if u.return_kind(charu) == 'char':
            outf.write('<tr>')
            outf.write('<td>Stacked Under:</td>')
            outf.write('<td>{} [{}]</td></tr>\n'.format(
                charu['na'][0], anchor(to_oid(u.return_unitid(charu)))))
예제 #16
0
def write_char_stacked_over(v, data, outf):
    # LI/hl
    if 'LI' in v and 'hl' in v['LI']:
        over_list = v['LI']['hl']
        stacked_over = 'Stacked Over:'
        for ov in over_list:
            charo = data[ov]
            outf.write('<tr>')
            outf.write('<td>{}</td>'.format(stacked_over))
            outf.write('<td>{} [{}]</td></tr>\n'.format(
                charo['na'][0], anchor(to_oid(u.return_unitid(charo)))))
            stacked_over = ''
예제 #17
0
def write_char_visions_received(v, data, outf):
    if 'CM' in v and 'vi' in v['CM']:
        vision_list = v['CM']['vi']
        outf.write('<p>Visions Received:</p>\n')
        outf.write('<table>\n')
        for vision in vision_list:
            try:
                visioned = data[vision]
            except KeyError:
                vision_name = 'missing'
            else:
                vision_name = visioned.get('na', ['missing'])[0]
            outf.write('<tr><td>{} [{}]</td></tr>\n'.format(
                vision_name, anchor(to_oid(vision))))
        outf.write('</table>\n')
예제 #18
0
파일: ship.py 프로젝트: olympiag3/olymap
def write_ship_owner(v, data, outf):
    if 'LI' in v and 'hl' in v['LI']:
        units = v['LI']['hl']
    else:
        units = '???'
    if units != '???':
        char = data[units[0]]
        outf.write('<tr>')
        outf.write('<td>Owner:</td>')
        outf.write('<td>{} [{}]</td></tr>\n'.format(
            char['na'][0], anchor(to_oid(u.return_unitid(char)))))
    else:
        outf.write('<tr>')
        outf.write('<td>Owner:</td>')
        outf.write('<td>unoccupied</td></tr>\n')
예제 #19
0
파일: ship.py 프로젝트: olympiag3/olymap
def write_ship_bound_storm(v, data, outf):
    if 'SL' in v and 'bs' in v['SL']:
        bound_storm = v['SL']['bs'][0]
    else:
        bound_storm = '???'
    if bound_storm != '???':
        bound_storm_rec = data[bound_storm]
        if 'na' in bound_storm_rec:
            name = bound_storm_rec['na'][0]
        else:
            name = u.return_type(bound_storm_rec).capitalize()
        outf.write('<tr>')
        outf.write('<td>Bound Storm:</td>')
        outf.write('<td>{} [{}] (Strength: {})</td></tr>\n'.format(
            name, anchor(to_oid(bound_storm)), bound_storm_rec['MI']['ss'][0]))
예제 #20
0
def write_char_pledged_to_us(k, data, outf, pledge_chain):
    # CM/pl
    try:
        pledge_list = pledge_chain[k]
    except:
        pass
    else:
        if len(pledge_list) > 0:
            pledged_text = 'Pledged To Us:'
            for pledgee in pledge_list:
                pledgee_rec = data[pledgee]
                outf.write('<tr>')
                outf.write('<td>{}</td>'.format(pledged_text))
                pledged_text = '&nbsp;'
                outf.write('<td>{} [{}]</td></tr>\n'.format(
                    pledgee_rec['na'][0], anchor(to_oid(pledgee))))
예제 #21
0
파일: ship.py 프로젝트: olympiag3/olymap
def write_ship_seen_here(k, data, outf):
    label1 = 'Seen Here:'
    seen_here_list = []
    level = 0
    seen_here_list = u.chase_structure(k, data, level, seen_here_list)
    list_length = len(seen_here_list)
    if list_length > 1:
        for un in seen_here_list[1:]:
            char = data[un[0]]
            depth = un[1] - 1
            outf.write('<tr>')
            outf.write('<td>{}</td>'.format(label1))
            outf.write('<td>{} {} [{}]</td></tr>\n'.format(
                '.' * depth, char['na'][0],
                anchor(to_oid(u.return_unitid(char)))))
            label1 = '&nbsp;'
예제 #22
0
파일: loc.py 프로젝트: olympiag3/olymap
def write_hidden_access(v, k, data, outf, hidden_chain):
    if 'LO' in v and 'hi' in v['LO']:
        if v['LO']['hi'][0] == '1' or u.region(k, data) in {'faery', 'hades'}:
            # PL/kn
            try:
                hidden_list = hidden_chain[k]
                if len(hidden_list) > 0:
                    outf.write('Hidden location known by:</H4>\n')
                    outf.write('<ul>\n')
                    for hidden in hidden_list:
                        hidden_rec = data[hidden]
                        outf.write('<li>{} [{}]</td></li>\n'.format(hidden_rec['na'][0],
                                                                    anchor(to_oid(hidden))))
                    outf.write('</ul>\n')
            finally:
                pass
예제 #23
0
def write_char_prisoners(k, data, outf, prisoner_chain):
    # CH/pr
    try:
        prisoner_list = prisoner_chain[k]
    except:
        pass
    else:
        if len(prisoner_list) > 0:
            prisoner_text = 'Prisoners:'
            for prisoner in prisoner_list:
                prisoner_rec = data[prisoner]
                outf.write('<tr>')
                outf.write('<td>{}</td>'.format(prisoner_text))
                prisoner_text = '&nbsp;'
                prisoner_health_text = ''
                if 'CH' in prisoner_rec:
                    if 'he' in prisoner_rec['CH']:
                        prisoner_health_text = ' (health {})'.format(
                            prisoner_rec['CH']['he'][0])
                outf.write('<td>{} [{}]{}</td></tr>\n'.format(
                    prisoner_rec['na'][0], anchor(to_oid(prisoner)),
                    prisoner_health_text))
예제 #24
0
def write_char_pending_trades(v, data, outf):
    if 'tl' in v:
        trade_list = v['tl']
        if len(trade_list) > 0:
            outf.write('<p>Pending Trades:</p>\n')
            outf.write('<table>\n')
            outf.write(
                '<tr><td style="text-align:right">trades</td><td style="text-align:right">price</td>'
                '<td style="text-align:right">qty</td><td style="text-align:left">item</td>\n'
            )
            outf.write(
                '<tr><td style="text-align:right">---</td><td style="text-align:right">-----</td>'
                '<td style="text-align:right">---</td><td style="text-align:left">----</td>\n'
            )
            for trades in range(0, len(trade_list), 8):
                try:
                    itemz = data[trade_list[trades + 1]]
                except KeyError:
                    pass
                else:
                    outf.write('<tr>')
                    direction = 'buy' if trade_list[trades] == '1' else 'sell'
                    outf.write('<td style="text-align:right">{}</td>'.format(
                        direction))
                    outf.write('<td style="text-align:right">{}</td>'.format(
                        trade_list[trades + 3]))
                    outf.write('<td style="text-align:right">{}</td>'.format(
                        trade_list[trades + 2]))
                    name = u.get_item_name(itemz) if int(
                        trade_list[trades +
                                   2]) == 1 else u.get_item_plural(itemz)
                    anch = anchor(to_oid(trade_list[trades + 1]))
                    outf.write(
                        '<td style="text-align:left">{} [{}]</td>'.format(
                            name, anch))
                    outf.write('</tr>\n')
            outf.write('</table>\n')
예제 #25
0
def write_char_skills_known(v, data, outf):
    # CH/sl
    if 'CH' in v and 'sl' in v['CH']:
        skills_list = v['CH']['sl']
        skills_dict = defaultdict(list)
        if len(skills_list) > 0:
            for skill in range(0, len(skills_list), 5):
                skills_dict[skills_list[skill]].append(skills_list[skill + 1])
                skills_dict[skills_list[skill]].append(skills_list[skill + 2])
                skills_dict[skills_list[skill]].append(skills_list[skill + 3])
                skills_dict[skills_list[skill]].append(skills_list[skill + 4])
        sort_list = []
        for skill in skills_dict:
            skill_id = skill
            skills_rec = skills_dict[skill]
            know = skills_rec[0]
            sort_list.append([int(know) * -1, skill_id])
        sort_list.sort()
        if len(sort_list) > 0:
            printknown = False
            printunknown = False
            for skill in sort_list:
                skill_id = skill[1]
                skills_rec = skills_dict[skill_id]
                know = skills_rec[0]
                days_studied = skills_rec[1]
                if know == '2':
                    if not printknown:
                        if printunknown:
                            outf.write('</ul>\n')
                        outf.write('<p>Skills known:</p>\n')
                        outf.write('<ul style="list-style-type:none">\n')
                        printknown = True
                    skillz = data[skill_id]
                    outf.write('<li>')
                    if 'rs' in skillz['SK']:
                        req_skill = skillz['SK']['rs'][0]
                    else:
                        req_skill = '0'
                    if req_skill != '0':
                        outf.write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')
                    outf.write('{} [{}]'.format(skillz['na'][0],
                                                anchor(to_oid(skill_id))))
                    outf.write('</li>\n')
                if know == '1':
                    if not printunknown:
                        if printknown:
                            outf.write('</ul>\n')
                        outf.write('<p>Partially known skills:</p>\n')
                        outf.write('<ul style="list-style-type:none">\n')
                        printunknown = True
                    skillz = data[skill_id]
                    outf.write('<li>')
                    outf.write('{} [{}], {}/{}'.format(
                        skillz['na'][0], anchor(to_oid(skill_id)),
                        days_studied, skillz['SK']['tl'][0]))
                    outf.write('</li>\n')
            if printknown or printunknown:
                outf.write('</ul>\n')
    else:
        outf.write('<p>Skills known:</p>\n')
        outf.write('<ul style="list-style-type:none">\n')
        outf.write('<li>none</li></ul>\n')
예제 #26
0
def write_char_type(v, k, data, outf):
    if u.return_type(v) == 'ni':
        outf.write('<tr>')
        outf.write('<td>Type:</td>')
        outf.write('<td>{} [{}]</td></tr>\n'.format(
            data[v['CH']['ni'][0]]['na'][0], anchor(to_oid(v['CH']['ni'][0]))))
예제 #27
0
def write_char_magic_stuff(v, data, outf):
    if 'il' in v:
        item_list = v['il']
        for items in range(0, len(item_list), 2):
            try:
                itemz = data[item_list[items]]
            except KeyError:
                pass
            else:
                item_type = u.return_type(itemz)
                if item_type == '0':
                    if 'IM' in itemz and 'uk' in itemz['IM']:
                        use_key = itemz['IM']['uk'][0]
                        if use_key == '2':
                            outf.write('<p>Healing Potion [{}]</p>\n'.format(
                                anchor(to_oid(item_list[items]))))
                        elif use_key == '5':
                            loc_kind = 'unknown'
                            loc_name = 'unknown'
                            loc_id = ''
                            if 'IM' in itemz and 'pc' in itemz['IM']:
                                try:
                                    location = data[itemz['IM']['pc'][0]]
                                except KeyError:
                                    loc_kind = 'unknown'
                                    loc_name = 'unknown'
                                    loc_id = to_oid(itemz['IM']['pc'][0])
                                else:
                                    loc_id = anchor(
                                        to_oid(itemz['IM']['pc'][0]))
                                    if u.return_kind(location) != 'loc':
                                        loc_kind = u.return_kind(location)
                                    else:
                                        loc_kind = 'location'
                                    loc_name = location.get('na',
                                                            ['unknown'])[0]
                                    loc_id = anchor(
                                        to_oid(u.return_unitid(location)))
                            else:
                                loc_id = '(no id)'
                            anch = anchor(to_oid(item_list[items]))
                            outf.write(
                                '<p>Projected Cast [{}] to {} {}'.format(
                                    anch, loc_kind, loc_name))
                            if loc_id != '':
                                outf.write(' [{}]'.format(loc_id))
                            outf.write('</p>\n')
                elif item_type == 'scroll':
                    if 'IM' in itemz and 'ms' in itemz['IM']:
                        skill_id = anchor(to_oid(itemz['IM']['ms'][0]))
                        scroll_id = anchor(to_oid(item_list[items]))
                        required_study = ''
                        try:
                            skill = data[itemz['IM']['ms'][0]]
                        except KeyError:
                            skill_name = 'unknown'
                        else:
                            skill_name = skill['na'][0]
                            if 'SK' in skill:
                                if 'rs' in skill['SK']:
                                    try:
                                        skill2 = data[skill['SK']['rs'][0]]
                                    except KeyError:
                                        skill2_name = 'unknown'
                                    else:
                                        skill2_name = skill2.get(
                                            'na', ['unknown'])[0]
                                    anch = anchor(to_oid(skill['SK']['rs'][0]))
                                    required_study = '(requires {} [{}])'.format(
                                        skill2_name, anch)
                        outf.write(
                            '<p>Scroll [{}] permits the study of the following skills:<br>&nbsp;&nbsp;&nbsp;'
                            '{} [{}] {}</p>\n'.format(scroll_id, skill_name,
                                                      skill_id,
                                                      required_study))
예제 #28
0
파일: maps.py 프로젝트: pombredanne/olypy
def generate_cell_contents(castle_chain, cell, data, loc_rec, outf):
    if 'LO' in loc_rec and 'lc' in loc_rec['LO']:
        if loc_rec['LO']['lc'][0] != '0':
            outf.write('<b>')
    a = to_oid(cell)
    outf.write('{}'.format(anchor(to_oid(cell))))
    if 'LO' in loc_rec and 'lc' in loc_rec['LO']:
        if loc_rec['LO']['lc'][0] != '0':
            outf.write('</b>')
    if 'LI' in loc_rec and 'hl' in loc_rec['LI']:
        here_list = loc_rec['LI']['hl']
        for garr in here_list:
            garr_rec = data[garr]
            if u.return_type(garr_rec) == 'garrison':
                if 'MI' in garr_rec:
                    if 'gc' in garr_rec['MI']:
                        castle_id = garr_rec['MI']['gc'][0]
                        outf.write('{}'.format(castle_chain[castle_id][0]))
    loc1 = ''
    loc2 = ''
    city = ''
    graveyard = ''
    road_or_gate = ''
    count = int(0)
    if 'LI' in loc_rec and 'hl' in loc_rec['LI']:
        if len(loc_rec['LI']['hl']) > 0:
            here_list = loc_rec['LI']['hl']
            for here in here_list:
                # if 56760 <= int(here) <= 78999:
                here_rec = data[here]
                if u.return_type(
                        here_rec) in details.subloc_kinds or u.is_road_or_gate(
                            here_rec):
                    count = count + 1
                    if u.return_type(here_rec) == 'city':
                        city = here_rec
                    elif u.return_type(here_rec) == 'graveyard':
                        graveyard = here_rec
                    elif u.is_road_or_gate(here_rec):
                        road_or_gate = here_rec
                    elif loc1 == '' and u.return_kind(here_rec) == 'loc':
                        loc1 = here_rec
                    elif loc2 == '' and u.return_kind(here_rec) == 'loc':
                        loc2 = here_rec
    if 'SL' in loc_rec:
        if 'lt' in loc_rec['SL']:
            here_rec = data[loc_rec['SL']['lt'][0]]
            count = count + 1
            if loc1 == '':
                loc1 = here_rec
            elif loc2 == '':
                loc2 = here_rec
        if 'lf' in loc_rec['SL']:
            here_rec = data[loc_rec['SL']['lf'][0]]
            count = count + 1
            if loc1 == '':
                loc1 = here_rec
            elif loc2 == '':
                loc2 = here_rec
    if loc1 != '' or loc2 != '' or city != '' or graveyard != '' or road_or_gate != '':
        if city != '':
            if loc2 == '':
                loc2 = loc1
            loc1 = city
        if graveyard != '':
            if loc1 == '':
                if loc2 == '':
                    loc2 = loc1
                loc1 = graveyard
            else:
                if loc2 == '':
                    loc2 = graveyard
        if road_or_gate != '':
            if loc1 == '':
                if loc2 == '':
                    loc2 = loc1
                loc1 = road_or_gate
            else:
                if loc2 == '':
                    loc2 = road_or_gate
        if count > 2:
            outf.write('<br />many')
        else:
            if loc2 != '':
                if u.return_type(loc2) == 'city' or u.return_type(
                        loc2) == 'graveyard' or u.return_type(
                            loc2) == 'faery hill':
                    outf.write('<br />')
                    outf.write('{}'.format(
                        anchor2(to_oid(u.return_unitid(loc2)),
                                u.return_short_type(loc2))))
                else:
                    outf.write('<br />')
                    if 'LO' in loc2 and 'hi' in loc2['LO']:
                        if loc2['LO']['hi'][0] == '1':
                            outf.write('<i>')
                    outf.write(u.return_short_type(loc2))
                    if 'LO' in loc2:
                        if 'hi' in loc2['LO'] and loc2['LO']['hi'][0] == '1':
                            outf.write('</i>')
            else:
                outf.write('<br />&nbsp;')
        if loc1 != '':
            if u.return_type(loc1) == 'city' or u.return_type(
                    loc1) == 'graveyard' or u.return_type(
                        loc1) == 'faery hill':
                outf.write('<br />')
                outf.write('{}'.format(
                    anchor2(to_oid(u.return_unitid(loc1)),
                            u.return_short_type(loc1))))
            else:
                outf.write('<br />')
                if 'LO' in loc1 and 'hi' in loc1['LO']:
                    if loc1['LO']['hi'][0] == '1':
                        outf.write('<i>')
                outf.write(u.return_short_type(loc1))
                if 'LO' in loc1 and 'hi' in loc1['LO']:
                    if loc1['LO']['hi'][0] == '1':
                        outf.write('</i>')
        else:
            outf.write('<br />&nbsp;')
예제 #29
0
파일: skill.py 프로젝트: olympiag3/olymap
def write_skill_basic_info(v, k, data, outf, teaches_chain, child_skills_chain,
                           skills_known_chain):
    outf.write('<table>\n')
    if 'SK' in v:
        if 'rs' in v['SK']:
            skill = data[v['SK']['rs'][0]]
            outf.write('<tr><td>Skill Required:</td><td>{} [{}]'
                       '</td></tr>\n'.format(skill['na'][0],
                                             anchor(u.return_unitid(skill))))
        if 'tl' in v['SK']:
            outf.write('<tr><td>Time to Learn:</td><td>{}</td></tr>\n'.format(
                v['SK']['tl'][0]))
    char_list = skills_known_chain[k]
    if len(char_list) > 0:
        outf.write('<tr><td valign="top">Known By:</td><td>')
        outf.write('<table>\n')
        columns = int(math.ceil(len(char_list) / 3))
        for charac in range(0, columns):
            outf.write('<tr>')
            if (columns * 0) + charac < len(char_list):
                char_rec = data[char_list[(columns * 0) + charac]]
                outf.write('<td>{} [{}]</td>'.format(
                    char_rec['na'][0],
                    anchor(to_oid(u.return_unitid(char_rec)))))
            else:
                outf.write('<td></td><td></td>')
            if (columns * 1) + charac < len(char_list):
                char_rec = data[char_list[(columns * 1) + charac]]
                outf.write('<td>{} [{}]</td>'.format(
                    char_rec['na'][0],
                    anchor(to_oid(u.return_unitid(char_rec)))))
            else:
                outf.write('<td></td><td></td>')
            if (columns * 2) + charac < len(char_list):
                char_rec = data[char_list[(columns * 2) + charac]]
                outf.write('<td>{} [{}]</td>'.format(
                    char_rec['na'][0],
                    anchor(to_oid(u.return_unitid(char_rec)))))
            else:
                outf.write('<td></td><td></td>')
            outf.write('</tr>\n')
        outf.write('</table>\n')
        outf.write('</td></tr>')
    child_list = child_skills_chain[k]
    if len(child_list) > 0:
        outf.write('<tr><td valign="top">Child Skills:</td><td>')
        outf.write('<table>\n')
        columns = int(math.ceil(len(child_list) / 3))
        for skill in range(0, columns):
            outf.write('<tr>')
            if (columns * 0) + skill < len(child_list):
                skill_rec = data[child_list[(columns * 0) + skill]]
                outf.write('<td>{} [{}]</td>'.format(
                    skill_rec['na'][0],
                    anchor(to_oid(u.return_unitid(skill_rec)))))
            else:
                outf.write('<td></td><')
            if (columns * 1) + skill < len(child_list):
                skill_rec = data[child_list[(columns * 1) + skill]]
                outf.write('<td>{} [{}]</td>'.format(
                    skill_rec['na'][0],
                    anchor(to_oid(u.return_unitid(skill_rec)))))
            else:
                outf.write('<td></td>')
            if (columns * 2) + skill < len(child_list):
                skill_rec = data[child_list[(columns * 2) + skill]]
                outf.write('<td>{} [{}]</td>'.format(
                    skill_rec['na'][0],
                    anchor(to_oid(u.return_unitid(skill_rec)))))
            else:
                outf.write('<td></td>')
            outf.write('</tr>\n')
        outf.write('</table>\n')
        outf.write('</td></tr>')
    skill_list = teaches_chain[k]
    if len(skill_list) > 0:
        skill_literal = 'Taught in:'
        for loc in skill_list:
            loc_rec = data[loc]
            where_rec = data[loc_rec['LI']['wh'][0]]
            region = data[u.region(u.return_unitid(where_rec), data)]
            outf.write(
                '<tr><td>{}</td><td>{} [{}], {} [{}], in {}</td></tr>\n'.
                format(skill_literal, loc_rec['na'][0],
                       anchor(to_oid(u.return_unitid(loc_rec))),
                       where_rec['na'][0],
                       anchor(to_oid(u.return_unitid(where_rec))),
                       region['na'][0]))
            skill_literal = ''
    outf.write('</table>\n')
예제 #30
0
def write_char_inventory(v, data, outf):
    total_weight = int(0)
    if 'il' in v:
        item_list = v['il']
        if len(item_list) > 0:
            outf.write('<p>Inventory:</p>\n')
            outf.write('<table>\n')
            outf.write(
                '<tr><td style="text-align:right">qty</td><td style="text-align:left">name</td><td '
                'style="text-align:right">weight</td><td style="text-align:left">&nbsp;</td></tr>\n'
            )
            outf.write(
                '<tr><td style="text-align:right">---</td><td style="text-align:left">----</td><td '
                'style="text-align:right">------</td><td style="text-align:left">&nbsp;</td></tr>\n'
            )
            for itm in range(0, len(item_list), 2):
                item_id = item_list[itm]
                item_qty = int(item_list[itm + 1])
                outf.write('<tr>')
                outf.write(f'<td style="text-align:right">{item_qty:,d}</td>')
                itemz = data[item_id]
                itemz_name = u.get_item_name(
                    itemz) if item_qty == 1 else u.get_item_plural(itemz)
                outf.write('<td style="text-align:left">{} [{}]</td>'.format(
                    itemz_name, anchor(to_oid(item_id))))
                if 'wt' in itemz['IT']:
                    item_weight = int(itemz['IT']['wt'][0])
                else:
                    item_weight = int(0)
                item_ext = int(item_weight * item_qty)
                outf.write(f'<td style="text-align:right">{item_ext:,d}</td>')
                total_weight = total_weight + (item_weight * item_qty)
                if u.return_type(v) != "garrison":
                    outf.write('<td>')
                    fly_capacity = int(0)
                    if 'fc' in itemz['IT']:
                        fly_capacity = int(itemz['IT']['fc'][0])
                    land_capacity = int(0)
                    if 'lc' in itemz['IT']:
                        land_capacity = int(itemz['IT']['lc'][0])
                    ride_capacity = int(0)
                    if 'rc' in itemz['IT']:
                        ride_capacity = int(itemz['IT']['rc'][0])
                    if fly_capacity > 0:
                        outf.write(f'fly {(fly_capacity * item_qty):,d}')
                    elif ride_capacity > 0:
                        outf.write(f'ride {(ride_capacity * item_qty):,d}')
                    elif land_capacity > 0:
                        outf.write(f'cap {(land_capacity * item_qty):,d}')
                    if u.is_fighter(itemz, item_id):
                        attack = int(0)
                        defense = int(0)
                        missile = int(0)
                        if 'at' in itemz['IT']:
                            attack = int(itemz['IT']['at'][0])
                        if 'df' in itemz['IT']:
                            defense = int(itemz['IT']['df'][0])
                        if 'mi' in itemz['IT']:
                            missile = int(itemz['IT']['mi'][0])
                        outf.write(' ({},{},{})'.format(
                            attack, defense, missile))
                    attack_bonus = int(0)
                    defense_bonus = int(0)
                    missile_bonus = int(0)
                    if 'IM' in itemz:
                        if 'ab' in itemz['IM']:
                            attack_bonus = int(itemz['IM']['ab'][0])
                        if 'db' in itemz['IM']:
                            defense_bonus = int(itemz['IM']['db'][0])
                        if 'mb' in itemz['IM']:
                            missile_bonus = int(itemz['IM']['mb'][0])
                    if attack_bonus > 0:
                        outf.write(f'+ {attack_bonus:,d} attack')
                    if defense_bonus > 0:
                        outf.write(f'+ {defense_bonus:,d} defense')
                    if missile_bonus > 0:
                        outf.write(f'+ {missile_bonus:,d} missile')
                    if u.is_magician(v):
                        aura_bonus = 0
                        if 'IM' in itemz and 'ba' in itemz['IM']:
                            aura_bonus = int(itemz['IM']['ba'][0])
                        if aura_bonus > 0:
                            outf.write('+{} aura'.format(aura_bonus))
                    outf.write('&nbsp;</td>')
                else:
                    outf.write('<td>&nbsp;</td>')
                outf.write('</tr>\n')
            if u.return_type(v) != 'garrison':
                outf.write(
                    '<tr><td></td><td></td><td style="text-align:right">====='
                    '</td><td>&nbsp;</td></tr>\n')
                outf.write(
                    '<tr><td></td><td></td>'
                    f'<td style="text-align:right">{total_weight:,d}</td>'
                    '<td>&nbsp;</td></tr>\n')
            outf.write('</table>\n')