// File: /workspace/github_cpp_makefile_star2_O2/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 0xc1bc(%rip), %r15      # 0x11fd0
leaq 0x47f9(%rip), %r12      # 0xa614
leaq 0x47da(%rip), %rbp      # 0xa5fc
leaq 0x4802(%rip), %r13      # 0xa62b
movq %r14, %rdi
callq 0x6dd8
movq (%rbx), %rsi
addq $0x40, %rsi
movq %r15, %rdi
callq 0x3120
movq %rax, %rdi
movq %r12, %rsi
callq 0x3130
movq (%rbx), %rsi
cmpl $0x0, 0x80(%rsi)
je 0x5e6b
addq $0x60, %rsi
movq %r15, %rdi
callq 0x3120
movq %rax, %rdi
movq %r13, %rsi
jmp 0x5e75
movq %r15, %rdi
leaq 0x47b2(%rip), %rsi      # 0xa627
callq 0x3130
movq %r14, %rdi
callq 0x6eee
cmpl $0x5, %eax
ja 0x5e29
movl %eax, %eax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq (%rbx), %rdi
cmpl $0x32, 0x3c(%rdi)
jl 0x5f9c
addq $0x60, %rdi
leaq 0x4784(%rip), %rsi      # 0xa62f
callq 0x3230
movq (%rbx), %rax
movl $0x5, 0x80(%rax)
addl $-0x32, 0x3c(%rax)
jmp 0x5e29
movq (%rbx), %rdi
cmpl $0x1a4, 0x3c(%rdi)      # imm = 0x1A4
jl 0x5f9c
addq $0x60, %rdi
leaq 0x477f(%rip), %rsi      # 0xa660
callq 0x3230
movq (%rbx), %rax
movl $0x23, 0x80(%rax)
addl $0xfffffe5c, 0x3c(%rax) # imm = 0xFFFFFE5C
jmp 0x5e29
movq (%rbx), %rdi
cmpl $0x78, 0x3c(%rdi)
jl 0x5f9c
addq $0x60, %rdi
leaq 0x4733(%rip), %rsi      # 0xa64a
callq 0x3230
movq (%rbx), %rax
movl $0xa, 0x80(%rax)
addl $-0x78, 0x3c(%rax)
jmp 0x5e29
movq (%rbx), %rdi
cmpl $0x12b, 0x3c(%rdi)      # imm = 0x12B
jl 0x5f9c
addq $0x60, %rdi
leaq 0x470d(%rip), %rsi      # 0xa656
callq 0x3230
movq (%rbx), %rax
movl $0x13, 0x80(%rax)
addl $0xfffffed5, 0x3c(%rax) # imm = 0xFFFFFED5
jmp 0x5e29
movq (%rbx), %rdi
cmpl $0x29a, 0x3c(%rdi)      # imm = 0x29A
jl 0x5f9c
addq $0x60, %rdi
leaq 0x46ef(%rip), %rsi      # 0xa66d
callq 0x3230
movq (%rbx), %rax
movl $0x29a, 0x80(%rax)      # imm = 0x29A
addl $0xfffffd66, 0x3c(%rax) # imm = 0xFFFFFD66
jmp 0x5e29
movq %r15, %rdi
leaq 0x4690(%rip), %rsi      # 0xa636
callq 0x3130
jmp 0x5e29
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop