// File: /workspace/github_cpp_makefile_star2_O3/rozpo[P]enemy/data/game/items/Item.cpp
// Function: Item::openItem(std::shared_ptr<Player>&)
void Item::openItem(std::shared_ptr<Player> &player)
{
    int z = 0;
    do
    {
        print();

        std::cout << player->name << " current weapon ( ";
        if(player->weapon_dmg != 0)
            std::cout << player->weapon_name << " )\n";
        else
            std::cout << "None )\n";

        z = choice();
        switch(z)
        {
            case e_item_dagger:
            {
                if(player->gold >= 50)
                {
                    player->weapon_name = "Dagger";
                    player->weapon_dmg = 5;
                    player->gold-=50;
                }
                else
                    std::cout << "Not enough gold ;(\n";
            }
                break;

            case e_item_shortsword:
            {
                if(player->gold >= 120)
                {
                    player->weapon_name = "Short Sword";
                    player->weapon_dmg = 10;
                    player->gold-=120;
                }
                else
                    std::cout << "Not enough gold ;(\n";
            }
                break;

            case e_item_greataxe:
            {
                if(player->gold >= 299)
                {
                    player->weapon_name = "Great Axe";
                    player->weapon_dmg = 19;
                    player->gold-=299;
                }
                else
                    std::cout << "Not enough gold ;(\n";
            }
                break;

            case e_item_heavyhammer:
            {
                if(player->gold >= 420)
                {
                    player->weapon_name = "Heavy Hammer";
                    player->weapon_dmg = 35;
                    player->gold-=420;
                }
                else
                    std::cout << "Not enough gold ;(\n";
            }
                break;

            case e_item_devilscythe:
            {
                if(player->gold >= 666)
                {
                    player->weapon_name = "Legendary Lucifer's Scythe";
                    player->weapon_dmg = 666;
                    player->gold-=666;
                }
                else
                    std::cout << "Not enough gold ;(\n";
            }
                break;
        }
    }while(z != 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0xae48(%rip), %r15      # 0x10fd0
leaq 0x5485(%rip), %r12      # 0xb614
leaq 0x5466(%rip), %rbp      # 0xb5fc
leaq 0x548e(%rip), %r13      # 0xb62b
movq %r14, %rdi
callq 0x7404
movq (%rbx), %rax
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %r15, %rdi
callq 0x3140
movl $0x12, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3140
movq (%rbx), %rax
cmpl $0x0, 0x80(%rax)
je 0x61f1
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
movq %r15, %rdi
callq 0x3140
movl $0x3, %edx
movq %rax, %rdi
movq %r13, %rsi
jmp 0x6200
movl $0x7, %edx
movq %r15, %rdi
leaq 0x5427(%rip), %rsi      # 0xb627
callq 0x3140
movq %r14, %rdi
callq 0x757e
cmpl $0x5, %eax
ja 0x619d
movl %eax, %eax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq (%rbx), %rdi
cmpl $0x32, 0x3c(%rdi)
jl 0x6363
movq 0x68(%rdi), %rdx
addq $0x60, %rdi
movl $0x6, %r8d
xorl %esi, %esi
leaq 0x53ed(%rip), %rcx      # 0xb62f
callq 0x3190
movq (%rbx), %rax
movl $0x5, 0x80(%rax)
addl $-0x32, 0x3c(%rax)
jmp 0x619d
movq (%rbx), %rdi
cmpl $0x1a4, 0x3c(%rdi)      # imm = 0x1A4
jl 0x6363
movq 0x68(%rdi), %rdx
addq $0x60, %rdi
movl $0xc, %r8d
xorl %esi, %esi
leaq 0x53dc(%rip), %rcx      # 0xb660
callq 0x3190
movq (%rbx), %rax
movl $0x23, 0x80(%rax)
addl $0xfffffe5c, 0x3c(%rax) # imm = 0xFFFFFE5C
jmp 0x619d
movq (%rbx), %rdi
cmpl $0x78, 0x3c(%rdi)
jl 0x6363
movq 0x68(%rdi), %rdx
addq $0x60, %rdi
movl $0xb, %r8d
xorl %esi, %esi
leaq 0x5384(%rip), %rcx      # 0xb64a
callq 0x3190
movq (%rbx), %rax
movl $0xa, 0x80(%rax)
addl $-0x78, 0x3c(%rax)
jmp 0x619d
movq (%rbx), %rdi
cmpl $0x12b, 0x3c(%rdi)      # imm = 0x12B
jl 0x6363
movq 0x68(%rdi), %rdx
addq $0x60, %rdi
movl $0x9, %r8d
xorl %esi, %esi
leaq 0x5352(%rip), %rcx      # 0xb656
callq 0x3190
movq (%rbx), %rax
movl $0x13, 0x80(%rax)
addl $0xfffffed5, 0x3c(%rax) # imm = 0xFFFFFED5
jmp 0x619d
movq (%rbx), %rdi
cmpl $0x29a, 0x3c(%rdi)      # imm = 0x29A
jl 0x6363
movq 0x68(%rdi), %rdx
addq $0x60, %rdi
movl $0x1a, %r8d
xorl %esi, %esi
leaq 0x5328(%rip), %rcx      # 0xb66d
callq 0x3190
movq (%rbx), %rax
movl $0x29a, 0x80(%rax)      # imm = 0x29A
addl $0xfffffd66, 0x3c(%rax) # imm = 0xFFFFFD66
jmp 0x619d
movl $0x13, %edx
movq %r15, %rdi
leaq 0x52c4(%rip), %rsi      # 0xb636
callq 0x3140
jmp 0x619d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop