// File: /workspace/github_cpp_makefile_star2_O3/syky27[P]TicTacToe/src/DNHumanPlayer.cpp
// Function: DNHumanPlayer::triggerTurn(int, int)
bool DNHumanPlayer::triggerTurn(int y, int x)
{
    char ch;
    int key;
    while ((key = getch())) {
        ch = key;
        if (key == KEY_UP) {
            DNWindow::getInstance().moveUp();
            continue;

        }
        if (key == KEY_DOWN) {
            DNWindow::getInstance().moveDown();
            continue;
        }
        if (key == KEY_LEFT) {
            DNWindow::getInstance().moveLeft();
            continue;
        }

        if (key == KEY_RIGHT) {
            DNWindow::getInstance().moveRight();
            continue;
        }
        
            if (ch == 'x') {
                int x = 0;
                int y = 0;
                DNCellState state;
                
                DNWindow::getInstance().getCursorPosition(x, y);
                if (this->game_map->recordMove(this->getSymbol(), x - 0, y - 3, state)) {
                    DNWindow::getInstance().drawSymbol(this->getSymbol(), y, x);
                    this->game_map->debugToFile();

                    if (state != EMPTY) {
                        if (state == this->getSymbol()) {
                            string win(" is Winner !!!");
                            win = this->getNick() + win;
                            DNWindow::getInstance().terminateWithErrorMessage(win);
                        }
                    }else{
                        return true;
                    }
                }
        }
        
        if (ch == 'q') {
                DNWindow::getInstance().terminate();
            }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq 0x874d(%rip), %r13      # 0xcfd0
leaq 0x78(%rsp), %r15
leaq 0x47e5(%rip), %r14      # 0x9074
movq (%r13), %rdi
callq 0x3140
leal -0x102(%rax), %ecx
cmpl $0x3, %ecx
ja 0x48bb
movslq (%r14,%rcx,4), %rax
addq %r14, %rax
jmpq *%rax
callq 0x39ee
movq %rax, %rdi
callq 0x7d18
jmp 0x488f
testl %eax, %eax
je 0x4afc
cmpb $0x71, %al
je 0x4a0b
movzbl %al, %eax
cmpl $0x78, %eax
jne 0x488f
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
callq 0x39ee
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x8baa
movq 0x48(%rbx), %rbp
movq %rbx, %rdi
callq 0x6244
movl 0x10(%rsp), %edx
movl 0xc(%rsp), %ecx
addl $-0x3, %ecx
movq %rbp, %rdi
movl %eax, %esi
leaq 0x14(%rsp), %r8
callq 0x53ce
testb %al, %al
je 0x488f
callq 0x39ee
movq %rax, %rbp
movq %rbx, %rdi
callq 0x6244
movq %rbp, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x8c96
movq 0x48(%rbx), %rdi
callq 0x4f82
movl 0x14(%rsp), %ebp
testl %ebp, %ebp
je 0x4afc
movq %rbx, %rdi
callq 0x6244
cmpl %eax, %ebp
jne 0x488f
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x4713(%rip), %rsi      # 0x9094
leaq 0x471a(%rip), %rdx      # 0x90a2
callq 0x404c
movq %r15, %rbp
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6248
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbp, %rdi
callq 0x30f0
leaq 0x68(%rsp), %rbp
movq %rbp, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4a1d
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x4a24
callq 0x39ee
movq %rax, %rdi
callq 0x7d46
jmp 0x488f
callq 0x39ee
movq %rax, %rdi
callq 0x7d78
jmp 0x488f
callq 0x39ee
movq %rax, %rdi
callq 0x7ce6
jmp 0x488f
callq 0x39ee
movq %rax, %rdi
callq 0x82a2
jmp 0x488f
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x18(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x33b0
movq 0x58(%rsp), %rdi
cmpq %rbp, %rdi
je 0x4a62
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4a84
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
callq 0x39ee
leaq 0x38(%rsp), %r12
movq %rax, %rbp
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3fb6
movq %rbp, %rdi
movq %r12, %rsi
callq 0x82b0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4ad7
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x488f
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x488f
movb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4b55
movq 0x48(%rsp), %rsi
jmp 0x4b46
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4b55
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x4b55
jmp 0x4b52
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x4b71
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x34b0
nopl (%rax)