// File: tyhsu[P]Ewn/play.cpp
// Function: Play::player_move(int const&)
Movement Play::player_move(const int& dice)
{
    int movable_chs_cnt = this->game.count_movable_chs(dice);
    int chs_index, direct;
    Movement mvmt;

    do {
        cout << endl << "Next chessman able to move: ";
        for (int i=0; i<movable_chs_cnt; i++)
            cout << i << ")" << this->game.get_movable_chs(i).symbol << " ";
        cout << endl;
        cout << "Choose: ";
        cin >> chs_index;

        if (!this->game.get_is_switch())
            cout << "Direction: 0)Right 1)Down 2)Right-down" << endl;
        else
            cout << "Direction: 0)Left 1)Up 2)Left-up" << endl;
        cout << "Choose: ";
        cin >> direct;

        // get index
        chs_index = (this->game.get_is_switch() == false) ? this->game.get_movable_chs(chs_index).symbol - '1' : this->game.get_movable_chs(chs_index).symbol - 'A';
        mvmt.first = chs_index;
        mvmt.second = direct;
        //If the movement is illegal, run the loop
    } while (!this->game.check_in_board(mvmt));

    return mvmt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x90(%rbp)
movq -0x18(%rbp), %rsi
callq 0xada0
movl %eax, -0x1c(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x4c60
movq 0xf41e(%rip), %rdi      # 0x11fc8
movq 0xf407(%rip), %rsi      # 0x11fb8
callq 0x2190
movq %rax, %rdi
leaq 0xa500(%rip), %rsi      # 0xd0c0
callq 0x2150
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2c48
movl -0x28(%rbp), %esi
movq 0xf3ea(%rip), %rdi      # 0x11fc8
callq 0x2200
movq %rax, %rdi
leaq 0xa995(%rip), %rsi      # 0xd582
callq 0x2150
movq -0x90(%rbp), %rdi
movq %rax, -0x98(%rbp)
leaq -0x28(%rbp), %rsi
callq 0xb7c0
movq -0x98(%rbp), %rdi
movl %edx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x34(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x2c(%rbp)
movsbl -0x34(%rbp), %esi
callq 0x21a0
movq %rax, %rdi
leaq 0xa8d7(%rip), %rsi      # 0xd50f
callq 0x2150
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2bcc
movq 0xf379(%rip), %rdi      # 0x11fc8
movq 0xf362(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xf366(%rip), %rdi      # 0x11fc8
leaq 0xa424(%rip), %rsi      # 0xd08d
callq 0x2150
movq 0xf363(%rip), %rdi      # 0x11fd8
leaq -0x20(%rbp), %rsi
callq 0x20a0
movq -0x90(%rbp), %rdi
callq 0xb910
testb $0x1, %al
jne 0x2cb2
movq 0xf333(%rip), %rdi      # 0x11fc8
leaq 0xa441(%rip), %rsi      # 0xd0dd
callq 0x2150
movq %rax, %rdi
movq 0xf30d(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x2cd4
movq 0xf30f(%rip), %rdi      # 0x11fc8
leaq 0xa444(%rip), %rsi      # 0xd104
callq 0x2150
movq %rax, %rdi
movq 0xf2e9(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xf2ed(%rip), %rdi      # 0x11fc8
leaq 0xa3ab(%rip), %rsi      # 0xd08d
callq 0x2150
movq 0xf2ea(%rip), %rdi      # 0x11fd8
leaq -0x24(%rbp), %rsi
callq 0x20a0
movq -0x90(%rbp), %rdi
callq 0xb910
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2d41
movq -0x90(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xb7c0
movl %edx, -0x60(%rbp)
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x54(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x4c(%rbp)
movsbl -0x54(%rbp), %eax
subl $0x31, %eax
movl %eax, -0x9c(%rbp)
jmp 0x2d79
movq -0x90(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xb7c0
movl %edx, -0x80(%rbp)
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x74(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x6c(%rbp)
movsbl -0x74(%rbp), %eax
subl $0x41, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movq -0x90(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0xafe0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2ba3
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)