Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

PiecePaperCode/pyogame2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyogame2

picture

OGame is a browser-based, money-management and space-war themed massively multiplayer online browser game with over two million accounts.

This lib is supposed to help write scripts and bots for your needs. it supports ogame_version: 7.2.1 version 12

install

pip install pyogame2

update

pip uninstall pyogame2
pip install pyogame2

dont want to wait for new updates download direct from the develop branch

pip install git+https://github.com/PiecePaperCode/pyogame2.git@develop

get started

Code Snippets

Discord

Join Discord

functions

login

from pyogame2 import OGame2
from pyogame2.constants import destination, coordinates, ships, mission, speed, buildings, status
 
empire = OGame2(UNI, USER, PASSWORD)

#optional
empire = OGame2(UNI, USER, PASSWORD, user_agent='NCSA_Mosaic/2.0 (Windows 3.1)', proxy='https://proxy.com:port')

Want to use it with tor? Tutorial

get attacked

empire.attacked()                   returns bool 

get neutral

empire.neutral()                    returns bool 

get speed (universe)

empire.speed()                      returns class
empire.speed().universe
empire.speed().fleet

get planet id's

empire.planet_ids()                 returns list 

empire.id_by_planet_name('name')    returns int

empire.planet_names()               returns list

get moon id's

empire.moon_ids()                   returns list

**keep in mind to prefer planets id's moon id dont works on every function**

coordinates

coordinates have the format [galaxy, system, position, destination]

destination is referred to planet moon or debris on that coordinate planet=1 debris=2 moon=3
for example [1,200,16,3] = galaxy=1, system=200, position=16, destination=3 for moon
with from pyogame2.constants import destination the process is much more readable.

when you dont give it an destination it will default to planet

                                        returns list
from pyogame2.constants import coordinates, destination
pos = coordinates(galaxy=1,
                  system=2,
                  position=12,
                  dest=destination.debris)

coordinates(1, 2, 12, destination.moon)
coordinates(1, 2, 12, destination.debris)
coordinates(1, 2, 12, destination.planet) or coordinates(1, 2, 12)

get celestial coordinates

works with planet's and moon's

empire.celestial_coordinates(id)    returns list

resources

resources have the format [metal, crystal, deuterium]
darkmatter & energy are irrelevant, because you cant transport these.
It is used for transport and market functions

from pyogame2.constants import resources
res = resources(metal=1, crystal=2, deuterium=3)
[1, 2, 3]

get resources

empire.resources(id)                returns class(object)

res = empire.resources(id)
res.resources                           returns resources
res.day_production                      returns resources
res.darkmatter                          returns int
res.energy                              returns int
res.metal                               returns int
res.crystal                             returns int
res.deuterium                           returns int

get supply

empire.supply(id)                       returns class(object)

sup = empire.supply(id)

sup.metal_mine.level                    returns int
sup.metal_mine.is_possible              returns bool (possible to build)
sup.metal_mine.in_construction          returns bool
sup.metal_mine.cost                     returns resources

sup.crystal_mine
sup.deuterium_mine
sup.solar_plant
sup.fusion_plant 
sup.metal_storage
sup.crystal_storage
sup.deuterium_storage                   returns class(object)

get facilities

empire.facilities(id)               returns class(object) 

fac = empire.facilities(id)

fac.robotics_factory.level              returns int
fac.robotics_factory.is_possible        returns bool (possible to build)
fac.robotics_factory.in_construction    returns bool
fac.robotics_factory.cost               returns resources

fac.shipyard
fac.research_laboratory
fac.alliance_depot
fac.missile_silo
fac.nanite_factory
fac.terraformer
fac.repair_dock

get moon facilities

empire.moon_facilities(id)              returns class(object) 

fac = empire.moon_facilities(id) 
fac.robotics_factory.level              returns int
fac.robotics_factory.is_possible        returns bool (possible to build)
fac.robotics_factory.in_construction    returns bool
fac.robotics_factory.cost               returns resources

fac.shipyard
fac.moon_base
fac.sensor_phalanx 
fac.jump_gate

get marketplace

Use this function to get all offerings from the market.
resourses will be returned in the resourse's format
ships will be returned in the ship's format
for bid in empire.marketplace(id, page_nr):
    if bid.is_ships:
        print(bid.id, bid.offer, bid.price)
        print(ships.ship_name(bid.offer), ships.ship_amount(bid.offer))
    if bid.is_resources:
        print(bid.id, bid.offer, bid.price) 
    print(bid.is_possible)

>>>1234 (204, '508', 'shipyard') [0, '1500000', 0]
>>>light_fighter 508
>>>True
>>>1235 ['10000000', 0, 0] [0, '8000000', 0]
>>>False

buy marketplace

empire.buy_marketplace(bid.id, id)      returns bool

submit marketplace

you can sell resources and ships. 
Note that you can sell one ship or one resources at at time.
run a for loop if you wanna stack offerings.
If the Market accepts your offer depends on your price and availability on your id_planet
range cant be 0
empire.submit_marketplace(offer, 
                          price, 
                          id,
                          range)       returns bool

empire.submit_marketplace(offer=resources(metal=100),
                          price=resources(crystal=50),
                          id=id,
                          range=10)

empire.submit_marketplace(offer=ships.large_transporter(10),
                          price=resources(crystal=96000),
                          id=id,
                          range=10)

collect marketplace

it will collect all your orders at once that are not collected yet buy & sell orders
empire.collect_marketplace()        returns None (Ogame doesnt return a json return message anymore)

get traider

