from core.chat_blob import ChatBlob
from core.command_param_types import Options
from core.decorators import instance, command
from core.text import Text
from core.translation_service import TranslationService


@instance()
class AlienGeneralController:
    def inject(self, registry):
        self.text: Text = registry.get_instance("text")
        self.items_controller = registry.get_instance("items_controller")
        self.ts: TranslationService = registry.get_instance("translation_service")
        self.getresp = self.ts.get_response

    @command(command="aigen", params=[], access_level="member",
             description="List alien city ground generals")
    def aigen_list_command(self, request):
        blob = ""
        blob += " - <a href='chatcmd:///tell <myname> aigen Ankari'>Ankari</a>\n"
        blob += " - <a href='chatcmd:///tell <myname> aigen Ilari'>Ilari</a>\n"
        blob += " - <a href='chatcmd:///tell <myname> aigen Rimah'>Rimah</a>\n"
        blob += " - <a href='chatcmd:///tell <myname> aigen Jaax'>Jaax</a>\n"
        blob += " - <a href='chatcmd:///tell <myname> aigen Xoch'>Xoch</a>\n"
        blob += " - <a href='chatcmd:///tell <myname> aigen Cha'>Cha</a>\n"

        return ChatBlob(self.getresp("module/alien", "ai_gen_list_title"), blob)

    @command(command="aigen",
             params=[Options(["ankari", "ilari", "rimah", "jaax", "xoch", "cha"])],
             access_level="member",
             description="Show info about an alien city ground general")
    def aigen_show_command(self, request, general):
        general = general.capitalize()

        blob = ""

        if general == "Ankari":
            blob += "Low Evade/Dodge, Low AR, Casts Viral/Virral nukes\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247145)) + "\n"  # Arithmetic Viralbots
            blob += "(Nanoskill / Tradeskill)\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247684)) + "\n\n"  # type 1
            blob += self.text.format_item(self.items_controller.get_by_item_id(247686)) + "\n\n"  # type 2
            blob += self.text.format_item(self.items_controller.get_by_item_id(288673))  # type 48
        elif general == "Ilari":
            blob += "Low Evade/Dodge\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247147)) + "\n"  # Spiritual Viralbots
            blob += "(Nanocost / Nanopool / Max Nano)\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247682)) + "\n\n"  # type 992
            blob += self.text.format_item(self.items_controller.get_by_item_id(247680))  # type 880
        elif general == "Rimah":
            blob += "Low Evade/Dodge\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247143)) + "\n"  # Observant Viralbots
            blob += "(Init / Evades)\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247676)) + "\n\n"  # type 112
            blob += self.text.format_item(self.items_controller.get_by_item_id(247678))  # type 240
        elif general == "Jaax":
            blob += "High Evade, Low Dodge\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247139)) + "\n"  # Strong Viralbots
            blob += "(Melee / Spec Melee / Add All Def / Add Damage)\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247694)) + "\n\n"  # type 3
            blob += self.text.format_item(self.items_controller.get_by_item_id(247688))  # type 4
        elif general == "Xoch":
            blob += "High Evade/Dodge, Casts Ilari Biorejuvenation heals\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247137)) + "\n"  # Enduring Viralbots
            blob += "(Max Health / Body Dev)\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247690)) + "\n\n"  # type 5
            blob += self.text.format_item(self.items_controller.get_by_item_id(247692))  # type 12
        elif general == "Cha":
            blob += "High Evade/NR, Low Dodge\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247141)) + "\n"  # Supple Viralbots
            blob += "(Ranged / Spec Ranged / Add All Off)\n\n"
            blob += self.text.format_item(self.items_controller.get_by_item_id(247696)) + "\n\n"  # type 13
            blob += self.text.format_item(self.items_controller.get_by_item_id(247674))  # type 76

        return ChatBlob(f"General {general}", blob)
