// File: /workspace/github_cpp_makefile_star2_O1/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 0x8759(%rip), %r12      # 0xcfd0
leaq 0x78(%rsp), %r14
leaq 0x47f1(%rip), %r15      # 0x9074
movq %rdi, 0x8(%rsp)
movq (%r12), %rdi
callq 0x3140
movl %eax, %ebp
leal -0x102(%rbp), %eax
cmpl $0x3, %eax
ja 0x48b6
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x39ee
movq %rax, %rdi
callq 0x7d28
jmp 0x4888
testl %ebp, %ebp
je 0x4b0b
shll $0x18, %ebp
cmpl $0x71000000, %ebp       # imm = 0x71000000
je 0x4af9
cmpl $0x78000000, %ebp       # imm = 0x78000000
jne 0x4888
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movl %eax, (%rsp)
callq 0x39ee
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
callq 0x8bba
movq 0x48(%rbx), %r13
movq %rbx, %rdi
callq 0x6234
movl 0x4(%rsp), %edx
movl (%rsp), %ecx
addl $-0x3, %ecx
movq %r13, %rdi
movl %eax, %esi
leaq 0x14(%rsp), %r8
callq 0x53c6
testb %al, %al
je 0x4ae8
callq 0x39ee
movq %rax, %r13
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6234
movq %r13, %rdi
movl %eax, %esi
movq %rsp, %rdx
leaq 0x4(%rsp), %rcx
callq 0x8ca6
movq 0x48(%rbx), %rdi
callq 0x4f8e
movl 0x14(%rsp), %r13d
testl %r13d, %r13d
je 0x4b0b
movq %rbx, %rdi
callq 0x6234
cmpl %eax, %r13d
jne 0x4ae8
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x470f(%rip), %rsi      # 0x9094
leaq 0x4716(%rip), %rdx      # 0x90a2
callq 0x4048
movq %r14, %r13
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x6238
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rdi
callq 0x30f0
leaq 0x68(%rsp), %r13
movq %r13, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4a11
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x4a19
callq 0x39ee
movq %rax, %rdi
callq 0x7d56
jmp 0x4888
callq 0x39ee
movq %rax, %rdi
callq 0x7d88
jmp 0x4888
callq 0x39ee
movq %rax, %rdi
callq 0x7cf6
jmp 0x4888
movups (%rcx), %xmm0
movups %xmm0, (%r13)
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 %r13, %rdi
je 0x4a57
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4a79
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
callq 0x39ee
leaq 0x38(%rsp), %rbx
movq %rax, %r13
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3fb8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x82c0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4acc
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x4ae8
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32f0
cmpl $0x71000000, %ebp       # imm = 0x71000000
movq 0x8(%rsp), %rbx
jne 0x4888
callq 0x39ee
movq %rax, %rdi
callq 0x82b2
jmp 0x4888
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 0x4b64
movq 0x48(%rsp), %rsi
jmp 0x4b55
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4b64
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x4b64
jmp 0x4b61
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x4b80
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x34b0