// File: syky27[P]TicTacToe/src/DNRemoteHumanPlayer.cpp
// Function: DNRemoteHumanPlayer::processOponentsTurn()
void DNRemoteHumanPlayer::processOponentsTurn()
{
    
    DNCellState opSymbol, state;
    if (this->symbol == CROSS) opSymbol = CIRCLE;
    else opSymbol = CROSS;

    string op = DNNetworkConnection::getInstance().receiveData(this->clientSocket);
    if (op == "QUIT") {
        //close connection;
        DNNetworkConnection::getInstance().closeConnection(this->clientSocket);
        DNWindow::getInstance().terminateWithErrorMessage("OPPONNET QUITED GAME");
    }

    
    stringstream tmp(op);
    string s_y, s_x;
    int y,x;
    getline(tmp, s_x, ';');
    getline(tmp, s_y, ';');
    y = atoi(s_y.c_str());
    x = atoi(s_x.c_str());


    if (this->game_map->recordMove(opSymbol, x - 0, y - 3, state)) {
        DNWindow::getInstance().drawSymbolBetter(opSymbol, x, y);
        this->game_map->debugToFile();
     if (state != EMPTY) {
            if (state == opSymbol) {
                string op_winner("Opponent is winner");
                DNWindow::getInstance().terminateWithErrorMessage(op_winner);
            }
            
        }
    }
    else {
        DNWindow::getInstance().sound();
        DNWindow::getInstance().sound();
        cout << "FATATTATATATATLLL ERRRROOORRR" <<endl;
        
    }



    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x288(%rbp)
cmpl $0x2, 0x28(%rax)
jne 0x78a9
movl $0x1, -0xc(%rbp)
jmp 0x78b0
movl $0x2, -0xc(%rbp)
callq 0x8050
movq %rax, %rsi
movq -0x288(%rbp), %rax
movl 0x54(%rax), %edx
leaq -0x30(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x6fc0
movq -0x298(%rbp), %rdi
leaq 0x4b0a(%rip), %rsi      # 0xc3ea
callq 0x80c0
movb %al, -0x289(%rbp)
jmp 0x78ed
movb -0x289(%rbp), %al
testb $0x1, %al
jne 0x78fc
jmp 0x79c1
callq 0x8050
movq %rax, -0x2a0(%rbp)
jmp 0x790a
movq -0x2a0(%rbp), %rdi
movq -0x288(%rbp), %rax
movl 0x54(%rax), %esi
callq 0x7160
jmp 0x7922
callq 0x3a90
movq %rax, -0x2a8(%rbp)
jmp 0x7930
leaq -0x61(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x35e0
movq -0x2b0(%rbp), %rdx
leaq 0x4ac1(%rip), %rsi      # 0xc40f
leaq -0x60(%rbp), %rdi
callq 0x42f0
jmp 0x7959
movq -0x2a8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xaf80
jmp 0x796b
leaq -0x60(%rbp), %rdi
callq 0x3200
leaq -0x61(%rbp), %rdi
callq 0x3400
jmp 0x79c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7cc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x79b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3200
leaq -0x61(%rbp), %rdi
callq 0x3400
jmp 0x7cc6
movl $0x10, %edi
movl $0x8, %esi
callq 0x43a0
movl %eax, -0x2b4(%rbp)
jmp 0x79d8
movl -0x2b4(%rbp), %edx
leaq -0x1f0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3570
jmp 0x79f0
leaq -0x210(%rbp), %rdi
callq 0x34e0
leaq -0x230(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x34e0
movq -0x2c0(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
movl $0x3b, %edx
callq 0x3620
jmp 0x7a29
leaq -0x1f0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
movl $0x3b, %edx
callq 0x3620
jmp 0x7a43
leaq -0x210(%rbp), %rdi
callq 0x3180
movq %rax, %rdi
callq 0x3560
movl %eax, -0x234(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3180
movq %rax, %rdi
callq 0x3560
movl %eax, %ecx
movq -0x288(%rbp), %rax
movl %ecx, -0x238(%rbp)
movq 0x48(%rax), %rdi
movl -0xc(%rbp), %esi
movl -0x238(%rbp), %edx
movl -0x234(%rbp), %ecx
addl $-0x3, %ecx
leaq -0x10(%rbp), %r8
callq 0x5e40
movb %al, -0x2c1(%rbp)
jmp 0x7aa7
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x7ab6
jmp 0x7c01
callq 0x3a90
movq %rax, -0x2d0(%rbp)
jmp 0x7ac4
movq -0x2d0(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x238(%rbp), %rdx
leaq -0x234(%rbp), %rcx
callq 0xbab0
jmp 0x7ae3
movq -0x288(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x58d0
jmp 0x7af5
cmpl $0x0, -0x10(%rbp)
je 0x7bff
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x7bfd
leaq -0x259(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x35e0
movq -0x2d8(%rbp), %rdx
leaq 0x48f8(%rip), %rsi      # 0xc424
leaq -0x258(%rbp), %rdi
callq 0x42f0
jmp 0x7b3a
leaq -0x259(%rbp), %rdi
callq 0x3400
callq 0x3a90
movq %rax, -0x2e0(%rbp)
jmp 0x7b54
leaq -0x280(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3190
jmp 0x7b69
movq -0x2e0(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xaf80
jmp 0x7b7e
leaq -0x280(%rbp), %rdi
callq 0x3200
leaq -0x258(%rbp), %rdi
callq 0x3200
jmp 0x7bfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7ca2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x259(%rbp), %rdi
callq 0x3400
jmp 0x7ca2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x3200
leaq -0x258(%rbp), %rdi
callq 0x3200
jmp 0x7ca2
jmp 0x7bff
jmp 0x7c6c
callq 0x3a90
movq %rax, -0x2e8(%rbp)
jmp 0x7c0f
movq -0x2e8(%rbp), %rdi
callq 0xbe60
jmp 0x7c1d
callq 0x3a90
movq %rax, -0x2f0(%rbp)
jmp 0x7c2b
movq -0x2f0(%rbp), %rdi
callq 0xbe60
jmp 0x7c39
movq 0x9398(%rip), %rdi      # 0x10fd8
leaq 0x47f0(%rip), %rsi      # 0xc437
callq 0x3360
movq %rax, -0x2f8(%rbp)
jmp 0x7c55
movq -0x2f8(%rbp), %rdi
movq 0x9355(%rip), %rsi      # 0x10fb8
callq 0x33e0
jmp 0x7c6a
jmp 0x7c6c
leaq -0x230(%rbp), %rdi
callq 0x3200
leaq -0x210(%rbp), %rdi
callq 0x3200
leaq -0x1f0(%rbp), %rdi
callq 0x3290
leaq -0x30(%rbp), %rdi
callq 0x3200
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
leaq -0x230(%rbp), %rdi
callq 0x3200
leaq -0x210(%rbp), %rdi
callq 0x3200
leaq -0x1f0(%rbp), %rdi
callq 0x3290
leaq -0x30(%rbp), %rdi
callq 0x3200
movq -0x38(%rbp), %rdi
callq 0x35d0
nopl (%rax,%rax)