// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rbx, 0x8(%rsp)
movb 0x50(%rbx), %bpl
callq 0x39ee
movq %rax, %r14
testb %bpl, %bpl
je 0x637d
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x301b(%rip), %rsi      # 0x9357
leaq 0x3040(%rip), %rdx      # 0x9383
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x4048
movq %r14, %rdi
movq %r15, %rsi
callq 0x77aa
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x63da
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x63da
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2f99(%rip), %rsi      # 0x932a
leaq 0x2fbe(%rip), %rdx      # 0x9356
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
callq 0x4048
movq %r14, %rdi
movq %r15, %rsi
callq 0x77aa
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x63d0
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x8(%rsp), %rdi
callq 0x67ac
movq 0x6bef(%rip), %r14      # 0xcfd0
leaq 0x4(%rsp), %rbp
leaq 0x2f17(%rip), %r15      # 0x9304
movq (%r14), %rdi
callq 0x3140
movl %eax, %r12d
leal -0x102(%r12), %eax
cmpl $0x3, %eax
ja 0x641d
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x39ee
movq %rax, %rdi
callq 0x7d28
jmp 0x63ed
testl %r12d, %r12d
je 0x66d0
shll $0x18, %r12d
cmpl $0x51000000, %r12d      # imm = 0x51000000
je 0x6445
cmpl $0x78000000, %r12d      # imm = 0x78000000
je 0x6458
cmpl $0x71000000, %r12d      # imm = 0x71000000
jne 0x63ed
movq 0x8(%rsp), %rdi
callq 0x6ba6
cmpl $0x78000000, %r12d      # imm = 0x78000000
jne 0x63ed
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movl %eax, (%rsp)
callq 0x39ee
movq %rax, %rdi
movq %rbp, %rsi
movq %rsp, %rdx
callq 0x8bba
movq 0x8(%rsp), %rbx
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
movq %rbp, %r14
movl %eax, %ebp
callq 0x39ee
movq %rax, %r13
testb %bpl, %bpl
je 0x6692
movq %rbx, %rdi
callq 0x6234
movq %r13, %rdi
movl %eax, %esi
movq %rsp, %rdx
movq %r14, %rcx
callq 0x8ca6
movq 0x48(%rbx), %rdi
callq 0x4f8e
movl (%rsp), %esi
movl 0x4(%rsp), %edx
movq %rbx, %rdi
callq 0x6c9c
movl 0x14(%rsp), %ebp
testl %ebp, %ebp
movq 0x6adf(%rip), %r14      # 0xcfd0
je 0x65a3
movq 0x8(%rsp), %rdi
callq 0x6234
cmpl %eax, %ebp
jne 0x65a3
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x2e65(%rip), %rsi      # 0x9384
leaq 0x2e6f(%rip), %rdx      # 0x9395
callq 0x4048
callq 0x39ee
leaq 0x78(%rsp), %rbx
movq %rax, %r13
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%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 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6587
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x65a3
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32f0
callq 0x39ee
movq %rax, %r13
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x2d66(%rip), %rsi      # 0x932a
leaq 0x2d8b(%rip), %rdx      # 0x9356
callq 0x4048
movq %r13, %rdi
movq %rbp, %rsi
callq 0x77aa
leaq 0x4(%rsp), %rbp
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x65fc
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32f0
movq 0x8(%rsp), %rdi
callq 0x67ac
callq 0x39ee
movq %rax, %r13
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
leaq 0x2d30(%rip), %rsi      # 0x9357
leaq 0x2d55(%rip), %rdx      # 0x9383
callq 0x4048
movq %r13, %rdi
movq %rbx, %rsi
callq 0x77aa
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x66b1
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x66b1
callq 0x39ee
movq %rax, %rdi
callq 0x7d56
jmp 0x63ed
callq 0x39ee
movq %rax, %rdi
callq 0x7d88
jmp 0x63ed
callq 0x39ee
movq %rax, %rdi
callq 0x7cf6
jmp 0x63ed
movq %r13, %rdi
callq 0x8dac
callq 0x39ee
movq %rax, %rdi
callq 0x8dac
movq %r14, %rbp
movq 0x691f(%rip), %r14      # 0xcfd0
cmpl $0x71000000, %r12d      # imm = 0x71000000
jne 0x63ed
callq 0x39ee
movq %rax, %rdi
callq 0x82b2
jmp 0x63ed
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 0x67a4
movq 0xc8(%rsp), %rsi
jmp 0x6797
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x67a4
movq 0xa8(%rsp), %rsi
jmp 0x6797
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x674f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x674f
jmp 0x67a1
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x67a4
movq 0x28(%rsp), %rsi
jmp 0x6797
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x67a4
movq 0x68(%rsp), %rsi
jmp 0x6797
jmp 0x67a1
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x67a4
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32f0
jmp 0x67a4
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34b0