// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe0, %rsp
movq %rdi, %rbx
movq %rsp, %rdi
callq 0x87d8
leaq 0x40(%rsp), %rdi
callq 0x87f3
leaq 0x20(%rsp), %rdi
callq 0x880e
leaq 0x10(%rsp), %rdi
callq 0x8829
leaq 0x30(%rsp), %rdi
callq 0x8844
leaq 0x70(%rsp), %rdi
callq 0x885f
leaq 0x60(%rsp), %rdi
callq 0x887a
leaq 0x50(%rsp), %rdi
callq 0x8895
movq (%rsp), %rsi
addq $0x30, %rsi
leaq 0x98(%rsp), %rdi
callq 0x703e
leaq 0x98(%rsp), %rdi
callq 0x88b0
leaq 0x259a(%rip), %r13      # 0xaa44
leaq 0xc8(%rsp), %r14
leaq 0x80(%rsp), %r15
leaq 0xb0(%rsp), %r12
andl $0x0, 0x4(%rbx)
movq 0x40(%rsp), %rdi
callq 0x6dd8
movq 0x40(%rsp), %rdi
callq 0x6eee
movl %eax, 0x4(%rbx)
decl %eax
cmpl $0x7, %eax
ja 0x86e3
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x20(%rsp), %rdi
callq 0x6dd8
movq 0x20(%rsp), %rdi
callq 0x6eee
movl %eax, (%rbx)
movq 0x20(%rsp), %rsi
movq (%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x5a5c
movq %r14, %rdi
callq 0x88d2
movq (%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x4, %rax
decl %eax
movl %eax, 0x48(%rcx)
jmp 0x86d9
movq (%rsp), %rax
movq (%rax), %rsi
cmpq 0x8(%rax), %rsi
je 0x86d9
movq 0x70(%rsp), %rdi
movslq 0x48(%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x63cc
jmp 0x86d9
movq (%rsp), %rax
movq (%rax), %rsi
cmpq 0x8(%rax), %rsi
je 0x86d9
movq 0x30(%rsp), %rdi
movslq 0x48(%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x69a4
movq 0x30(%rsp), %rdi
movq (%rsp), %rdx
movslq 0x48(%rdx), %rsi
shlq $0x4, %rsi
addq (%rdx), %rsi
addq $0x30, %rdx
callq 0x6c2e
jmp 0x86d9
movq (%rsp), %rsi
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x86d9
addq $0x18, %rsi
movq %r15, %rdi
callq 0x88f4
movq %r12, %rdi
movq %r15, %rsi
callq 0x533c
movq (%rsp), %rdi
addq $0x18, %rdi
movq %r12, %rsi
callq 0x9bf4
movq %r12, %rdi
callq 0x8948
movq %r15, %rdi
callq 0x8948
movq (%rsp), %rdx
movslq 0x48(%rdx), %rdi
shlq $0x4, %rdi
addq (%rdx), %rdi
movq 0x20(%rdx), %rsi
addq $-0x10, %rsi
addq $0x30, %rdx
callq 0x4f88
jmp 0x86d9
movq (%rsp), %rdi
movq (%rdi), %rax
cmpq 0x8(%rdi), %rax
je 0x86d9
addq $0x30, %rdi
callq 0x7448
jmp 0x86d9
movq (%rsp), %rsi
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x86d9
movq 0x10(%rsp), %rdi
callq 0x5fc0
movq 0x10(%rsp), %rdi
callq 0x6eee
movl %eax, (%rbx)
testl %eax, %eax
je 0x86d9
movslq %eax, %rcx
movq (%rsp), %rdx
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x4, %rsi
cmpq %rcx, %rsi
jbe 0x86d9
movq 0x10(%rsp), %rdi
movl %eax, %esi
callq 0x60e6
movq (%rsp), %rcx
jmp 0x8535
movq (%rsp), %rax
movq (%rax), %rsi
cmpq 0x8(%rax), %rsi
je 0x86d9
movq 0x60(%rsp), %rdi
movslq 0x48(%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x6cf4
jmp 0x86d9
movq (%rsp), %rax
movq (%rax), %rsi
cmpq 0x8(%rax), %rsi
je 0x86d9
movq 0x50(%rsp), %rdi
movslq 0x48(%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x5dfc
cmpl $0x0, 0x4(%rbx)
jne 0x84c2
leaq 0x58(%rsp), %rdi
callq 0x4468
leaq 0x68(%rsp), %rdi
callq 0x4468
leaq 0x78(%rsp), %rdi
callq 0x4468
leaq 0x38(%rsp), %rdi
callq 0x4468
leaq 0x18(%rsp), %rdi
callq 0x4468
leaq 0x28(%rsp), %rdi
callq 0x4468
leaq 0x48(%rsp), %rdi
callq 0x4468
leaq 0x8(%rsp), %rdi
callq 0x4468
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x877d
movq %rax, %rbx
jmp 0x878a
movq %rax, %rbx
jmp 0x8794
movq %rax, %rbx
jmp 0x879e
movq %rax, %rbx
jmp 0x87a8
movq %rax, %rbx
jmp 0x87b2
movq %rax, %rbx
jmp 0x87bc
movq %rax, %rbx
jmp 0x87c6
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x8948
jmp 0x8780
jmp 0x877d
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4468
leaq 0x68(%rsp), %rdi
callq 0x4468
leaq 0x78(%rsp), %rdi
callq 0x4468
leaq 0x38(%rsp), %rdi
callq 0x4468
leaq 0x18(%rsp), %rdi
callq 0x4468
leaq 0x28(%rsp), %rdi
callq 0x4468
leaq 0x48(%rsp), %rdi
callq 0x4468
leaq 0x8(%rsp), %rdi
callq 0x4468
movq %rbx, %rdi
callq 0x3200