#textdomain wesnoth

# This is AI test scenario which is not visible to casual player.
# It should not be translateable
[test]
    id=ai_arena_small
    name= "AI Arena - small"
    description= "Small ai arena"
    map_data="{ai/maps/scenario-AI_Arena_small.map}"
    random_start_time="no"
    turns=-1

    {DEFAULT_SCHEDULE}
    {DEFAULT_MUSIC_PLAYLIST}

    {PLACE_IMAGE items/burial.png 15 13}
    {PLACE_IMAGE items/burial.png 26 16}
    {PLACE_IMAGE items/burial.png 4 9}

    [event]
        name=preload
        first_time_only=no
        [lua]
            code = <<
            H = wesnoth.dofile("lua/helper.lua")
            W = H.set_wml_action_metatable({})
            H.set_wml_var_metatable(_G)
            local tests_table = {}
            function register_test(_name, _description)
            tests_table[_name] = _description
            end
            function get_tests_table()
            return tests_table
            end
            >>
        [/lua]
    [/event]

    [event]
        name=preload
        first_time_only=no
        [set_variable]
            name=test_path_to_ai
            value=ai/ais/default_ai.cfg
        [/set_variable]
        [set_variable]
            name=test_path_to_idle_ai
            value=ai/dev/idle_ai.cfg
        [/set_variable]
        [set_variable]
            name=test_path_to_default_ai
            value=ai/ais/default_ai.cfg
        [/set_variable]
        [set_variable]
            name=test_path_to_formula_ai
            value=ai/ais/formula_ai.cfg
        [/set_variable]
        [set_variable]
            name=test_path_to_testing_ai_default
            value=ai/dev/testing_ai_default.cfg
        [/set_variable]
        [set_variable]
            name=test_id
            value=0002-poisoning
        [/set_variable]

        [set_menu_item]
            id=repeat_test
            description="Repeat last test"
            [command]
                [fire_event]
                    name="_clean_arena"
                [/fire_event]
                [fire_event]
                    name="_replace_ai_2"
                [/fire_event]
                [lua]
                    code= <<  W.fire_event {name=wesnoth.get_variable("test_id") } >>
                [/lua]
            [/command]
        [/set_menu_item]

        [set_menu_item]
            id=select_another_ai
            description="Select another ai"
            [command]
                [fire_event]
                    name=_select_challenger_ai
                [/fire_event]
            [/command]
        [/set_menu_item]

        [set_menu_item]
            id=select_test
            description="Select another test"
            [command]
                [fire_event]
                    name=_select_test
                [/fire_event]
            [/command]
        [/set_menu_item]
    [/event]

    {ai/scenarios/ai_arena_small/}

    [side]
        side=1
        name="AI Developer"
        type=Nightgaunt
        canrecruit=yes
        controller=human
        team_name=master
        user_team_name= "AI Developer"
        fog=no
        [modifications]
            {TRAIT_INTELLIGENT}
            {TRAIT_QUICK}
            {TRAIT_LOYAL}
        [/modifications]
    [/side]
    [side]
        side=2
        name="Challenger AI"
        type=White Mage
        canrecruit=yes
        controller=ai
        team_name=north
        user_team_name= "North"
        fog=yes
    [/side]
    [side]
        side=3
        name="Champion AI"
        type=Dark Adept
        canrecruit=yes
        controller=ai
        team_name=south
        user_team_name= "South"
        fog=yes
    [/side]

    [event]
        name=_select_test
        first_time_only=no
        [command]
            [fire_event]
                name="_clean_arena"
            [/fire_event]
        [/command]
        [lua]
            code= <<
            local opts = {}
            for k,v in pairs(get_tests_table()) do
            local cmd = { "command", {{ "set_variable", {name="test_id", value= k } } } }
            table.insert(opts, { "option", { message = v, cmd } } )
            end
            W.message { speaker="narrator", message="Which test do you want to run, oh Mightly AI Developer?", unpack(opts) }
            >>
        [/lua]
        [command]
            [fire_event]
                name="_replace_ai_2"
            [/fire_event]
        [/command]
        [lua]
            code= <<  W.fire_event {name=wesnoth.get_variable("test_id") } >>
        [/lua]
    [/event]

    [event]
        name=_select_challenger_ai
        first_time_only=no

        [message]
            speaker=narrator
            message="Which AI do you want to use, oh Mightly AI Developer ?"
            [option]
                message="I am happy with the current AI of team 2, [$test_path_to_ai]"
            [/option]
            [option]
                message="My AI is TESTING AI DEFAULT, implemented as ai_composite."
                [command]
                    [set_variable]
                        name=test_path_to_ai
                        value=$test_path_to_testing_ai_default
                    [/set_variable]
                [/command]
            [/option]
            [option]
                message="My AI is DEFAULT AI, and it strikes fear into the hearts of mortals."
                [command]
                    [set_variable]
                        name=test_path_to_ai
                        value=$test_path_to_default_ai
                    [/set_variable]
                [/command]
            [/option]
            [option]
                message="I am the king of FORMULA AI, and I will use its vast powers for world domination."
                [command]
                    [set_variable]
                        name=test_path_to_ai
                        value=$test_path_to_formula_ai
                    [/set_variable]
                [/command]
            [/option]
            [option]
                message="I've come with my own AI, and I am ready to test its strength"
                [command]
                    [message]
                        speaker=narrator
                        message="and where is it located ? (path follows the usual WML convention)"
                        [text_input]
                            label="AI Location:"
                            variable="test_path_to_ai"
                        [/text_input]
                    [/message]
                [/command]
            [/option]
            [option]
                message="I want to test formulaAI-based poisoning improvements"
                [command]
                    [set_variable]
                        name=test_path_to_ai
                        value=ai/dev/formula_ai_poisoning.cfg
                    [/set_variable]
                [/command]
            [/option]
        [/message]
        [command]
            [fire_event]
                name="_replace_ai_2"
            [/fire_event]
        [/command]
        [command]
            {TELEPORT_TILE 6 21 5 22}
        [/command]
    [/event]

    [event]
        name=_clean_arena
        first_time_only=no
        [kill]
            animate=no
            fire_event=no
            canrecruit=no
        [/kill]
        [capture_village]
            x,y=5,9
        [/capture_village]
        [capture_village]
            x,y=6,19
        [/capture_village]
        [capture_village]
            x,y=9,17
        [/capture_village]
        [capture_village]
            x,y=10,20
        [/capture_village]
        [capture_village]
            x,y=11,4
        [/capture_village]
        [capture_village]
            x,y=14,8
        [/capture_village]
        [capture_village]
            x,y=16,17
        [/capture_village]
        [capture_village]
            x,y=19,22
        [/capture_village]
        [capture_village]
            x,y=20,5
        [/capture_village]
        [capture_village]
            x,y=21,9
        [/capture_village]
        [capture_village]
            x,y=24,6
        [/capture_village]
        [capture_village]
            x,y=25,17
        [/capture_village]
        [label]
            x="9"
            y="17"
        [/label]
        [label]
            x="19"
            y="6"
        [/label]
        [label]
            x="25"
            y="19"
        [/label]
        [label]
            x="26"
            y="14"
        [/label]
        [modify_side]
            side=1
            gold=10000
        [/modify_side]
        [modify_side]
            side=2
            gold=10000
        [/modify_side]
        [modify_side]
            side=3
            gold=10000
        [/modify_side]
    [/event]

    [event]
        name=_replace_ai_2
        first_time_only=no
        [modify_side]
            side=2
            switch_ai=$test_path_to_ai
        [/modify_side]
        [message]
            speaker=narrator
            message="and so, the AI for team 2 was redeployed from file '$test_path_to_ai'"
        [/message]
    [/event]
[/test]
