tkpy


Nametkpy JSON
Version 0.0.1b4 PyPI version JSON
download
home_pagehttps://github.com/didadadida93/tkpy
SummaryTravian: Kingdom utilities for your need.
upload_time2020-08-06 09:09:07
maintainer
docs_urlNone
authordidadadida93
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tkpy

[Travian: Kingdom](https://www.kingdoms.com) utilities for your need.  
It provide several object that mostly used on Travian: Kingdom such as `Map`, `Villages`, `Notepad`, and `Farmlist`.  

[![PyPI version](https://badge.fury.io/py/tkpy.svg)](https://pypi.org/project/tkpy/) [![Python 3.6](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/release/python-367/) [![Build Status](https://travis-ci.org/didadadida93/tkpy.svg?branch=master)](https://travis-ci.org/didadadida93/tkpy) [![codecov](https://codecov.io/gh/didadadida93/tkpy/branch/master/graph/badge.svg)](https://codecov.io/gh/didadadida93/tkpy) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)

## Table of Contents
* [Installation](https://github.com/didadadida93/tkpy#installation)
* [Getting started](https://github.com/didadadida93/tkpy#getting-started)
* [Usage](https://github.com/didadadida93/tkpy#usage)
    * [Map](https://github.com/didadadida93/tkpy#map)
    * [Villages](https://github.com/didadadida93/tkpy#villages)
    * [Farmlist](https://github.com/didadadida93/tkpy#farmlist)
    * [Notepad](https://github.com/didadadida93/tkpy#notepad)
* [Documentation](https://github.com/didadadida93/tkpy#documentation)
* [Disclaimer](https://github.com/didadadida93/tkpy#disclaimer)
* [Changelog](https://github.com/didadadida93/tkpy/blob/master/CHANGELOG.md)

## Installation

>It is recommended to use [virtualenv](https://docs.python-guide.org/dev/virtualenvs/) or any other similar virtual environment management for python.

Since `tkpy` depend on `primordial` package, first you need to install [primordial package](https://github.com/didadadida93/primordial).

```sh
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.  

```python
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.

```python
from tkpy import Map

m = Map(driver)
m.pull()
```

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

```python
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.

```python
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.

```python
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.

```python
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.
```python
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.

```python
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`.

```python
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`.

```python
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`.

```python
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`.

```python
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.

```python
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](https://github.com/didadadida93/tkpy/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._



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/didadadida93/tkpy",
    "name": "tkpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "didadadida93",
    "author_email": "didadadida93@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/82/10/8b62c7e4ae2f1fc0ac42a4999bfa879625dd95aa7a079ec6fb4419a6d59c/tkpy-0.0.1b4.tar.gz",
    "platform": "",
    "description": "# tkpy\n\n[Travian: Kingdom](https://www.kingdoms.com) utilities for your need.  \nIt provide several object that mostly used on Travian: Kingdom such as `Map`, `Villages`, `Notepad`, and `Farmlist`.  \n\n[![PyPI version](https://badge.fury.io/py/tkpy.svg)](https://pypi.org/project/tkpy/) [![Python 3.6](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/release/python-367/) [![Build Status](https://travis-ci.org/didadadida93/tkpy.svg?branch=master)](https://travis-ci.org/didadadida93/tkpy) [![codecov](https://codecov.io/gh/didadadida93/tkpy/branch/master/graph/badge.svg)](https://codecov.io/gh/didadadida93/tkpy) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\n## Table of Contents\n* [Installation](https://github.com/didadadida93/tkpy#installation)\n* [Getting started](https://github.com/didadadida93/tkpy#getting-started)\n* [Usage](https://github.com/didadadida93/tkpy#usage)\n    * [Map](https://github.com/didadadida93/tkpy#map)\n    * [Villages](https://github.com/didadadida93/tkpy#villages)\n    * [Farmlist](https://github.com/didadadida93/tkpy#farmlist)\n    * [Notepad](https://github.com/didadadida93/tkpy#notepad)\n* [Documentation](https://github.com/didadadida93/tkpy#documentation)\n* [Disclaimer](https://github.com/didadadida93/tkpy#disclaimer)\n* [Changelog](https://github.com/didadadida93/tkpy/blob/master/CHANGELOG.md)\n\n## Installation\n\n>It is recommended to use [virtualenv](https://docs.python-guide.org/dev/virtualenvs/) or any other similar virtual environment management for python.\n\nSince `tkpy` depend on `primordial` package, first you need to install [primordial package](https://github.com/didadadida93/primordial).\n\n```sh\npip install git+https://github.com/didadadida93/tkpy.git\n```\n\n## Getting started\n\n`tkpy` need `Gameworld` object from `primordial` package so it can request data from Travian: Kingdom. Use `authenticate` function to retrieve `Gameworld` object.  \n\n```python\nfrom tkpy import authenticate\n\ndriver = authenticate(email='your@email.com', password='your password', gameworld='com12')\n```  \n\n## Usage\n### Map\n\nMap object is an object for keeping map data from Travian: Kingdom.  \nTo get map data from Travian: Kingdom, you need to call `pull` method.\n\n```python\nfrom tkpy import Map\n\nm = Map(driver)\nm.pull()\n```\n\nOnce you call `pull` method, now you can get all tiles data using several method.\n\n```python\nall_villages = list(m.gen_villages()) # get all villages from map\nabandoned_valleys = list(m.gen_abandoned_valley()) # get all unsettled tiles from map\noases = list(m.gen_oases()) # get all oases from map\ngrey_villages = list(m.gen_grey_villages()) # get all grey villages from map\n```\n\nOr if you want to get data from specific tile, you can use `coordinate` method.\n\n```python\nm.coordinate(0, 0)\n<Cell({'id': '536887296', 'landscape': '9013', 'owner': '0'})>\n```\n\nWhen 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.\n\n```python\nplayer_list = list(m.gen_players()) # get all players\nkingdom_list = list(m.gen_kingdoms()) # get all kingdoms\ninactive_player_list = list(m.gen_inactive_players()) # get all inactive players\n```\n\nIf you want to get data from specific player or kingdom, you can use `get_player` method and `get_kingdom` method.\n\n```python\nm.get_player('player name')\n<Player({'name': 'player name', 'country': 'en', 'tribeId': '1', ...})>\n\nm.get_kingdom('kingdom name')\n<Kingdom({'tag': 'kingdom name', 'kingdomId': '9999'})>\n```\n\nIf you want to slice map data based on the area of your interest, you can use `slice_map` method.\n```python\nsliced_map = m.slice_map(center=(0, 0), radius=5)\n\n# now you can do the same thing as `Map` object\ngrey_villages = list(sliced_map.gen_grey_villages())\n```\n\n### Villages\nVillages 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.\n\n```python\nfrom tkpy import Villages\n\nv = Villages(driver)\nv.pull()\n\nv['your first village']\n<Village({'villageId': '537313245', 'playerId': '001', 'name': 'my first village',...})>\n```\n\nFrom `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`.\n\n> If you want to attack, you need to get troop enum from `tkpy`.\n\n```python\nfrom tkpy import RomanTroop # if you are a Roman tribe\n\nfirst_village = v['your first village'] # get your first village object\nunits_siege = {RomanTroop.IMPERIAN: 1000, RomanTroop.BATTERING_RAM: 1} # prepare unit\nunits_attack = {RomanTroop.LEGIONNAIRE: 1000} # prepare unit\nunits_raid = {RomanTroop.EQUITES_IMPERATORIS: 50} # prepare unit\nunits_defend = {RomanTroop.PRAETORIAN: 1000} # prepare unit\n\nfirst_village.send_siege(x=0, y=0, units=units_siege) # send siege\nfirst_village.send_attack(x=0, y=0, units=units_attack) # send attack\nfirst_village.send_raid(x=0, y=0, units=units_raid) # send raid\nfirst_village.send_spy(x=0, y=0, amount=1) # send spy\nfirst_village.send_defend(x=0, y=0, untis=unts_defend) # send defend\n```\n\nFrom `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.\n\n> If you want to upgrade or construct building, you need to get building enum from `tkpy`.\n\n```python\nfrom tkpy import BuildingType\n\nfirst_village = v['your first village'] # get your first village object\nfirst_village.upgrade(building=BuildingType.MAIN_BUILDING) # upgrade main building\nfirst_village.construct(buildng=BuildingType.WAREHOUSE) # construct warehouse\n```\n\n### Farmlist\n`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`.\n\n```python\nfrom tkpy import Farmlist\n\nf = Farmlist(driver)\nf.pull()\n\nf['Startup farm list']\n<FarmlistEntry({'listId': '1631', 'listName': 'Startup farm list', ...})>\n\nf.create_farmlist('new farmlist')\nf['new farmlist']\n<FarmlistEntry({'listId': '1632', 'listName': 'new farmlist', ...})>\n```\n\nFrom `Farmlist` object you can get `FarmlistEntry` object and from it you can add new village to the `FarmlistEntry`  and send this `FarmlistEntry`.\n\n```python\nf['Startup farm list'].add(villageId=536887296) # add village using village id to 'Startup farm list'\nf['Startup farm list'].send(villageId=537051141) # send 'startup farm list' from village using village id\n```\n\n### Notepad\n`Notepad` is an object that when instantiate will create new notepad in game. Use `message` method for write new message.\n\n```python\nfrom tkpy import Notepad\n\nn = Notepad(driver) # new notepad will appear in game\nn.message('this is new message on new notepad') # write message to the notepad\n\n# careful, use `message` method will overwrite message previously on notepad\nn.message('old message will be overwrited')\n```\n\n## Documentation\nFor documentation, you can go to this [wiki](https://github.com/didadadida93/tkpy/wiki).\n\n## Disclaimer\n_Please note that this is a research project, i am by no means responsible for any usage of this utilities._  \n_Use on your own behalf, i am also not responsible if your accounts get banned due to extensive use of this utilites._\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Travian: Kingdom utilities for your need.",
    "version": "0.0.1b4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9f6925cc554dc5f64aba80ba879048b5",
                "sha256": "62edcbeb9b2641755a225ad886c74b1d3bf1b8269af6e877082344d2302d4e95"
            },
            "downloads": -1,
            "filename": "tkpy-0.0.1b4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9f6925cc554dc5f64aba80ba879048b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 24453,
            "upload_time": "2020-08-06T09:09:05",
            "upload_time_iso_8601": "2020-08-06T09:09:05.811968Z",
            "url": "https://files.pythonhosted.org/packages/f1/8f/a0b3ea4527d57fec1d6f27d9a9c3baa01ff64d0ec3e873adecd7412941a4/tkpy-0.0.1b4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "92f714cc049f92e20fa337cd6a3f0de4",
                "sha256": "d21b1fb3ff788b4111ab6a51b5febe5d71f846f8b95ac28b69e5093bac9d0440"
            },
            "downloads": -1,
            "filename": "tkpy-0.0.1b4.tar.gz",
            "has_sig": false,
            "md5_digest": "92f714cc049f92e20fa337cd6a3f0de4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22985,
            "upload_time": "2020-08-06T09:09:07",
            "upload_time_iso_8601": "2020-08-06T09:09:07.810781Z",
            "url": "https://files.pythonhosted.org/packages/82/10/8b62c7e4ae2f1fc0ac42a4999bfa879625dd95aa7a079ec6fb4419a6d59c/tkpy-0.0.1b4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-08-06 09:09:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "didadadida93",
    "error": "Could not fetch GitHub repository",
    "lcname": "tkpy"
}
        
Elapsed time: 0.16767s