Package: dragon-city-utils
dragon-city-utilsWelcome 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 FilesSpritesDragon SpriteYou can download a dragon sprite using the following code:fromdcutils.static.spritesimportDragonSpritedragon_sprite=DragonSprite(image_name="1000_dragon_nature",phase=3,skin="skin1",image_quality=2)dragon_sprite.download(output="dragon_nature_sprite.png")Dragon ThumbTo download a dragon thumb:fromdcutils.static.spritesimportDragonThumbdragon_thumb=DragonThumb(image_name="1000_dragon_nature",phase=3,skin="skin1")dragon_thumb.download(output="dragon_nature_thumb.png")AnimationsDragon Animation (Flash Animation)To download a dragon flash animation:fromdcutils.static.animationsimportDragonFlashAnimationdragon_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:fromdcutils.static.animationsimportDragonSpineAnimationdragon_spine_animation=DragonSpineAnimation(image_name="1000_dragon_nature",phase=3,skin=1)dragon_spine_animation.download(output="dragon_spine_animation.zip")Island PackagesTo download an island package:fromdcutils.static.islandsimportIslandPackageisland_package=IslandPackage(uri="/mobile/ui/heroicraces_islands/hr_71_heroicorigins.zip")island_package.download(output="island_package.zip")SoundsMusicTo download music:fromdcutils.static.soundsimportGeneralMusicmusic=GeneralMusic(music_name="531_dc_party_planning_island")music.download(output="531_dc_party_planning_island.mp3")ToolsCalculatorsCalculate Element Strengthsfromdcutils.tools.calculatorsimportcalculate_strongsstrongs=calculate_strongs(elements=["terra","flame"])Output:['electric', 'flame', 'nature', 'ice']Calculate Element Weaknessesfromdcutils.tools.calculatorsimportcalculate_weaknessesweaknesses=calculate_weaknesses(first_element="terra")Output:['metal', 'war']Calculate Orb Recall Gainfromdcutils.tools.calculatorsimportcalculate_orb_recall_gainorb_recall_gain=calculate_orb_recall_gain(dragon_level=15,dragon_stars=2)Output:389Calculate Attack DamageYou can calculate attack damage using thecalculate_attack_damagefunction.fromdcutils.tools.calculators.dragonimportcalculate_attack_damagedamage_info=calculate_attack_damage(category=1,level=50,attack_power=1000,rank_class=3,stars=2)CalculateYou can calculate dragon status using thecalculate_statusfunction.fromdcutils.tools.calculators.dragonimportcalculate_statusstatus_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 Detectorfromdcutils.tools.ai.elements_detectorimportElementsDetectorAIelements_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 Detectorfromdcutils.tools.ai.phase_detectorimportPhaseDetectorAIphase_detector=PhaseDetectorAI()phase_result=phase_detector.detect(image_path="ui_3110_dragon_hoardereternal_1@2x.png")Output:{'phase': 'baby', 'confidence_score': 0.9999938011169434}URL ParserDragon URL ParserYou can parse various information from Dragon URLs:fromdcutils.tools.url_parser.dragonimportDragonUrlParser# Example URLsurl_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 URLsresult_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 informationdragon_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!LocalizationTheLocalizationclass 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.fromdcutils.static.localizationimportLocalization# Example usageloc=Localization(language="en")print(loc)Methodsload_fileLoad localization data from a file.loc=Localization.load_file(file_path="localization.json")load_compressed_fileLoad compressed localization data from a file.loc=Localization.load_compressed_file(file_path="localization.gz")fetchFetch localization data from an endpoint.loc_data=Localization.fetch(language="en")get_value_from_keyGet the value from a key in the localization data.value=loc.get_value_from_key("key_name")get_key_from_valueGet the key from a value in the localization data.key=loc.get_key_from_value("value_name")get_dragon_nameGet the name of a dragon based on its ID.name=loc.get_dragon_name(id=1000)get_dragon_descriptionGet the description of a dragon based on its ID.description=loc.get_dragon_description(id=1000)get_attack_nameGet the name of an attack based on its ID.name=loc.get_attack_name(id=1)get_skill_nameGet the name of a skill based on its ID.name=loc.get_skill_name(id=1)get_skill_descriptionGet the description of a skill based on its ID.description=loc.get_skill_description(id=1)search_keysSearch for keys containing a specific query.keys=loc.search_keys(query="search_query")search_valuesSearch for values containing a specific query.values=loc.search_values(query="search_query")compareCompare the current localization data with old localization data.comparison=loc.compare(old_localization=old_loc)PropertieslistGet the localization data as a list.loc_list=loc.listdictGet the localization data as a dictionary.loc_dict=loc.dictFeel free to explore these functionalities and integrate them into your projects!