dragon-city-utils


Namedragon-city-utils JSON
Version 2.0.3 PyPI version JSON
download
home_page
SummaryDragon City Utils, a collection of tools and utilities for managing static assets and performing calculations related to the Dragon City game.
upload_time2024-02-06 15:19:01
maintainer
docs_urlNone
authorMarcuth
requires_python
licenseMIT License
keywords dragoncity dcutils tools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dragon-city-utils

Welcome to the documentation of Dragon City Utils, a collection of tools and utilities for managing static assets and performing calculations related to the game Dragon City. Below, you'll find detailed explanations and code snippets for various functionalities.

## Static Files

### Sprites

#### Dragon Sprite

You can download a dragon sprite using the following code:

```python
from dcutils.static.sprites import DragonSprite

dragon_sprite = DragonSprite(
    image_name = "1000_dragon_nature",
    phase = 3,
    skin = "skin1",
    image_quality = 2
)

dragon_sprite.download(output="dragon_nature_sprite.png")
```
#### Dragon Thumb

To download a dragon thumb:

```python
from dcutils.static.sprites import DragonThumb

dragon_thumb = DragonThumb(
    image_name = "1000_dragon_nature",
    phase = 3,
    skin = "skin1"
)

dragon_thumb.download(output="dragon_nature_thumb.png")
```

### Animations

#### Dragon Animation (Flash Animation)

To download a dragon flash animation:

```python
from dcutils.static.animations import DragonFlashAnimation

dragon_flash_animation = DragonFlashAnimation(
    image_name = "1000_dragon_nature",
    phase = 3,
    skin = "skin1"
)

dragon_flash_animation.download(output="dragon_nature_flash_animation.swf")
```

#### Dragon Animation (Spine Animation)

To download a dragon spine animation:

```python
from dcutils.static.animations import DragonSpineAnimation

dragon_spine_animation = DragonSpineAnimation(
    image_name = "1000_dragon_nature",
    phase = 3,
    skin = 1
)

dragon_spine_animation.download(output="dragon_spine_animation.zip")
```

### Island Packages

To download an island package:

```python
from dcutils.static.islands import IslandPackage

island_package = IslandPackage(uri = "/mobile/ui/heroicraces_islands/hr_71_heroicorigins.zip")

island_package.download(output = "island_package.zip")
```

### Sounds

#### Music

To download music:

```python
from dcutils.static.sounds import GeneralMusic

music = GeneralMusic(music_name = "531_dc_party_planning_island")

music.download(output = "531_dc_party_planning_island.mp3")
```

## Tools

### Calculators

#### Calculate Element Strengths

```python
from dcutils.tools.calculators import calculate_strongs

strongs = calculate_strongs(elements = ["terra", "flame"])
```
**Output:**
```
['electric', 'flame', 'nature', 'ice']
```

#### Calculate Element Weaknesses

```python
from dcutils.tools.calculators import calculate_weaknesses

weaknesses = calculate_weaknesses(first_element="terra")
```
**Output:**
```
['metal', 'war']
```

#### Calculate Orb Recall Gain

```python
from dcutils.tools.calculators import calculate_orb_recall_gain

orb_recall_gain = calculate_orb_recall_gain(dragon_level = 15, dragon_stars = 2)
```
**Output:**
```
389
```

### Calculate Attack Damage

You can calculate attack damage using the `calculate_attack_damage` function.

```python
from dcutils.tools.calculators.dragon import calculate_attack_damage

damage_info = calculate_attack_damage(
    category = 1,
    level = 50,
    attack_power=  1000,
    rank_class = 3,
    stars = 2
)
```

### Calculate

You can calculate dragon status using the `calculate_status` function.

```python
from dcutils.tools.calculators.dragon import calculate_status

status_info = calculate_status(
    category = 1,
    rarity = "R",
    level = 50,
    rank_class = 3,
    stars = 2,
    hp_runes = 5,
    damage_runes = 3,
    with_tower_bonus = True,
    extra_hp_multiplier=  0.1,
    extra_damage_multiplier = 0.05
)
```

### AI (Artificial Intelligence)

#### Elements Detector

```python
from dcutils.tools.ai.elements_detector import ElementsDetectorAI

elements_detector = ElementsDetectorAI()

elements_result = elements_detector.detect(image_path = "ui_3110_dragon_hoardereternal_1@2x.png", limit = 4)
```
**Output:**
```
[{'element': 'ice', 'confidence_score': 0.4871271550655365}, {'element': 'nature', 'confidence_score': 0.296091228723526}, {'element': 'flame', 'confidence_score': 0.16774502396583557}, {'element': 'sea', 'confidence_score': 0.03868602588772774}]
```

#### Phase Detector

```python 
from dcutils.tools.ai.phase_detector import PhaseDetectorAI

phase_detector = PhaseDetectorAI()

phase_result = phase_detector.detect(image_path="ui_3110_dragon_hoardereternal_1@2x.png")
```
**Output:**
```
{'phase': 'baby', 'confidence_score': 0.9999938011169434}
```

### URL Parser

#### Dragon URL Parser

You can parse various information from Dragon URLs:

```python
from dcutils.tools.url_parser.dragon import DragonUrlParser

# Example URLs
url_flash_animation = "https://dci-static-s1.socialpointgames.com/static/dragoncity/assets/sprites/1000_dragon_nature_skin1_3.swf"
url_spine_animation = "https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/engine/version_1_1/dragons/1000_dragon_nature_3/1000_dragon_nature_skin1_3_HD_tweened_dxt5.zip"
url_sprite = "https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/dragons/ui_1000_dragon_nature_skin1_3@2x.png"
url_thumb = "https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/dragons/HD/thumb_1000_dragon_nature_skin1_3.png"

# Parse from URLs
result_flash_animation = DragonUrlParser.from_flash_animation(url_flash_animation)
result_spine_animation = DragonUrlParser.from_spine_animation(url_spine_animation)
result_sprite = DragonUrlParser.from_sprite(url_sprite)
result_thumb = DragonUrlParser.from_thumb(url_thumb)

# Get specific information
dragon_id = DragonUrlParser.get_id(url_thumb)
image_name = DragonUrlParser.get_image_name(url_thumb)
image_quality = DragonUrlParser.get_image_quality(url_sprite)
phase = DragonUrlParser.get_phase(url_sprite)
skin = DragonUrlParser.get_skin(url_sprite)
```

Each function returns relevant information parsed from the given Dragon URL.

Feel free to explore these functionalities and integrate them into your projects!

## Localization

The `Localization` class allows you to handle localization data efficiently. You can load localization from files, fetch it from an endpoint, and perform various operations on the data.

```python
from dcutils.static.localization import Localization

# Example usage
loc = Localization(language = "en")
print(loc)
```

### Methods

#### load_file

Load localization data from a file.

```python
loc = Localization.load_file(file_path = "localization.json")
```

#### load_compressed_file

Load compressed localization data from a file.

```python
loc = Localization.load_compressed_file(file_path = "localization.gz")
```

#### fetch

Fetch localization data from an endpoint.

```python
loc_data = Localization.fetch(language = "en")
```

#### get_value_from_key

Get the value from a key in the localization data.

```python
value = loc.get_value_from_key("key_name")
```

#### get_key_from_value

Get the key from a value in the localization data.

```python
key = loc.get_key_from_value("value_name")
```

#### get_dragon_name

Get the name of a dragon based on its ID.

```python
name = loc.get_dragon_name(id = 1000)
```

#### get_dragon_description

Get the description of a dragon based on its ID.

```python
description = loc.get_dragon_description(id = 1000)
```

#### get_attack_name

Get the name of an attack based on its ID.

```python
name = loc.get_attack_name(id = 1)
```

#### get_skill_name

Get the name of a skill based on its ID.

```python
name = loc.get_skill_name(id = 1)
```

#### get_skill_description

Get the description of a skill based on its ID.

```python
description = loc.get_skill_description(id = 1)
```

#### search_keys

Search for keys containing a specific query.

```python
keys = loc.search_keys(query = "search_query")
```

#### search_values

Search for values containing a specific query.

```python
values = loc.search_values(query = "search_query")
```

#### compare

Compare the current localization data with old localization data.

```python
comparison = loc.compare(old_localization = old_loc)
```

### Properties

#### list

Get the localization data as a list.

```python
loc_list = loc.list
```

#### dict

Get the localization data as a dictionary.

```python
loc_dict = loc.dict
```

Feel free to explore these functionalities and integrate them into your projects!

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dragon-city-utils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "dragoncity dcutils tools",
    "author": "Marcuth",
    "author_email": "example@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/41/4d/b0bea333f54e81e44d46313c335e2c883b8cc2d820fe27ae58c1b4c49db6/dragon-city-utils-2.0.3.tar.gz",
    "platform": null,
    "description": "# dragon-city-utils\r\n\r\nWelcome to the documentation of Dragon City Utils, a collection of tools and utilities for managing static assets and performing calculations related to the game Dragon City. Below, you'll find detailed explanations and code snippets for various functionalities.\r\n\r\n## Static Files\r\n\r\n### Sprites\r\n\r\n#### Dragon Sprite\r\n\r\nYou can download a dragon sprite using the following code:\r\n\r\n```python\r\nfrom dcutils.static.sprites import DragonSprite\r\n\r\ndragon_sprite = DragonSprite(\r\n    image_name = \"1000_dragon_nature\",\r\n    phase = 3,\r\n    skin = \"skin1\",\r\n    image_quality = 2\r\n)\r\n\r\ndragon_sprite.download(output=\"dragon_nature_sprite.png\")\r\n```\r\n#### Dragon Thumb\r\n\r\nTo download a dragon thumb:\r\n\r\n```python\r\nfrom dcutils.static.sprites import DragonThumb\r\n\r\ndragon_thumb = DragonThumb(\r\n    image_name = \"1000_dragon_nature\",\r\n    phase = 3,\r\n    skin = \"skin1\"\r\n)\r\n\r\ndragon_thumb.download(output=\"dragon_nature_thumb.png\")\r\n```\r\n\r\n### Animations\r\n\r\n#### Dragon Animation (Flash Animation)\r\n\r\nTo download a dragon flash animation:\r\n\r\n```python\r\nfrom dcutils.static.animations import DragonFlashAnimation\r\n\r\ndragon_flash_animation = DragonFlashAnimation(\r\n    image_name = \"1000_dragon_nature\",\r\n    phase = 3,\r\n    skin = \"skin1\"\r\n)\r\n\r\ndragon_flash_animation.download(output=\"dragon_nature_flash_animation.swf\")\r\n```\r\n\r\n#### Dragon Animation (Spine Animation)\r\n\r\nTo download a dragon spine animation:\r\n\r\n```python\r\nfrom dcutils.static.animations import DragonSpineAnimation\r\n\r\ndragon_spine_animation = DragonSpineAnimation(\r\n    image_name = \"1000_dragon_nature\",\r\n    phase = 3,\r\n    skin = 1\r\n)\r\n\r\ndragon_spine_animation.download(output=\"dragon_spine_animation.zip\")\r\n```\r\n\r\n### Island Packages\r\n\r\nTo download an island package:\r\n\r\n```python\r\nfrom dcutils.static.islands import IslandPackage\r\n\r\nisland_package = IslandPackage(uri = \"/mobile/ui/heroicraces_islands/hr_71_heroicorigins.zip\")\r\n\r\nisland_package.download(output = \"island_package.zip\")\r\n```\r\n\r\n### Sounds\r\n\r\n#### Music\r\n\r\nTo download music:\r\n\r\n```python\r\nfrom dcutils.static.sounds import GeneralMusic\r\n\r\nmusic = GeneralMusic(music_name = \"531_dc_party_planning_island\")\r\n\r\nmusic.download(output = \"531_dc_party_planning_island.mp3\")\r\n```\r\n\r\n## Tools\r\n\r\n### Calculators\r\n\r\n#### Calculate Element Strengths\r\n\r\n```python\r\nfrom dcutils.tools.calculators import calculate_strongs\r\n\r\nstrongs = calculate_strongs(elements = [\"terra\", \"flame\"])\r\n```\r\n**Output:**\r\n```\r\n['electric', 'flame', 'nature', 'ice']\r\n```\r\n\r\n#### Calculate Element Weaknesses\r\n\r\n```python\r\nfrom dcutils.tools.calculators import calculate_weaknesses\r\n\r\nweaknesses = calculate_weaknesses(first_element=\"terra\")\r\n```\r\n**Output:**\r\n```\r\n['metal', 'war']\r\n```\r\n\r\n#### Calculate Orb Recall Gain\r\n\r\n```python\r\nfrom dcutils.tools.calculators import calculate_orb_recall_gain\r\n\r\norb_recall_gain = calculate_orb_recall_gain(dragon_level = 15, dragon_stars = 2)\r\n```\r\n**Output:**\r\n```\r\n389\r\n```\r\n\r\n### Calculate Attack Damage\r\n\r\nYou can calculate attack damage using the `calculate_attack_damage` function.\r\n\r\n```python\r\nfrom dcutils.tools.calculators.dragon import calculate_attack_damage\r\n\r\ndamage_info = calculate_attack_damage(\r\n    category = 1,\r\n    level = 50,\r\n    attack_power=  1000,\r\n    rank_class = 3,\r\n    stars = 2\r\n)\r\n```\r\n\r\n### Calculate\r\n\r\nYou can calculate dragon status using the `calculate_status` function.\r\n\r\n```python\r\nfrom dcutils.tools.calculators.dragon import calculate_status\r\n\r\nstatus_info = calculate_status(\r\n    category = 1,\r\n    rarity = \"R\",\r\n    level = 50,\r\n    rank_class = 3,\r\n    stars = 2,\r\n    hp_runes = 5,\r\n    damage_runes = 3,\r\n    with_tower_bonus = True,\r\n    extra_hp_multiplier=  0.1,\r\n    extra_damage_multiplier = 0.05\r\n)\r\n```\r\n\r\n### AI (Artificial Intelligence)\r\n\r\n#### Elements Detector\r\n\r\n```python\r\nfrom dcutils.tools.ai.elements_detector import ElementsDetectorAI\r\n\r\nelements_detector = ElementsDetectorAI()\r\n\r\nelements_result = elements_detector.detect(image_path = \"ui_3110_dragon_hoardereternal_1@2x.png\", limit = 4)\r\n```\r\n**Output:**\r\n```\r\n[{'element': 'ice', 'confidence_score': 0.4871271550655365}, {'element': 'nature', 'confidence_score': 0.296091228723526}, {'element': 'flame', 'confidence_score': 0.16774502396583557}, {'element': 'sea', 'confidence_score': 0.03868602588772774}]\r\n```\r\n\r\n#### Phase Detector\r\n\r\n```python \r\nfrom dcutils.tools.ai.phase_detector import PhaseDetectorAI\r\n\r\nphase_detector = PhaseDetectorAI()\r\n\r\nphase_result = phase_detector.detect(image_path=\"ui_3110_dragon_hoardereternal_1@2x.png\")\r\n```\r\n**Output:**\r\n```\r\n{'phase': 'baby', 'confidence_score': 0.9999938011169434}\r\n```\r\n\r\n### URL Parser\r\n\r\n#### Dragon URL Parser\r\n\r\nYou can parse various information from Dragon URLs:\r\n\r\n```python\r\nfrom dcutils.tools.url_parser.dragon import DragonUrlParser\r\n\r\n# Example URLs\r\nurl_flash_animation = \"https://dci-static-s1.socialpointgames.com/static/dragoncity/assets/sprites/1000_dragon_nature_skin1_3.swf\"\r\nurl_spine_animation = \"https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/engine/version_1_1/dragons/1000_dragon_nature_3/1000_dragon_nature_skin1_3_HD_tweened_dxt5.zip\"\r\nurl_sprite = \"https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/dragons/ui_1000_dragon_nature_skin1_3@2x.png\"\r\nurl_thumb = \"https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/dragons/HD/thumb_1000_dragon_nature_skin1_3.png\"\r\n\r\n# Parse from URLs\r\nresult_flash_animation = DragonUrlParser.from_flash_animation(url_flash_animation)\r\nresult_spine_animation = DragonUrlParser.from_spine_animation(url_spine_animation)\r\nresult_sprite = DragonUrlParser.from_sprite(url_sprite)\r\nresult_thumb = DragonUrlParser.from_thumb(url_thumb)\r\n\r\n# Get specific information\r\ndragon_id = DragonUrlParser.get_id(url_thumb)\r\nimage_name = DragonUrlParser.get_image_name(url_thumb)\r\nimage_quality = DragonUrlParser.get_image_quality(url_sprite)\r\nphase = DragonUrlParser.get_phase(url_sprite)\r\nskin = DragonUrlParser.get_skin(url_sprite)\r\n```\r\n\r\nEach function returns relevant information parsed from the given Dragon URL.\r\n\r\nFeel free to explore these functionalities and integrate them into your projects!\r\n\r\n## Localization\r\n\r\nThe `Localization` class allows you to handle localization data efficiently. You can load localization from files, fetch it from an endpoint, and perform various operations on the data.\r\n\r\n```python\r\nfrom dcutils.static.localization import Localization\r\n\r\n# Example usage\r\nloc = Localization(language = \"en\")\r\nprint(loc)\r\n```\r\n\r\n### Methods\r\n\r\n#### load_file\r\n\r\nLoad localization data from a file.\r\n\r\n```python\r\nloc = Localization.load_file(file_path = \"localization.json\")\r\n```\r\n\r\n#### load_compressed_file\r\n\r\nLoad compressed localization data from a file.\r\n\r\n```python\r\nloc = Localization.load_compressed_file(file_path = \"localization.gz\")\r\n```\r\n\r\n#### fetch\r\n\r\nFetch localization data from an endpoint.\r\n\r\n```python\r\nloc_data = Localization.fetch(language = \"en\")\r\n```\r\n\r\n#### get_value_from_key\r\n\r\nGet the value from a key in the localization data.\r\n\r\n```python\r\nvalue = loc.get_value_from_key(\"key_name\")\r\n```\r\n\r\n#### get_key_from_value\r\n\r\nGet the key from a value in the localization data.\r\n\r\n```python\r\nkey = loc.get_key_from_value(\"value_name\")\r\n```\r\n\r\n#### get_dragon_name\r\n\r\nGet the name of a dragon based on its ID.\r\n\r\n```python\r\nname = loc.get_dragon_name(id = 1000)\r\n```\r\n\r\n#### get_dragon_description\r\n\r\nGet the description of a dragon based on its ID.\r\n\r\n```python\r\ndescription = loc.get_dragon_description(id = 1000)\r\n```\r\n\r\n#### get_attack_name\r\n\r\nGet the name of an attack based on its ID.\r\n\r\n```python\r\nname = loc.get_attack_name(id = 1)\r\n```\r\n\r\n#### get_skill_name\r\n\r\nGet the name of a skill based on its ID.\r\n\r\n```python\r\nname = loc.get_skill_name(id = 1)\r\n```\r\n\r\n#### get_skill_description\r\n\r\nGet the description of a skill based on its ID.\r\n\r\n```python\r\ndescription = loc.get_skill_description(id = 1)\r\n```\r\n\r\n#### search_keys\r\n\r\nSearch for keys containing a specific query.\r\n\r\n```python\r\nkeys = loc.search_keys(query = \"search_query\")\r\n```\r\n\r\n#### search_values\r\n\r\nSearch for values containing a specific query.\r\n\r\n```python\r\nvalues = loc.search_values(query = \"search_query\")\r\n```\r\n\r\n#### compare\r\n\r\nCompare the current localization data with old localization data.\r\n\r\n```python\r\ncomparison = loc.compare(old_localization = old_loc)\r\n```\r\n\r\n### Properties\r\n\r\n#### list\r\n\r\nGet the localization data as a list.\r\n\r\n```python\r\nloc_list = loc.list\r\n```\r\n\r\n#### dict\r\n\r\nGet the localization data as a dictionary.\r\n\r\n```python\r\nloc_dict = loc.dict\r\n```\r\n\r\nFeel free to explore these functionalities and integrate them into your projects!\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Dragon City Utils, a collection of tools and utilities for managing static assets and performing calculations related to the Dragon City game.",
    "version": "2.0.3",
    "project_urls": null,
    "split_keywords": [
        "dragoncity",
        "dcutils",
        "tools"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "414db0bea333f54e81e44d46313c335e2c883b8cc2d820fe27ae58c1b4c49db6",
                "md5": "04093ac973f413f3a1f9ea3aec38db2e",
                "sha256": "98ce114b4dfd4413d9989b0c661016253de829dd8929cad8fd542aadc365a01d"
            },
            "downloads": -1,
            "filename": "dragon-city-utils-2.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "04093ac973f413f3a1f9ea3aec38db2e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26702,
            "upload_time": "2024-02-06T15:19:01",
            "upload_time_iso_8601": "2024-02-06T15:19:01.331699Z",
            "url": "https://files.pythonhosted.org/packages/41/4d/b0bea333f54e81e44d46313c335e2c883b8cc2d820fe27ae58c1b4c49db6/dragon-city-utils-2.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 15:19:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dragon-city-utils"
}
        
Elapsed time: 0.18215s