Skip to main content

Travian: Kingdom utilities for your need.

Project description

tkpy

Travian: Kingdom utilities for your need.
It provide several object that mostly used on Travian: Kingdom such as Map, Villages, Notepad, and Farmlist.

PyPI version Python 3.6 Build Status codecov Code style: black License: MIT

Table of Contents

Installation

It is recommended to use virtualenv or any other similar virtual environment management for python.

Since tkpy depend on primordial package, first you need to install primordial package.

pip install git+https://github.com/didadadida93/tkpy.git

Getting started

tkpy need Gameworld object from primordial package so it can request data from Travian: Kingdom. Use authenticate function to retrieve Gameworld object.

from tkpy import authenticate

driver = authenticate(email='your@email.com', password='your password', gameworld='com12')

Usage

Map

Map object is an object for keeping map data from Travian: Kingdom.
To get map data from Travian: Kingdom, you need to call pull method.

from tkpy import Map

m = Map(driver)
m.pull()

Once you call pull method, now you can get all tiles data using several method.

all_villages = list(m.gen_villages()) # get all villages from map
abandoned_valleys = list(m.gen_abandoned_valley()) # get all unsettled tiles from map
oases = list(m.gen_oases()) # get all oases from map
grey_villages = list(m.gen_grey_villages()) # get all grey villages from map

Or if you want to get data from specific tile, you can use coordinate method.

m.coordinate(0, 0)
<Cell({'id': '536887296', 'landscape': '9013', 'owner': '0'})>

When you call pull method, you also will get player data and kingdom data. Map object will keep this data and you can get player data or kingdom data using several method.

player_list = list(m.gen_players()) # get all players
kingdom_list = list(m.gen_kingdoms()) # get all kingdoms
inactive_player_list = list(m.gen_inactive_players()) # get all inactive players

If you want to get data from specific player or kingdom, you can use get_player method and get_kingdom method.

m.get_player('player name')
<Player({'name': 'player name', 'country': 'en', 'tribeId': '1', ...})>

m.get_kingdom('kingdom name')
<Kingdom({'tag': 'kingdom name', 'kingdomId': '9999'})>

If you want to slice map data based on the area of your interest, you can use slice_map method.

sliced_map = m.slice_map(center=(0, 0), radius=5)

# now you can do the same thing as `Map` object
grey_villages = list(sliced_map.gen_grey_villages())

Villages

Villages object is like built-in dict object from Python so you can access the village using its name as key. To get village data from Travian: Kingdom, you need to call pull method first.

from tkpy import Villages

v = Villages(driver)
v.pull()

v['your first village']
<Village({'villageId': '537313245', 'playerId': '001', 'name': 'my first village',...})>

From Villages object you can get Village object and from this object you can do send_attack, send_raid, send_defend, send_spy, and send_siege.

If you want to attack, you need to get troop enum from tkpy.

from tkpy import RomanTroop # if you are a Roman tribe

first_village = v['your first village'] # get your first village object
units_siege = {RomanTroop.IMPERIAN: 1000, RomanTroop.BATTERING_RAM: 1} # prepare unit
units_attack = {RomanTroop.LEGIONNAIRE: 1000} # prepare unit
units_raid = {RomanTroop.EQUITES_IMPERATORIS: 50} # prepare unit
units_defend = {RomanTroop.PRAETORIAN: 1000} # prepare unit

first_village.send_siege(x=0, y=0, units=units_siege) # send siege
first_village.send_attack(x=0, y=0, units=units_attack) # send attack
first_village.send_raid(x=0, y=0, units=units_raid) # send raid
first_village.send_spy(x=0, y=0, amount=1) # send spy
first_village.send_defend(x=0, y=0, untis=unts_defend) # send defend

From Village object you can also upgrade building that on the village by using upgrade method. And if you want to construct building, you can use construct method.

If you want to upgrade or construct building, you need to get building enum from tkpy.

from tkpy import BuildingType

first_village = v['your first village'] # get your first village object
first_village.upgrade(building=BuildingType.MAIN_BUILDING) # upgrade main building
first_village.construct(buildng=BuildingType.WAREHOUSE) # construct warehouse

Farmlist

Farmlist object is like built-in dict object from Python so you can access farmlist using its name as key. To get farmlist data from Travian: Kingdom, you need to call pull method first. From Farmlist you can create new farmlist by calling create_farmlist.

from tkpy import Farmlist

f = Farmlist(driver)
f.pull()

f['Startup farm list']
<FarmlistEntry({'listId': '1631', 'listName': 'Startup farm list', ...})>

f.create_farmlist('new farmlist')
f['new farmlist']
<FarmlistEntry({'listId': '1632', 'listName': 'new farmlist', ...})>

From Farmlist object you can get FarmlistEntry object and from it you can add new village to the FarmlistEntry and send this FarmlistEntry.

f['Startup farm list'].add(villageId=536887296) # add village using village id to 'Startup farm list'
f['Startup farm list'].send(villageId=537051141) # send 'startup farm list' from village using village id

Notepad

Notepad is an object that when instantiate will create new notepad in game. Use message method for write new message.

from tkpy import Notepad

n = Notepad(driver) # new notepad will appear in game
n.message('this is new message on new notepad') # write message to the notepad

# careful, use `message` method will overwrite message previously on notepad
n.message('old message will be overwrited')

Documentation

For documentation, you can go to this wiki.

Disclaimer

Please note that this is a research project, i am by no means responsible for any usage of this utilities.
Use on your own behalf, i am also not responsible if your accounts get banned due to extensive use of this utilites.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkpy-0.0.1b4.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

tkpy-0.0.1b4-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file tkpy-0.0.1b4.tar.gz.

File metadata

  • Download URL: tkpy-0.0.1b4.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for tkpy-0.0.1b4.tar.gz
Algorithm Hash digest
SHA256 d21b1fb3ff788b4111ab6a51b5febe5d71f846f8b95ac28b69e5093bac9d0440
MD5 92f714cc049f92e20fa337cd6a3f0de4
BLAKE2b-256 82108b62c7e4ae2f1fc0ac42a4999bfa879625dd95aa7a079ec6fb4419a6d59c

See more details on using hashes here.

File details

Details for the file tkpy-0.0.1b4-py3-none-any.whl.

File metadata

  • Download URL: tkpy-0.0.1b4-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for tkpy-0.0.1b4-py3-none-any.whl
Algorithm Hash digest
SHA256 62edcbeb9b2641755a225ad886c74b1d3bf1b8269af6e877082344d2302d4e95
MD5 9f6925cc554dc5f64aba80ba879048b5
BLAKE2b-256 f18fa0b3ea4527d57fec1d6f27d9a9c3baa01ff64d0ec3e873adecd7412941a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page