Package: tkpy
tkpyTravian: Kingdomutilities for your need.It provide several object that mostly used on Travian: Kingdom such asMap,Villages,Notepad, andFarmlist.Table of ContentsInstallationGetting startedUsageMapVillagesFarmlistNotepadDocumentationDisclaimerChangelogInstallationIt is recommended to usevirtualenvor any other similar virtual environment management for python.Sincetkpydepend onprimordialpackage, first you need to installprimordial package.pipinstallgit+https://github.com/didadadida93/tkpy.gitGetting startedtkpyneedGameworldobject fromprimordialpackage so it can request data from Travian: Kingdom. Useauthenticatefunction to retrieveGameworldobject.fromtkpyimportauthenticatedriver=authenticate(email='your@email.com',password='your password',gameworld='com12')UsageMapMap object is an object for keeping map data from Travian: Kingdom.To get map data from Travian: Kingdom, you need to callpullmethod.fromtkpyimportMapm=Map(driver)m.pull()Once you callpullmethod, now you can get all tiles data using several method.all_villages=list(m.gen_villages())# get all villages from mapabandoned_valleys=list(m.gen_abandoned_valley())# get all unsettled tiles from mapoases=list(m.gen_oases())# get all oases from mapgrey_villages=list(m.gen_grey_villages())# get all grey villages from mapOr if you want to get data from specific tile, you can usecoordinatemethod.m.coordinate(0,0)<Cell({'id':'536887296','landscape':'9013','owner':'0'})>When you callpullmethod, 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 playerskingdom_list=list(m.gen_kingdoms())# get all kingdomsinactive_player_list=list(m.gen_inactive_players())# get all inactive playersIf you want to get data from specific player or kingdom, you can useget_playermethod andget_kingdommethod.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 useslice_mapmethod.sliced_map=m.slice_map(center=(0,0),radius=5)# now you can do the same thing as `Map` objectgrey_villages=list(sliced_map.gen_grey_villages())VillagesVillages object is like built-indictobject fromPythonso you can access the village using its name as key. To get village data from Travian: Kingdom, you need to callpullmethod first.fromtkpyimportVillagesv=Villages(driver)v.pull()v['your first village']<Village({'villageId':'537313245','playerId':'001','name':'my first village',...})>FromVillagesobject you can getVillageobject and from this object you can dosend_attack,send_raid,send_defend,send_spy, andsend_siege.If you want to attack, you need to get troop enum fromtkpy.fromtkpyimportRomanTroop# if you are a Roman tribefirst_village=v['your first village']# get your first village objectunits_siege={RomanTroop.IMPERIAN:1000,RomanTroop.BATTERING_RAM:1}# prepare unitunits_attack={RomanTroop.LEGIONNAIRE:1000}# prepare unitunits_raid={RomanTroop.EQUITES_IMPERATORIS:50}# prepare unitunits_defend={RomanTroop.PRAETORIAN:1000}# prepare unitfirst_village.send_siege(x=0,y=0,units=units_siege)# send siegefirst_village.send_attack(x=0,y=0,units=units_attack)# send attackfirst_village.send_raid(x=0,y=0,units=units_raid)# send raidfirst_village.send_spy(x=0,y=0,amount=1)# send spyfirst_village.send_defend(x=0,y=0,untis=unts_defend)# send defendFromVillageobject you can also upgrade building that on the village by usingupgrademethod. And if you want to construct building, you can useconstructmethod.If you want to upgrade or construct building, you need to get building enum fromtkpy.fromtkpyimportBuildingTypefirst_village=v['your first village']# get your first village objectfirst_village.upgrade(building=BuildingType.MAIN_BUILDING)# upgrade main buildingfirst_village.construct(buildng=BuildingType.WAREHOUSE)# construct warehouseFarmlistFarmlistobject is like built-indictobject fromPythonso you can access farmlist using its name as key. To get farmlist data from Travian: Kingdom, you need to callpullmethod first. FromFarmlistyou can create new farmlist by callingcreate_farmlist.fromtkpyimportFarmlistf=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',...})>FromFarmlistobject you can getFarmlistEntryobject and from it you can add new village to theFarmlistEntryand send thisFarmlistEntry.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 idNotepadNotepadis an object that when instantiate will create new notepad in game. Usemessagemethod for write new message.fromtkpyimportNotepadn=Notepad(driver)# new notepad will appear in gamen.message('this is new message on new notepad')# write message to the notepad# careful, use `message` method will overwrite message previously on notepadn.message('old message will be overwrited')DocumentationFor documentation, you can go to thiswiki.DisclaimerPlease 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.