// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x20(%rbp), %rdi
callq 0x105f0
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x21641(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xfbc2(%rip), %rsi      # 0x1d560
callq 0x41b0
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x0, 0x80(%rax)
je 0xd9e2
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x60, %rsi
movq 0x21604(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xfb9c(%rip), %rsi      # 0x1d577
callq 0x41b0
jmp 0xd9f5
movq 0x215e7(%rip), %rdi     # 0x2efd0
leaq 0xfb83(%rip), %rsi      # 0x1d573
callq 0x41b0
movq -0x20(%rbp), %rdi
callq 0x10730
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x4, %eax
ja 0xdc47
movq -0x28(%rbp), %rax
leaq 0xfb2c(%rip), %rcx      # 0x1d54c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x32, 0x3c(%rax)
jl 0xda7b
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x60, %rdi
leaq 0xfb2c(%rip), %rsi      # 0x1d57b
callq 0x4260
movq -0x10(%rbp), %rdi
callq 0xaf60
movl $0x5, 0x80(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x32, %ecx
movl %ecx, 0x3c(%rax)
jmp 0xda8e
movq 0x2154e(%rip), %rdi     # 0x2efd0
leaq 0xfaf9(%rip), %rsi      # 0x1d582
callq 0x41b0
jmp 0xdc47
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x78, 0x3c(%rax)
jl 0xdae5
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x60, %rdi
leaq 0xfadd(%rip), %rsi      # 0x1d596
callq 0x4260
movq -0x10(%rbp), %rdi
callq 0xaf60
movl $0xa, 0x80(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x78, %ecx
movl %ecx, 0x3c(%rax)
jmp 0xdaf8
movq 0x214e4(%rip), %rdi     # 0x2efd0
leaq 0xfa8f(%rip), %rsi      # 0x1d582
callq 0x41b0
jmp 0xdc47
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x12b, 0x3c(%rax)      # imm = 0x12B
jl 0xdb55
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x60, %rdi
leaq 0xfa7c(%rip), %rsi      # 0x1d5a2
callq 0x4260
movq -0x10(%rbp), %rdi
callq 0xaf60
movl $0x13, 0x80(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x12b, %ecx            # imm = 0x12B
movl %ecx, 0x3c(%rax)
jmp 0xdb68
movq 0x21474(%rip), %rdi     # 0x2efd0
leaq 0xfa1f(%rip), %rsi      # 0x1d582
callq 0x41b0
jmp 0xdc47
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x1a4, 0x3c(%rax)      # imm = 0x1A4
jl 0xdbc5
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x60, %rdi
leaq 0xfa16(%rip), %rsi      # 0x1d5ac
callq 0x4260
movq -0x10(%rbp), %rdi
callq 0xaf60
movl $0x23, 0x80(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x1a4, %ecx            # imm = 0x1A4
movl %ecx, 0x3c(%rax)
jmp 0xdbd8
movq 0x21404(%rip), %rdi     # 0x2efd0
leaq 0xf9af(%rip), %rsi      # 0x1d582
callq 0x41b0
jmp 0xdc47
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x29a, 0x3c(%rax)      # imm = 0x29A
jl 0xdc32
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x60, %rdi
leaq 0xf9b6(%rip), %rsi      # 0x1d5b9
callq 0x4260
movq -0x10(%rbp), %rdi
callq 0xaf60
movl $0x29a, 0x80(%rax)      # imm = 0x29A
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x29a, %ecx            # imm = 0x29A
movl %ecx, 0x3c(%rax)
jmp 0xdc45
movq 0x21397(%rip), %rdi     # 0x2efd0
leaq 0xf942(%rip), %rsi      # 0x1d582
callq 0x41b0
jmp 0xdc47
jmp 0xdc49
cmpl $0x0, -0x14(%rbp)
jne 0xd96f
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
nopl (%rax)