// File: /workspace/github_cpp_makefile_star2_O3/syky27[P]TicTacToe/src/DNRemoteHumanPlayer.cpp
// Function: DNRemoteHumanPlayer::triggerTurn(int, int)
bool DNRemoteHumanPlayer::triggerTurn(int y, int x)
{
    sleep(2);
    if(!amIServer){ DNWindow::getInstance().drawHeaderWithGuide(string("TicTacToe press 'x' to trigger turn ==> WAIT")); processOponentsTurn();}
    else {DNWindow::getInstance().drawHeaderWithGuide(string("TicTacToe press 'x' to trigger turn ==> PLAY"));}
    
    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 == 'q' || ch == 'Q') {
            transferQuitGame();
        }


        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();
                transferTurn(y, x);


                if (state != EMPTY) {
                    if (state == this->getSymbol()) {
                        string you_winner("YOU are WINNER!!!");
                        DNWindow::getInstance().terminateWithErrorMessage(you_winner);
                    }

                }
                DNWindow::getInstance().drawHeaderWithGuide(string("TicTacToe press 'x' to trigger turn ==> WAIT"));
                processOponentsTurn();
                DNWindow::getInstance().drawHeaderWithGuide(string("TicTacToe press 'x' to trigger turn ==> PLAY"));

            }
            else {
                DNWindow::getInstance().sound();
                DNWindow::getInstance().sound();
            }


            if (ch == 'q') {
                DNWindow::getInstance().terminate();
            }
        }
    }
    return true;



}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movl $0x2, %edi
callq 0x3230
movb 0x50(%rbx), %bpl
callq 0x39ee
movq %rax, %r14
testb %bpl, %bpl
je 0x6388
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x3010(%rip), %rsi      # 0x9357
leaq 0x3035(%rip), %rdx      # 0x9383
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x404c
movq %r14, %rdi
movq %r15, %rsi
callq 0x779a
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x63e3
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x63e3
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2f8e(%rip), %rsi      # 0x932a
leaq 0x2fb3(%rip), %rdx      # 0x9356
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
callq 0x404c
movq %r14, %rdi
movq %r15, %rsi
callq 0x779a
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x63db
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x677a
movq 0x6be6(%rip), %rbp      # 0xcfd0
leaq 0xc(%rsp), %r14
leaq 0x2f0e(%rip), %r15      # 0x9304
movq (%rbp), %rdi
callq 0x3140
leal -0x102(%rax), %ecx
cmpl $0x3, %ecx
ja 0x6422
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x39ee
movq %rax, %rdi
callq 0x7d18
jmp 0x63f6
testl %eax, %eax
je 0x669e
cmpb $0x51, %al
je 0x643b
movzbl %al, %eax
cmpl $0x78, %eax
je 0x6472
cmpl $0x71, %eax
jne 0x63f6
movq %rbx, %rdi
callq 0x6b74
jmp 0x63f6
callq 0x39ee
movq %rax, %rdi
callq 0x7d46
jmp 0x63f6
callq 0x39ee
movq %rax, %rdi
callq 0x7d78
jmp 0x63f6
callq 0x39ee
movq %rax, %rdi
callq 0x7ce6
jmp 0x63f6
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
callq 0x39ee
movq %rax, %rdi
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
movq %r14, %rdx
callq 0x8baa
movq 0x48(%rbx), %r12
movq %rbx, %rdi
callq 0x6244
movl 0x10(%rsp), %edx
movl 0xc(%rsp), %ecx
addl $-0x3, %ecx
movq %r12, %rdi
movl %eax, %esi
leaq 0x14(%rsp), %r8
callq 0x53ce
movl %eax, %r13d
callq 0x39ee
movq %rax, %r12
testb %r13b, %r13b
je 0x667d
movq %rbx, %rdi
callq 0x6244
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x8c96
movq 0x48(%rbx), %rdi
callq 0x4f82
movl 0xc(%rsp), %esi
movl 0x10(%rsp), %edx
movq %rbx, %rdi
callq 0x6c6a
movl 0x14(%rsp), %r12d
testl %r12d, %r12d
movq 0x6ac2(%rip), %rbp      # 0xcfd0
leaq 0x58(%rsp), %r14
je 0x65c4
movq %rbx, %rdi
callq 0x6244
cmpl %eax, %r12d
jne 0x65c4
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x2e44(%rip), %rsi      # 0x9384
leaq 0x2e4e(%rip), %rdx      # 0x9395
callq 0x404c
callq 0x39ee
leaq 0x78(%rsp), %r13
movq %rax, %r12
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3fb6
movq %r12, %rdi
movq %r13, %rsi
callq 0x82b0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x65a8
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x65c4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32f0
callq 0x39ee
movq %rax, %r12
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %r14, %rdi
leaq 0x2d4a(%rip), %rsi      # 0x932a
leaq 0x2d6f(%rip), %rdx      # 0x9356
callq 0x404c
movq %r12, %rdi
movq %r14, %rsi
callq 0x779a
leaq 0xc(%rsp), %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6618
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x677a
callq 0x39ee
movq %rax, %r12
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %r13
movq %r13, %rdi
leaq 0x2d16(%rip), %rsi      # 0x9357
leaq 0x2d3b(%rip), %rdx      # 0x9383
callq 0x404c
movq %r12, %rdi
movq %r13, %rsi
callq 0x779a
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x63f6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x63f6
movq %r12, %rdi
callq 0x8d9c
callq 0x39ee
movq %rax, %rdi
callq 0x8d9c
movq 0x6937(%rip), %rbp      # 0xcfd0
jmp 0x63f6
movb $0x1, %al
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6772
movq 0xc8(%rsp), %rsi
jmp 0x6765
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x6772
movq 0xa8(%rsp), %rsi
jmp 0x6765
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x671d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x671d
jmp 0x676f
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x6772
movq 0x28(%rsp), %rsi
jmp 0x6765
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6772
movq 0x48(%rsp), %rsi
jmp 0x6765
jmp 0x676f
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6772
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x6772
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34b0