How to use ogame - 10 common examples

To help you get started, we’ve selected a few ogame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alaingilbert / pyogame / ogame / __init__.py View on Github external
def build(self, what, id):
        type = what[0]
        amount = what[1]
        component = what[2]
        response = self.session.get(self.index_php + 'page=ingame&component={}&cp={}'.format(component, id)).text
        html = OGame.HTML(response)
        build_token = None
        for line in html.find_all('type', 'javascript', 'value'):
            if 'urlQueueAdd' in line:
                build_token = line.split('token=')[1].split('\'')[0]
                break
        build_url = self.index_php + 'page=ingame&component={}&modus=1&token={}&type={}&menge={}' \
            .format(component, build_token, type, amount)
        self.session.get(build_url)
github alaingilbert / pyogame / ogame / __init__.py View on Github external
def send_fleet(self, mission, id, where, ships, resources=[0, 0, 0], speed=10, holdingtime=0):
        response = self.session.get(self.index_php + 'page=ingame&component=fleetdispatch&cp={}'.format(id)).text
        html = OGame.HTML(response)
        sendfleet_token = None
        for line in html.find_all('type', 'textjavascript', 'value'):
            if 'fleetSendingToken' in line:
                sendfleet_token = line.split('fleetSendingToken=')[1].split('"')[1]
                break
        form_data = {'token': sendfleet_token}
        for ship in ships:
            ship_type = 'am{}'.format(ship[0])
            form_data.update({ship_type: ship[1]})
        form_data.update({'galaxy': where[0],
                          'system': where[1],
                          'position': where[2],
                          'type': where[3],
                          'metal': resources[0],
                          'crystal': resources[1],
                          'deuterium': resources[2],
github alaingilbert / pyogame / ogame / __init__.py View on Github external
def collect_marketplace(self):
        to_collect_market_ids = []
        history_pages = ['history_buying', 'history_selling']
        action = ['fetchHistoryBuyingItems', 'fetchHistorySellingItems']
        collect = ['collectItem', 'collectPrice']
        response = False
        for page, action, collect in zip(history_pages, action, collect):
            response = self.session.get(
                url=self.index_php + 'page=ingame&component=marketplace&tab={}&action={}&ajax=1&pagination%5Bpage%5D=1'
                    .format(page, action, OGame.planet_ids(self)[0]),
                headers={'X-Requested-With': 'XMLHttpRequest'}
            ).json()
            items = response['content']['marketplace/marketplace_items_history'].split('data-transactionid=')
            del items[0]
            for item in items:
                if 'buttons small enabled' in item:
                    to_collect_market_ids.append(int(item[1:10].split('"')[0]))
            for id in to_collect_market_ids:
                form_data = {'marketTransactionId': id}
                response = self.session.post(
                    url=self.index_php + 'page=componentOnly&component=marketplace&action={}&asJson=1'.format(collect),
                    data=form_data,
                    headers={'X-Requested-With': 'XMLHttpRequest'}
                ).json()

        if not to_collect_market_ids:
github alaingilbert / pyogame / ogame / __init__.py View on Github external
def celestial_coordinates(self, id):
        celestial = self.landing_page.find_all('title', 'componentgalaxy&cp{}'.format(id), 'attribute')
        coordinates = celestial[0].split('componentgalaxy&cp{}&'.format(id))[1].split('"')[0] \
            .replace('&amp', '').replace('galaxy', '').replace('system', '').replace('position', '').split(';')
        if 'moon' in self.landing_page.find_all('title', 'galaxy&cp{}'.format(id), 'attribute', 'class')[0]:
            coordinates.append(const.destination.moon)
        else:
            coordinates.append(const.destination.planet)
        return coordinates
github alaingilbert / pyogame / ogame / __init__.py View on Github external
def celestial_coordinates(self, id):
        celestial = self.landing_page.find_all('title', 'componentgalaxy&cp{}'.format(id), 'attribute')
        coordinates = celestial[0].split('componentgalaxy&cp{}&'.format(id))[1].split('"')[0] \
            .replace('&amp', '').replace('galaxy', '').replace('system', '').replace('position', '').split(';')
        if 'moon' in self.landing_page.find_all('title', 'galaxy&cp{}'.format(id), 'attribute', 'class')[0]:
            coordinates.append(const.destination.moon)
        else:
            coordinates.append(const.destination.planet)
        return coordinates
github alaingilbert / pyogame / ogame / __init__.py View on Github external
in_construction = data[1]
            cost = const.price(const.buildings.fusion_plant, level=level)

        class metal_storage_class:
            level = levels[5]
            data = OGame.collect_status(status[7])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.metal_storage, level=level)

        class crystal_storage_class:
            level = levels[6]
            data = OGame.collect_status(status[8])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.crystal_storage, level=level)

        class deuterium_storage_class:
            level = levels[7]
            data = OGame.collect_status(status[9])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.deuterium_storage, level=level)

        class supply_buildings(object):
            metal_mine = metal_mine_class
            crystal_mine = crystal_mine_class
            deuterium_mine = deuterium_mine_class
            solar_plant = solar_plant_class
            fusion_plant = fusion_plant_class
            metal_storage = metal_storage_class
            crystal_storage = crystal_storage_class
github alaingilbert / pyogame / ogame / Object_Oriented.py View on Github external
                        def build(): return ogame.build(const.buildings.research_laboratory, id)
github alaingilbert / pyogame / ogame / Object_Oriented.py View on Github external
                        def build(): return ogame.build(const.buildings.terraformer, id)
github alaingilbert / pyogame / ogame / __init__.py View on Github external
levels = [int(level) for level in html.find_all('class', 'level', 'attribute', 'data-value', exact=True)]
        status = html.find_all('data-technology', '', 'attribute', 'data-status')

        class robotics_factory_class:
            level = levels[0]
            data = OGame.collect_status(status[0])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.robotics_factory, level=level)

        class shipyard_class:
            level = levels[1]
            data = OGame.collect_status(status[1])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.shipyard, level=level)

        class moon_base_class:
            level = levels[2]
            data = OGame.collect_status(status[2])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.moon_base, level=level)

        class sensor_phalanx_class:
            level = levels[3]
            data = OGame.collect_status(status[3])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.sensor_phalanx, level=level)

        class jump_gate_class:
github alaingilbert / pyogame / ogame / __init__.py View on Github external
in_construction = data[1]
            cost = const.price(const.buildings.deuterium_mine, level=level)

        class solar_plant_class:
            level = levels[3]
            data = OGame.collect_status(status[3])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.solar_plant, level=level)

        class fusion_plant_class:
            level = levels[4]
            data = OGame.collect_status(status[4])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.fusion_plant, level=level)

        class metal_storage_class:
            level = levels[5]
            data = OGame.collect_status(status[7])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.metal_storage, level=level)

        class crystal_storage_class:
            level = levels[6]
            data = OGame.collect_status(status[8])
            is_possible = data[0]
            in_construction = data[1]
            cost = const.price(const.buildings.crystal_storage, level=level)

        class deuterium_storage_class: