// File: MichaelXanth[P]RPG_Game/Living/Heroes/Hero.cpp
// Function: Hero::EquipWeapon(Weapon*, short)
bool Hero::EquipWeapon(Weapon* chosen , const short handGiven) //equips a chosen weapon
{
    if(handGiven == 1)
    {
        if(chosen == equippedWeaponRight)
            return true;

        if(equippedWeaponRight != NULL) //removes the damage from the previous weapon
            weaponDamage -= equippedWeaponRight->GetDamage();

        //if(chosen == equippedWeaponLeft) //removes the damage from the previous weapon
        /*{
            weaponDamage -= equippedWeaponLeft->GetDamage();
            equippedWeaponLeft = NULL;
        }*/

        if(equippedWeaponBoth != NULL) //removes the damage from the previous weapon
        {
            weaponDamage -= equippedWeaponBoth->GetDamage();
            equippedWeaponBoth = NULL;
            equippedWeaponLeft = NULL;
            leftHand = false;
        }

        equippedWeaponRight = chosen;
        rightHand = true;

        weaponDamage += chosen->GetDamage();
    }
    else if(handGiven == 2)
    {
        if(chosen == equippedWeaponLeft)
            return true;

        if(equippedWeaponLeft != NULL) //removes the damage from the previous weapon
            weaponDamage -= equippedWeaponLeft->GetDamage();

        //if(chosen == equippedWeaponRight) //removes the damage from the previous weapon
        /*{
            weaponDamage -= equippedWeaponRight->GetDamage();
            equippedWeaponRight = NULL;
        }*/

        if(equippedWeaponBoth != NULL) //removes the damage from the previous weapon
        {
            weaponDamage -= equippedWeaponBoth->GetDamage();
            equippedWeaponBoth = NULL;
            equippedWeaponRight = NULL;
            rightHand = false;
        }

        equippedWeaponLeft = chosen;
        leftHand = true;

        weaponDamage += chosen->GetDamage();
    }
    else if(handGiven == 3)
    {
        if(chosen == equippedWeaponBoth)
            return true;

        if(equippedWeaponBoth != NULL)
            weaponDamage -= equippedWeaponBoth->GetDamage();

        if(equippedWeaponLeft != NULL) //removes the damage from the previous weapon
            weaponDamage -= equippedWeaponLeft->GetDamage();

        if(equippedWeaponRight != NULL) //removes the damage from the previous weapon
            weaponDamage -= equippedWeaponRight->GetDamage();

        equippedWeaponBoth = chosen;
        equippedWeaponLeft = NULL;
        equippedWeaponRight = NULL;
        rightHand = true;
        leftHand = true;

        weaponDamage += chosen->GetDamage();
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movswl -0x1a(%rbp), %eax
cmpl $0x1, %eax
jne 0x208fd
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
cmpq 0xc8(%rcx), %rax
jne 0x20846
movb $0x1, -0x1(%rbp)
jmp 0x20aee
movq -0x28(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x20878
movq -0x28(%rbp), %rax
movq 0xc8(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
je 0x208c7
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq $0x0, 0xd8(%rax)
movq $0x0, 0xd0(%rax)
movb $0x0, 0x120(%rax)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, 0xc8(%rax)
movb $0x1, 0x121(%rax)
movq -0x18(%rbp), %rdi
callq 0x1e5e0
movl %eax, %ecx
movq -0x28(%rbp), %rax
addl 0xfc(%rax), %ecx
movl %ecx, 0xfc(%rax)
jmp 0x20aea
movswl -0x1a(%rbp), %eax
cmpl $0x2, %eax
jne 0x209db
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
cmpq 0xd0(%rcx), %rax
jne 0x20924
movb $0x1, -0x1(%rbp)
jmp 0x20aee
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
je 0x20956
movq -0x28(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
je 0x209a5
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq $0x0, 0xd8(%rax)
movq $0x0, 0xc8(%rax)
movb $0x0, 0x121(%rax)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, 0xd0(%rax)
movb $0x1, 0x120(%rax)
movq -0x18(%rbp), %rdi
callq 0x1e5e0
movl %eax, %ecx
movq -0x28(%rbp), %rax
addl 0xfc(%rax), %ecx
movl %ecx, 0xfc(%rax)
jmp 0x20ae8
movswl -0x1a(%rbp), %eax
cmpl $0x3, %eax
jne 0x20ae6
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
cmpq 0xd8(%rcx), %rax
jne 0x20a02
movb $0x1, -0x1(%rbp)
jmp 0x20aee
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
je 0x20a34
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
je 0x20a66
movq -0x28(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x20a98
movq -0x28(%rbp), %rax
movq 0xc8(%rax), %rdi
callq 0x1e5e0
movl %eax, %edx
movq -0x28(%rbp), %rax
movl 0xfc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xfc(%rax)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movq $0x0, 0xd0(%rax)
movq $0x0, 0xc8(%rax)
movb $0x1, 0x121(%rax)
movb $0x1, 0x120(%rax)
movq -0x18(%rbp), %rdi
callq 0x1e5e0
movl %eax, %ecx
movq -0x28(%rbp), %rax
addl 0xfc(%rax), %ecx
movl %ecx, 0xfc(%rax)
jmp 0x20ae8
jmp 0x20aea
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)