{ "info": { "author": "didadadida93", "author_email": "didadadida93@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Utilities" ], "description": "--- \n# tkpy\n\n[Travian: Kingdom](https://www.kingdoms.com) (TK) utilities for your need. It provide several object that mostly used on TK such as `Map`, `Villages`, `Notepad`, and `Farmlist`. \n\n[![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) \n\n--- \n# Installation \n>It is recommended to use [virtualenv](https://docs.python-guide.org/dev/virtualenvs/).\n\nSince `tkpy` depend on `primordial` package, first install [primordial package](https://github.com/lijok/primordial). \nAfter that, run `tkpy-init` for create database that will be used for storing `Gameworld` object.\n\n```sh\n(venv)$ pip install git+https://github.com/lijok/primordial.git\n(venv)$ pip install tkpy\n(venv)$ tkpy-init\n```\n\n--- \n# Getting started \n`tkpy` need `Gameworld` object so it can get data from TK. Use `login` function for retrieve `Gameworld` object. \n```python\nfrom tkpy import login\n\ndriver = login(email='your@email.com', password='your password', gameworld='com12')\n\n# login as sitter or dual\ndriver = login(\n email='your@email.com',\n password='your password',\n gameworld='dual/sitter gameworld',\n avatar='avatar name of sitter/dual account'\n)\n\n# once you have `Gameworld` object, you can use another object of tkpy.\n\nfrom tkpy import Map\n\nm = Map(driver)\nm.pull() # pulling map data\n\nm.coordinate(0, 0)\n\n\nunoccupied_oasis_list = [oasis for oasis in m.oasis if oasis['oasis']['oasisStatus'] == '3']\nunoccupied_oasis_list[0]\n\n\n``` \n--- \n# Usage \n## Map \n * `Map` object provide you an easy way to access data from TK map by using `pull` method.\n\n ```python\n from tkpy import Map\n\n m = Map(driver)\n m.pull()\n ```\n\n * Once you pulling map data, you can access every cell by using `coordinate` method.\n\n ```python\n m.coordinate(0, 0)\n \n ```\n\n * Since TK provide you player data, and kingdom data when you pulling map data, `Map` object also provide you easy way to access this kind of data.\n\n ```python\n m.player('player name')\n \n\n m.kingdom('kingdom name')\n \n ```\n\n * `Map` object have property that act as generator function and yield `Cell` object so you can get all data from every cell.\n\n ```python\n cell_list = list(m.cell)\n ``` \n > Side note for `Map.cell` property: \n > Some `Cell` object have different data. Once with village data while another didn't have village data. \n > Finding specific cell through `Map.cell` property may cause `KeyError Exception`. To prevent this use `try except` clause.\n >\n > ```python\n > for cell in m.cell:\n > try:\n > village = cell['village']\n > except KeyError: # this cell didn't have village data\n > continue\n > ...\n > ```\n\n * `Map` object also have property that filter cell data so it only give specific data.\n\n ```python\n # make a list of cell that have village data on it\n villages = list(m.villages)\n\n # make a list of cell that have oasis data on it\n oasis = list(m.oasis)\n\n # make a list of cell that have 15c and 9c but didn't have village data on it (unsettled croppers)\n croppers = [tile for tile in m.tiles if tile['resType'] == '3339' or tile['resType'] == '11115']\n\n # make a list of cell that have village data on it and have population lower than 100\n village_list = [village for village in m.villages if int(village['village']['population']) < 100]\n ```\n\n * There is a property for generate player and kingdom data too\n\n ```python\n # make a list of inactive player\n inactive_list = [player for player in m.players if player.is_active is False]\n\n # make a list of kingdoms data\n kingdoms = list(m.kingdoms)\n ``` \n---\n## Villages\n `Villages` object provide you an easy way to access every village that you have in game by using village name. \n But first `Villages` object need to pull data from TK.\n\n ```python\n from tkpy import Villages\n\n villages = Villages(driver)\n villages.pull()\n\n villages['my first village']\n \n\n # with `Village` object you can do several think, such as:\n # attack village at coordinate (0, 0)\n villages['my first village'].attack(0, 0, units={'1':-1, '11': 1})\n\n # defend another village at (0, 0)\n villages['my first village'].defend(0, 0, units={'1': -1, '2': -1, '11': 1})\n\n # raid another village at (0, 0)\n villages['my first village'].raid(0, 0, units={'1': 100})\n\n # siege another village at (0, 0)\n villages['my first village'].siege(0, 0, units={'1': -1, '6': -1, '7': -1, '11': 1})\n\n # upgrade building\n villages['my first village'].upgrade('main building')\n ```\n > Side note for `Villages` object: \n > As you already know, you can naming your village with same name _(like 'my village' and 'my village')_. \n > The problem is `Villages` object can't access this 2 kind of `Village` object with same name, \n > in result `Villages` object will randomly return `Village` object that have same name.\n\n--- \n## Farmlist\n `Farmlist` provide you an easy way to access in game farmlist by using farmlist name. \n First `Farmlist` object need to pull data from TK.\n ```python\n from tkpy import Farmlist\n\n farmlist = Farmlist(driver)\n farmlist.pull()\n\n # after that you can access `FarmlistEntry` object use name of farmlist\n farmlist['Startup farm list']\n \n\n # you can create a new farmlist use `create_farmlist` method\n farmlist.create_farmlist(name='new farmlist')\n\n # now you can access new farmlist use it's name\n farmlist['new farmlist']\n \n\n # through `FarmlistEntry` object you can add, and toggle village use villageId\n farmlist['Startup farm list'].add(villageId=537313245)\n farmlist['Startup farm list'].toggle(villageId=537313245)\n ```\n > Side note for `Farmlist` object: \n > As you already know, you can naming your farmlist with same name _(like 'farmlist 1', and 'farmlist 1')_. \n > The problem is `Farmlist` object can't access this 2 kind of `FarmlistEntry` object with same name, \n > in result `Farmlist` object will randomly return `FarmlistEntry` object that have same name.\n\n--- \n## Notepad\n `Notepad` is an object that when instantiate will create a new notepad in game. \n ```python\n from tkpy import Notepad\n\n notepad = Notepad(driver) # new notepad will appear in game\n\n # message method will write your message to notepad\n notepad.message('this is new message on new notepad')\n\n # careful, use message method will overwrite message that previously on notepad\n notepad.message('this message will overwrite with old one.')\n ```\n--- \n# Document\nFor documentation, visit [tkpy wiki](https://github.com/didadadida93/tkpy/wiki).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/didadadida93/tkpy", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "tkpy", "package_url": "https://pypi.org/project/tkpy/", "platform": "", "project_url": "https://pypi.org/project/tkpy/", "project_urls": { "Homepage": "https://github.com/didadadida93/tkpy" }, "release_url": "https://pypi.org/project/tkpy/0.0.1a1/", "requires_dist": [ "requests" ], "requires_python": "", "summary": "Travian: Kingdom utilities for your need.", "version": "0.0.1a1" }, "last_serial": 5660747, "releases": { "0.0.1a1": [ { "comment_text": "", "digests": { "md5": "e1b7eee00747660da37bf959aaff369b", "sha256": "06801c445d872cfa8a1655616802e293de0c250489d63cf0b2260d3277c342b8" }, "downloads": -1, "filename": "tkpy-0.0.1a1-py3-none-any.whl", "has_sig": false, "md5_digest": "e1b7eee00747660da37bf959aaff369b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 22735, "upload_time": "2019-08-11T01:54:19", "url": "https://files.pythonhosted.org/packages/03/19/285951c5c7794da9f14cec78b89a1dd4cd3ad6036e9de31f0adc96b9d00e/tkpy-0.0.1a1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "49115a4b52dc02b8c201852f417a02c2", "sha256": "1ecf30493adcdcd726250660bcbb3f4b0d70b3f71e9c23643454b792350b0ca0" }, "downloads": -1, "filename": "tkpy-0.0.1a1.tar.gz", "has_sig": false, "md5_digest": "49115a4b52dc02b8c201852f417a02c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21309, "upload_time": "2019-08-11T01:54:30", "url": "https://files.pythonhosted.org/packages/fa/a0/b8155e7b0b22732fedf6cd76603cd306b230c9534a96c3be052251627074/tkpy-0.0.1a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e1b7eee00747660da37bf959aaff369b", "sha256": "06801c445d872cfa8a1655616802e293de0c250489d63cf0b2260d3277c342b8" }, "downloads": -1, "filename": "tkpy-0.0.1a1-py3-none-any.whl", "has_sig": false, "md5_digest": "e1b7eee00747660da37bf959aaff369b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 22735, "upload_time": "2019-08-11T01:54:19", "url": "https://files.pythonhosted.org/packages/03/19/285951c5c7794da9f14cec78b89a1dd4cd3ad6036e9de31f0adc96b9d00e/tkpy-0.0.1a1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "49115a4b52dc02b8c201852f417a02c2", "sha256": "1ecf30493adcdcd726250660bcbb3f4b0d70b3f71e9c23643454b792350b0ca0" }, "downloads": -1, "filename": "tkpy-0.0.1a1.tar.gz", "has_sig": false, "md5_digest": "49115a4b52dc02b8c201852f417a02c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21309, "upload_time": "2019-08-11T01:54:30", "url": "https://files.pythonhosted.org/packages/fa/a0/b8155e7b0b22732fedf6cd76603cd306b230c9534a96c3be052251627074/tkpy-0.0.1a1.tar.gz" } ] }