Beispiel #1
0
def read_resource_fields(doc):
    """ Requires dorf1.php """
    resmap = doc.find("map#rx")

    buildings = []
    for field in resmap.children():
        if field.attr('href') == "dorf2.php": break
        bid = reg_bid.match(field.attr('href')).group(1)
        m = reg_res.match(field.attr('alt'))
        
        buildings.append((int(bid), db.get_gid_by_name(m.group(1)), int(m.group(2))))

    return buildings
Beispiel #2
0
def read_build_queue(doc):
    """ Requires dorf1.php or dorf2.php """

    queue = doc.find("div.buildingList div.boxes-contents ul li")
    build_queue = []
    for bldElm in queue:
        m = reg_queue.match(bldElm.find("div.name").text())
        try:
            timer = (datetime.strptime(bldElm.find("div.buildDuration span").text(), "%H:%M:%S") - datetime(1900, 1, 1)) # - timedelta(hours=1))
        except:
            continue
        
        build_queue.append({ 'building': db.get_gid_by_name(m.group(1)), 'level': int(m.group(2)), 'timer':timer })

    return build_queue
Beispiel #3
0
def read_buildings(doc):
    """ Requires dorf2.php """
    bldmap = doc.find("map#clickareas")

    buildings = []

    for building in bldmap.children():
        bid = reg_bid.match(building.attr('href')).group(1)

        if building.attr('alt').find(' ') == -1: # building could be empty
            buildings.append((int(bid), 0, 0))
            continue
            
        m = reg_bld.match(building.attr('alt'))

        buildings.append((int(bid), db.get_gid_by_name(html_entities_decode(m.group(1))), int(m.group(2))))
        
    return buildings