empire.traider(id)                  returns Exception("function not implemented yet PLS contribute")

get research

empire.research()                   returns class(object) 

res = empire.research()
res.energy
res.laser
res.ion
res.hyperspace
res.plasma
res.combustion_drive
res.impulse_drive
res.hyperspace_drive
res.espionage
res.computer
res.astrophysics
res.research_network
res.graviton
res.weapons
res.shielding
res.armor

get ships

empire.ships(id)                    returns class(object) 

shi = empire.ships(id)
shi.light_fighter
shi.heavy_fighter
shi.cruiser
shi.battleship
shi.interceptor
shi.bomber
shi.destroyer
shi.deathstar
shi.reaper
shi.explorer
shi.small_transporter
shi.large_transporter
shi.colonyShip
shi.recycler
shi.espionage_probe
shi.solarSatellite
shi.crawler

get defences

empire.defences(id)                 returns class(object) 

def = empire.defences(id)
def.rocket_launcher
def.laser_cannon_light
def.laser_cannon_heavy
def.gauss_cannon
def.ion_cannon
def.plasma_cannon
def.shield_dome_small
def.shield_dome_large
def.missile_interceptor
def.missile_interplanetary

get galaxy

empire.galaxy(coordinates)          returns list of class(object)
for planet in empire.galaxy(coordinates(randint(1,6), randint(1,499))):
    print(planet.list)
    print(planet.name, planet.position, planet.player, planet.player_id, planet.status, planet.moon)
    if status.inactive in planet.status:
        #Farm Inactive

get ally

empire.ally()                       returns string

get officers

empire.officers()                   returns Exception("function not implemented yet PLS contribute")

get shop

empire.shop()                       returns Exception("function not implemented yet PLS contribute")

get fleet

empire.fleet()                      returns list of class(object)
for fleet in empire.fleet():
    if fleet.mission == mission.expedition:
        print(fleet.list)
        print(fleet.id, fleet.mission, fleet.returns, fleet.arrival, fleet.origin, fleet.destination)

get phalanx

empire.phalanx(coordinates, id)     returns list of class(object)
for fleet in empire.phalanx(moon_id, coordinates(2, 410, 7)):
    if fleet.mission == mission.expedition:
        print(fleet.list)
        print(fleet.id, fleet.mission, fleet.returns, fleet.arrival, fleet.origin, fleet.destination)

get spyreports

empire.spyreports()                  returns list of class(object)
for spyreport in empire.spyreports():
    print(spyreport.id, spyreport.time, spyreport.coordinates, 
          spyreport.resources, spyreport.technology, spyreport.list)
    
    # you need to check bacause somtimes spymissions fail
    if buildings.metal_mine in spyreports.technology:
        print(spyreport.technology[buildings.metal_mine])

send fleet

from pyogame2.constants import coordinates, ships, mission, speed
empire.send_fleet(mission=mission.expedition,
                  id=id,
                  where=coordinates(1, 12, 16),
                  ships=[ships.small_transporter(1), ships.bomber(1)],
                  resources=[0, 0, 0],  # optional default no resources
                  speed=speed.max,      # optional default speed.max
                  holdingtime=2)        # optional default 0 will be needed by expeditions
                 
                                        returns bool

send message

empire.send_message(player_id, msg)     returns bool

build

Buildings

from pyogame2.constants import buildings
empire.build(what=buildings.alliance_depot, 
             id=id)

buildings.metal_mine
buildings.crystal_mine
buildings.deuterium_mine
buildings.solar_plant
buildings.fusion_plant
buildings.solar_satellite(int)
buildings.crawler(int)
buildings.metal_storage
buildings.crystal_storage
buildings.deuterium_storage

buildings.robotics_factory
buildings.shipyard
buildings.research_laboratory
buildings.alliance_depot
buildings.missile_silo
buildings.nanite_factory
buildings.terraformer
buildings.repair_dock

empire.build(what=buildings.rocket_launcher(10), 
             id=id)

buildings.rocket_launcher(int)
buildings.laser_cannon_light(int)
buildings.laser_cannon_heavy(int)
buildings.gauss_cannon(int)
buildings.ion_cannon(int)
buildings.plasma_cannon(int)
buildings.shield_dome_small(int)
buildings.shield_dome_large(int)
buildings.missile_interceptor(int)
buildings.missile_interplanetary(int)

buildings.moon_base
buildings.sensor_phalanx
buildings.jump_gate

Ships

from pyogame2.constants import ships
empire.build(what=ships.bomber(10), 
             id=id)

ships.light_fighter(int)
ships.heavy_fighter(int)
ships.cruiser(int)
ships.battleship(int)
ships.interceptor(int)
ships.bomber(int)
ships.destroyer(int)
ships.deathstar(int)
ships.reaper(int)
ships.explorer(int)
ships.small_transporter(int)
ships.large_transporter(int)
ships.colonyShip(int)
ships.recycler(int)
ships.espionage_probe(int)
                 
                                        returns None

do research

from pyogame2.constants import research
empire.do_research(research=research.energy, id=id)

research.energy
research.laser
research.ion
research.hyperspace
research.plasma
research.combustion_drive
research.impulse_drive
research.hyperspace_drive
research.espionage
research.computer
research.astrophysics
research.research_network
research.graviton
research.weapons
research.shielding
research.armor
                 
                                        returns None

collect rubble field

 
this will collect your rubble field at the planet id.
                
empire.collect_rubble_field(id)         returns None

logout

                 
empire.logout()                         returns exit()

About

lib for the popular browsergame ogame

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages