dragon-city-utils


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