// File: Worthy-Wang[P]Warcraft3-StartWar/City.cpp
// Function: warcraft::City::blueWarriorAttackFirst()
void City::blueWarriorAttackFirst()
{
    vector<WeaponPtr> &redWeaponLib = redWarrior->getWeapons();
    vector<WeaponPtr> &blueWeaponLib = blueWarrior->getWeapons();
    size_t redWeaponIndex = 0;
    size_t blueWeaponIndex = 0;
    //蓝武士先发动攻击
    while (1)
    {
        bool redWeaponFlag = false, blueWeaponFlag = false;
        bool redHpFlag = false, blueHpFlag = false;

        /****************************蓝武士*******************************/
        //查看是否有武器能使用
        for (size_t i = 0; i < blueWeaponLib.size(); i++)
            if (blueWeaponLib[i]->getDurability() > 0)
            {
                blueWeaponFlag = true;
                break;
            }
        //有武器能够使用的话进行攻击
        if (blueWeaponFlag)
        {
            while (blueWeaponLib[blueWeaponIndex]->getDurability() == 0)
                blueWeaponIndex = (blueWeaponIndex + 1) % blueWeaponLib.size();
            blueWarrior->attack(redWarrior, blueWeaponLib[blueWeaponIndex]);
            blueWeaponIndex = (blueWeaponIndex + 1) % blueWeaponLib.size();
            redHpFlag = true; //红方确定受到攻击
        }

        /****************************红武士*******************************/
        //查看是否有武器能使用
        for (size_t i = 0; i < redWeaponLib.size(); i++)
            if (redWeaponLib[i]->getDurability() > 0)
            {
                redWeaponFlag = true;
                break;
            }
        //有武器能够使用的话进行攻击
        if (redWeaponFlag)
        {
            while (0 == redWeaponLib[redWeaponIndex]->getDurability())
                redWeaponIndex = (redWeaponIndex + 1) % redWeaponLib.size();
            redWarrior->attack(blueWarrior, redWeaponLib[redWeaponIndex]);
            redWeaponIndex = (redWeaponIndex + 1) % redWeaponLib.size();
            blueHpFlag = true; //蓝方确定受到攻击
        }

        /****************************一轮攻击之后*******************************/
        if (judgeResult(redHpFlag, blueHpFlag))
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x98(%rbp)
addq $0x8, %rdi
callq 0x5db0
movq %rax, %rdi
callq 0x5dd0
movq -0x98(%rbp), %rdi
movq %rax, -0x10(%rbp)
addq $0x18, %rdi
callq 0x5db0
movq %rax, %rdi
callq 0x5dd0
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movb $0x0, -0x2a(%rbp)
movb $0x0, -0x2b(%rbp)
movb $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5ee0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0x4aaf
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6690
movq %rax, %rdi
callq 0x5d30
movq %rax, %rdi
callq 0x5d70
cmpq $0x0, %rax
jbe 0x4a9f
movb $0x1, -0x2a(%rbp)
jmp 0x4aaf
jmp 0x4aa1
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x4a53
testb $0x1, -0x2a(%rbp)
je 0x4bdf
jmp 0x4abb
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x6690
movq %rax, %rdi
callq 0x5d30
movq %rax, %rdi
callq 0x5d70
cmpq $0x0, %rax
jne 0x4b0b
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5ee0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, -0x28(%rbp)
jmp 0x4abb
movq -0x98(%rbp), %rdi
addq $0x18, %rdi
callq 0x5db0
movq -0x98(%rbp), %rsi
movq %rax, -0xc0(%rbp)
addq $0x8, %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x6640
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x6690
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x6390
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0x192a0
jmp 0x4b79
leaq -0x58(%rbp), %rdi
callq 0x63c0
leaq -0x48(%rbp), %rdi
callq 0x6670
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5ee0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, -0x28(%rbp)
movb $0x1, -0x2b(%rbp)
jmp 0x4bdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x63c0
leaq -0x48(%rbp), %rdi
callq 0x6670
jmp 0x4da7
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5ee0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jae 0x4c43
movq -0x10(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x6690
movq %rax, %rdi
callq 0x5d30
movq %rax, %rdi
callq 0x5d70
cmpq $0x0, %rax
jbe 0x4c33
movb $0x1, -0x29(%rbp)
jmp 0x4c43
jmp 0x4c35
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x4be7
testb $0x1, -0x29(%rbp)
je 0x4d7d
jmp 0x4c4f
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x6690
movq %rax, %rdi
callq 0x5d30
movq %rax, %rdi
callq 0x5d70
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x4ca3
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5ee0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, -0x20(%rbp)
jmp 0x4c4f
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x5db0
movq -0x98(%rbp), %rsi
movq %rax, -0xf0(%rbp)
addq $0x18, %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x6640
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x6690
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x6390
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
callq 0x192a0
jmp 0x4d14
leaq -0x90(%rbp), %rdi
callq 0x63c0
leaq -0x80(%rbp), %rdi
callq 0x6670
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5ee0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, -0x20(%rbp)
movb $0x1, -0x2c(%rbp)
jmp 0x4d7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x63c0
leaq -0x80(%rbp), %rdi
callq 0x6670
jmp 0x4da7
movq -0x98(%rbp), %rdi
leaq -0x2b(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x5780
testb $0x1, %al
jne 0x4d97
jmp 0x4d99
jmp 0x4d9e
jmp 0x4a3b
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x4300