// File: Leeingnyo[P]newPuyoC/main.cpp
// Function: main
int main() {
    srand(time(NULL));
    Console::ScreenClear();
    Console::HideCursor();
    if (Socket::StartUp()) {
        std::cout << "Winsock 초기화 실패" << std::endl;
        return -1;
    }
    
    bool app_alive = true;
    while (app_alive) {
        int choice;
        std::shared_ptr<Game> game;
        
        Console::ScreenClear();
        std::cout << Console::GotoXY(X(0), Y(0));
        std::cout << Console::white;
        std::cout << "선택해주세요" << std::endl;
        std::cout << "0. 게임설명" << std::endl;
        std::cout << "1. 혼자하기" << std::endl;
        std::cout << "2. 둘이하기(같은컴)" << std::endl;
        std::cout << "3. 둘이하기(멀티플레이)" << std::endl;
        std::cout << "4. 끝내기" << std::endl;
        
        choice = getch();
        switch(choice) {
            case '0': {
                help();
            }   continue;
            case '1': {
                game = std::make_shared<SingleGame>();
            }   break;
            case '2': {
                game = std::make_shared<VSGame>();
            }   break;
            case '3': {
                game = std::make_shared<VSRemoteGame>();
            }   break;
            case '4': {
                app_alive = false;
            }   continue;
            default: continue;
        }
        
        if (game->GameInit()) {
            game->GameLoop();
            game->GameResult();
        }
    }
    
    std::cout << Console::gray;
    Console::ShowCursor();
    Console::ScreenClear();
    Socket::CleanUp();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x4290
movl %eax, %edi
callq 0x42c0
callq 0x5250
callq 0x5270
callq 0x49f0
cmpl $0x0, %eax
je 0x165f4
movq 0x119fb(%rip), %rdi     # 0x27fc8
leaq 0x44ac(%rip), %rsi      # 0x1aa80
callq 0x42d0
movq %rax, %rdi
movq 0x119c5(%rip), %rsi     # 0x27fa8
callq 0x4320
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x168f1
movb $0x1, -0x5(%rbp)
testb $0x1, -0x5(%rbp)
je 0x168c8
leaq -0x20(%rbp), %rdi
callq 0x16f30
callq 0x5250
jmp 0x16612
leaq -0x34(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x8790
jmp 0x16621
movq 0x119a0(%rip), %rdi     # 0x27fc8
leaq -0x34(%rbp), %rsi
callq 0x5300
jmp 0x16633
movq 0x1198e(%rip), %rdi     # 0x27fc8
leaq 0x11cd3(%rip), %rsi     # 0x28314
callq 0x52b0
jmp 0x16648
movq 0x11979(%rip), %rdi     # 0x27fc8
leaq 0x4443(%rip), %rsi      # 0x1aa99
callq 0x42d0
movq %rax, -0x70(%rbp)
jmp 0x16661
movq -0x70(%rbp), %rdi
movq 0x1193c(%rip), %rsi     # 0x27fa8
callq 0x4320
jmp 0x16673
movq 0x1194e(%rip), %rdi     # 0x27fc8
leaq 0x442b(%rip), %rsi      # 0x1aaac
callq 0x42d0
movq %rax, -0x78(%rbp)
jmp 0x1668c
movq -0x78(%rbp), %rdi
movq 0x11911(%rip), %rsi     # 0x27fa8
callq 0x4320
jmp 0x1669e
movq 0x11923(%rip), %rdi     # 0x27fc8
leaq 0x4410(%rip), %rsi      # 0x1aabc
callq 0x42d0
movq %rax, -0x80(%rbp)
jmp 0x166b7
movq -0x80(%rbp), %rdi
movq 0x118e6(%rip), %rsi     # 0x27fa8
callq 0x4320
jmp 0x166c9
movq 0x118f8(%rip), %rdi     # 0x27fc8
leaq 0x43f5(%rip), %rsi      # 0x1aacc
callq 0x42d0
movq %rax, -0x88(%rbp)
jmp 0x166e5
movq -0x88(%rbp), %rdi
movq 0x118b5(%rip), %rsi     # 0x27fa8
callq 0x4320
jmp 0x166fa
movq 0x118c7(%rip), %rdi     # 0x27fc8
leaq 0x43df(%rip), %rsi      # 0x1aae7
callq 0x42d0
movq %rax, -0x90(%rbp)
jmp 0x16716
movq -0x90(%rbp), %rdi
movq 0x11884(%rip), %rsi     # 0x27fa8
callq 0x4320
jmp 0x1672b
movq 0x11896(%rip), %rdi     # 0x27fc8
leaq 0x43cf(%rip), %rsi      # 0x1ab08
callq 0x42d0
movq %rax, -0x98(%rbp)
jmp 0x16747
movq -0x98(%rbp), %rdi
movq 0x11853(%rip), %rsi     # 0x27fa8
callq 0x4320
jmp 0x1675c
callq 0x51d0
movl %eax, -0x9c(%rbp)
jmp 0x16769
movl -0x9c(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addl $-0x30, %eax
movl %eax, %ecx
movq %rcx, -0xa8(%rbp)
subl $0x4, %eax
ja 0x16844
movq -0xa8(%rbp), %rax
leaq 0x42d4(%rip), %rcx      # 0x1aa6c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x171b0
jmp 0x168fd
callq 0x16910
jmp 0x167c2
movl $0x2, -0x38(%rbp)
jmp 0x168ac
leaq -0x48(%rbp), %rdi
callq 0x16f50
jmp 0x167d9
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x16fc0
leaq -0x48(%rbp), %rdi
callq 0x16ff0
jmp 0x1684d
leaq -0x58(%rbp), %rdi
callq 0x17010
jmp 0x167fc
leaq -0x20(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x17080
leaq -0x58(%rbp), %rdi
callq 0x170b0
jmp 0x1684d
leaq -0x68(%rbp), %rdi
callq 0x170d0
jmp 0x1681f
leaq -0x20(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x17140
leaq -0x68(%rbp), %rdi
callq 0x17170
jmp 0x1684d
movb $0x0, -0x5(%rbp)
movl $0x2, -0x38(%rbp)
jmp 0x168ac
movl $0x2, -0x38(%rbp)
jmp 0x168ac
leaq -0x20(%rbp), %rdi
callq 0x17190
movq %rax, %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movb %al, -0xa9(%rbp)
jmp 0x16869
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x16875
jmp 0x168a5
leaq -0x20(%rbp), %rdi
callq 0x17190
movq %rax, %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x1688c
leaq -0x20(%rbp), %rdi
callq 0x17190
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0x168a3
jmp 0x168a5
movl $0x0, -0x38(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x171b0
movl -0x38(%rbp), %eax
testl %eax, %eax
je 0x168c3
jmp 0x168be
jmp 0x165f8
jmp 0x165f8
movq 0x116f9(%rip), %rdi     # 0x27fc8
leaq 0x11a1e(%rip), %rsi     # 0x282f4
callq 0x52b0
callq 0x5290
callq 0x5250
callq 0x4a00
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x44f0
nopw %cs:(%rax,%rax)