// File: /workspace/github_cpp_makefile_star2_O2/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 0x7d51(%rip), %r12      # 0xbfd0
leaq 0x78(%rsp), %r14
leaq 0x3de9(%rip), %rbp      # 0x8074
movq (%r12), %rdi
callq 0x3120
leal -0x102(%rax), %ecx
cmpl $0x3, %ecx
ja 0x42b8
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
callq 0x381e
movq %rax, %rdi
callq 0x6b90
jmp 0x428b
testl %eax, %eax
je 0x444a
cmpb $0x71, %al
je 0x4438
movzbl %al, %eax
cmpl $0x78, %eax
jne 0x428b
andl $0x0, 0x10(%rsp)
andl $0x0, 0xc(%rsp)
callq 0x381e
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x7696
movq 0x48(%rbx), %r13
movq %rbx, %rdi
callq 0x557c
movl 0x10(%rsp), %edx
movl 0xc(%rsp), %ecx
addl $-0x3, %ecx
movq %r13, %rdi
movl %eax, %esi
leaq 0x14(%rsp), %r8
callq 0x4a92
testb %al, %al
je 0x428b
callq 0x381e
movq %rax, %r13
movq %rbx, %rdi
callq 0x557c
movq %r13, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x7762
movq 0x48(%rbx), %rdi
callq 0x477c
movl 0x14(%rsp), %r13d
testl %r13d, %r13d
je 0x444a
movq %rbx, %rdi
callq 0x557c
cmpl %eax, %r13d
jne 0x428b
movq %r14, %r13
leaq 0x18(%rsp), %r15
movq %r15, %rdi
leaq 0x3d17(%rip), %rsi      # 0x8094
movq %r14, %rdx
callq 0x3c1e
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5580
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x448e
movq %r14, %r15
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x33b0
movq %r13, %r14
movq %r13, %rdi
callq 0x3170
movq %r15, %rdi
callq 0x3170
callq 0x381e
leaq 0x38(%rsp), %r15
movq %rax, %r13
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x33f0
movq %r13, %rdi
movq %r15, %rsi
callq 0x7060
movq %r15, %rdi
callq 0x3170
leaq 0x18(%rsp), %rdi
callq 0x3170
jmp 0x428b
callq 0x381e
movq %rax, %rdi
callq 0x6bbc
jmp 0x428b
callq 0x381e
movq %rax, %rdi
callq 0x6bea
jmp 0x428b
callq 0x381e
movq %rax, %rdi
callq 0x6b62
jmp 0x428b
callq 0x381e
movq %rax, %rdi
callq 0x7052
jmp 0x428b
movb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x4470
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3170
jmp 0x447c
jmp 0x4479
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x34d0