// File: rozpo[P]enemy/Loop.cpp
// Function: Loop::mainLoop()
void Loop::mainLoop()
{
    std::shared_ptr<Data>       data        = std::make_shared <Data>();
    std::shared_ptr<Menu>       menu        = std::make_shared <Menu>();
    std::shared_ptr<Create>     create      = std::make_shared <Create>();
    std::shared_ptr<Select>     select      = std::make_shared <Select>();
    std::shared_ptr<Stats>      stats       = std::make_shared <Stats>();
    std::shared_ptr<Shop>       shop        = std::make_shared <Shop>();
    std::shared_ptr<Training>   training    = std::make_shared <Training>();
    std::shared_ptr<Item>       items       = std::make_shared <Item>();
    Skill::createSkills (data->skills);
    do
    {
        status = e_loop_cancel;

        menu->print();
        status = menu->choice();

        switch(status)
        {
            case e_loop_create:
            {
                create->print();
                set = create->choice();
                create->createPlayer(data->players,set);
                data->activeplayer = data->players.size ()-1;
            }
                break;

            case e_loop_select:
            {
                if(data->players.empty() == 0)
                {
                    select->print(data->players);
                    set = select->choice();
                    if(set !=0 && set < data->players.size ())
                        data->activeplayer = select->selectPlayer(set);
                }


            }
                break;

            case e_loop_stats:
            {
                if(data->players.empty() == 0)
                {
                    stats->print(data->players[data->activeplayer]);
                    stats->printMoves (data->players[data->activeplayer],data->skills);
                }
            }
                break;

            case e_loop_battle:
            {
                if(data->players.empty() == 0)
                {
                    data->enemies = Battle::createEnemy(data->enemies);
                    Battle::doBattle(data->players[data->activeplayer],
                                     data->enemies[data->enemies.size()-1],
                                     data->skills);
                }
            }
                break;

            case e_loop_shop:
            {
                if(data->players.empty() == 0)
                {
                    shop->openShop(data->players[data->activeplayer]);
                }
            }
                break;

            case e_loop_training:
            {
                if(data->players.empty() == 0)
                {
                    training->openTraining(data->players[data->activeplayer]);
                }
            }
                break;

            case e_loop_skills:
            {
                if(data->players.empty() == 0)
                {
                    Skill::printSkills(data->skills);
                }
            }
                break;

            case e_loop_items:
            {
                if(data->players.empty() == 0)
                {
                    items->openItem(data->players[data->activeplayer]);
                }
            }
                break;

            default:
                return;
        }
    }while(status != e_loop_cancel);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x15630
leaq -0x28(%rbp), %rdi
callq 0x156a0
jmp 0x14e5e
leaq -0x48(%rbp), %rdi
callq 0x15710
jmp 0x14e69
leaq -0x58(%rbp), %rdi
callq 0x15780
jmp 0x14e74
leaq -0x68(%rbp), %rdi
callq 0x157f0
jmp 0x14e7f
leaq -0x78(%rbp), %rdi
callq 0x15860
jmp 0x14e8a
leaq -0x88(%rbp), %rdi
callq 0x158d0
jmp 0x14e98
leaq -0x98(%rbp), %rdi
callq 0x15940
jmp 0x14ea6
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rsi
addq $0x30, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x10920
jmp 0x14ec4
leaq -0xb0(%rbp), %rdi
callq 0x159d0
movq -0x108(%rbp), %rax
movl $0x0, 0x4(%rax)
leaq -0x28(%rbp), %rdi
callq 0x15a30
movq %rax, %rdi
callq 0x105f0
jmp 0x14ef1
leaq -0x28(%rbp), %rdi
callq 0x15a30
movq %rax, %rdi
callq 0x10730
movl %eax, -0x10c(%rbp)
jmp 0x14f0a
movq -0x108(%rbp), %rax
movl -0x10c(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl 0x4(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x118(%rbp)
subl $0x7, %eax
ja 0x1554b
movq -0x118(%rbp), %rax
leaq 0x8a29(%rip), %rcx      # 0x1d968
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x15610
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x15607
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x155fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x155f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x155ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x155e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x155d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x155cb
leaq -0x48(%rbp), %rdi
callq 0x15a50
movq %rax, %rdi
callq 0x105f0
jmp 0x14fe3
leaq -0x48(%rbp), %rdi
callq 0x15a50
movq %rax, %rdi
callq 0x10730
movl %eax, -0x11c(%rbp)
jmp 0x14ffc
movq -0x108(%rbp), %rax
movl -0x11c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x48(%rbp), %rdi
callq 0x15a50
movq %rax, -0x128(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq -0x128(%rbp), %rsi
movq -0x108(%rbp), %rcx
movq %rax, %rdx
leaq -0xc8(%rbp), %rdi
callq 0xc6a0
jmp 0x15043
leaq -0xc8(%rbp), %rdi
callq 0x15a70
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xc7a0
subq $0x1, %rax
movl %eax, -0x12c(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x159b0
movl -0x12c(%rbp), %ecx
movl %ecx, 0x48(%rax)
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1515e
leaq -0x58(%rbp), %rdi
callq 0x15ad0
movq %rax, -0x138(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq -0x138(%rbp), %rdi
movq %rax, %rsi
callq 0xdc60
jmp 0x150ca
leaq -0x58(%rbp), %rdi
callq 0x15ad0
movq %rax, %rdi
callq 0x10730
movl %eax, -0x13c(%rbp)
jmp 0x150e3
movq -0x108(%rbp), %rax
movl -0x13c(%rbp), %ecx
movl %ecx, (%rax)
cmpl $0x0, (%rax)
je 0x1515c
movq -0x108(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x148(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xc7a0
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jae 0x1515c
leaq -0x58(%rbp), %rdi
callq 0x15ad0
movq %rax, %rdi
movq -0x108(%rbp), %rax
movl (%rax), %esi
callq 0xddc0
movl %eax, -0x14c(%rbp)
jmp 0x1514a
leaq -0x18(%rbp), %rdi
callq 0x159b0
movl -0x14c(%rbp), %ecx
movl %ecx, 0x48(%rax)
jmp 0x1515e
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1524a
leaq -0x68(%rbp), %rdi
callq 0x15af0
movq %rax, -0x158(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x159b0
movq -0x168(%rbp), %rdi
movq %rax, -0x160(%rbp)
callq 0x159b0
movq -0x160(%rbp), %rdi
movslq 0x48(%rax), %rsi
callq 0x15b10
movq -0x158(%rbp), %rdi
movq %rax, %rsi
callq 0xff60
jmp 0x151d6
leaq -0x68(%rbp), %rdi
callq 0x15af0
movq %rax, -0x178(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x159b0
movq -0x180(%rbp), %rdi
movq %rax, -0x188(%rbp)
callq 0x159b0
movq -0x188(%rbp), %rdi
movslq 0x48(%rax), %rsi
callq 0x15b10
movq -0x180(%rbp), %rdi
movq %rax, -0x170(%rbp)
callq 0x159b0
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rsi
movq %rax, %rdx
addq $0x30, %rdx
callq 0x102d0
jmp 0x15248
jmp 0x1524a
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x153a8
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rsi
addq $0x18, %rsi
leaq -0xf8(%rbp), %rdi
callq 0x15b30
jmp 0x1528c
leaq -0xe0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xaeb0
jmp 0x152a1
leaq -0x18(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x159b0
movq %rax, %rdi
addq $0x18, %rdi
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x1b8(%rbp)
callq 0x15c20
movq -0x1b8(%rbp), %rdi
callq 0x15c50
leaq -0xf8(%rbp), %rdi
callq 0x15c50
movq -0x1a0(%rbp), %rdi
callq 0x159b0
movq -0x1a0(%rbp), %rdi
movq %rax, -0x1b0(%rbp)
callq 0x159b0
movq -0x1b0(%rbp), %rdi
movslq 0x48(%rax), %rsi
callq 0x15b10
movq -0x1a0(%rbp), %rdi
movq %rax, -0x198(%rbp)
callq 0x159b0
movq -0x1a0(%rbp), %rdi
addq $0x18, %rax
movq %rax, -0x1a8(%rbp)
callq 0x159b0
movq %rax, %rdi
addq $0x18, %rdi
callq 0xc230
movq -0x1a8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x15cb0
movq -0x1a0(%rbp), %rdi
movq %rax, -0x190(%rbp)
callq 0x159b0
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rsi
movq %rax, %rdx
addq $0x30, %rdx
callq 0xa8c0
jmp 0x15389
jmp 0x153a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x15c50
jmp 0x155cb
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1541e
leaq -0x78(%rbp), %rdi
callq 0x15cd0
movq %rax, -0x1c0(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x159b0
movq -0x1d0(%rbp), %rdi
movq %rax, -0x1c8(%rbp)
callq 0x159b0
movq -0x1c8(%rbp), %rdi
movslq 0x48(%rax), %rsi
callq 0x15b10
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0xf190
jmp 0x1541c
jmp 0x1541e
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x15497
leaq -0x88(%rbp), %rdi
callq 0x15cf0
movq %rax, -0x1d8(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x159b0
movq -0x1e8(%rbp), %rdi
movq %rax, -0x1e0(%rbp)
callq 0x159b0
movq -0x1e0(%rbp), %rdi
movslq 0x48(%rax), %rsi
callq 0x15b10
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x10480
jmp 0x15495
jmp 0x15497
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x154d0
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
addq $0x30, %rdi
callq 0x11020
jmp 0x154ce
jmp 0x154d0
jmp 0x15557
leaq -0x18(%rbp), %rdi
callq 0x159b0
movq %rax, %rdi
callq 0xdde0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x15549
leaq -0x98(%rbp), %rdi
callq 0x15d10
movq %rax, -0x1f0(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x159b0
movq -0x200(%rbp), %rdi
movq %rax, -0x1f8(%rbp)
callq 0x159b0
movq -0x1f8(%rbp), %rdi
movslq 0x48(%rax), %rsi
callq 0x15b10
movq -0x1f0(%rbp), %rdi
movq %rax, %rsi
callq 0xd950
jmp 0x15547
jmp 0x15549
jmp 0x15557
movl $0x1, -0xfc(%rbp)
jmp 0x15574
jmp 0x15559
movq -0x108(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x14ed0
movl $0x0, -0xfc(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x15d30
leaq -0x88(%rbp), %rdi
callq 0x15d50
leaq -0x78(%rbp), %rdi
callq 0x15d70
leaq -0x68(%rbp), %rdi
callq 0x15d90
leaq -0x58(%rbp), %rdi
callq 0x15db0
leaq -0x48(%rbp), %rdi
callq 0x15dd0
leaq -0x28(%rbp), %rdi
callq 0x15df0
leaq -0x18(%rbp), %rdi
callq 0x15e10
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0x98(%rbp), %rdi
callq 0x15d30
leaq -0x88(%rbp), %rdi
callq 0x15d50
leaq -0x78(%rbp), %rdi
callq 0x15d70
leaq -0x68(%rbp), %rdi
callq 0x15d90
leaq -0x58(%rbp), %rdi
callq 0x15db0
leaq -0x48(%rbp), %rdi
callq 0x15dd0
leaq -0x28(%rbp), %rdi
callq 0x15df0
leaq -0x18(%rbp), %rdi
callq 0x15e10
movq -0x30(%rbp), %rdi
callq 0x42e0
nopw %cs:(%rax,%rax)
nopl (%rax)