// File: kongrigoriou[P]Text-Based-RPG/src/Grid.cpp
// Function: Grid::battle()
int Grid::battle(){
    int rounds = 1;
    int battleflag = 0;
    list <Hero*>::iterator it;
    list <Monster *>::iterator mit;
    list <Hero*> hr;
    string input;
    cout << "ROUND " << rounds << endl;
    cout << "Choose an action for each hero" << endl;

    while(battleflag == 0){
        hr = team->get_HeroList();
        for(it = hr.begin(); it != hr.end(); ++it){
            cout << (*it)->get_name() << "'s turn" << endl;
            cout << "attack/spell/potion/equip" << endl;
            for(mit = Monsters.begin(); mit != Monsters.end(); ++mit){
                if((*mit)->get_HealthPower() > 0)
                    break;
            }
            
            cin >> input;
            if(input == "equip"){
                cout << "Do you want to equip a Weapon or an Armor? \n"
                        << "Reply with weapon/armor" << endl;
                cin >> input;

                if(input == "weapon"){
                    cout << "Type the name of the weapon you want to equip\n"
                        << "To display the available weapons type 'display' " << endl;
                    cin >> input;
                    int flag = 0;
                    while(flag == 0){
                        if(input == "display"){
                            (*it)->display_Weapons();
                        }else{
                            (*it)->equip_weapon(input);
                            flag = 1;
                        }
                        cin >> input;
                    }

                }else if(input == "armor"){
                    cout << "Type the name of the armor you want to equip\n"
                        << "To display the available armors type 'display' " << endl;
                    cin >> input;
                    int flag = 0;
                    while(flag == 0){
                        if(input == "display"){
                            (*it)->display_Armors();
                        }else{
                            (*it)->equip_armor(input);
                            flag = 1;
                        }
                        cin >> input;
                    }
                }
            }else if(input == "potion"){
                cout << "Type the name of the potion you want to use" << endl;
                cout << "To display the available Potions type 'display'" << endl;
                cin >> input;
                int flag = 0;
                while(flag < 2){
                    if(input == "display"){
                        (*it)->display_Potions();
                        flag++;
                    }else{
                        (*it)->usePotion(input);
                        flag++;
                    }
                    // cin >> input;
                    flag++;
                }
            }else if(input == "attack"){
                (*it)->attack(*mit);
                (*mit)->attack(*it);
            }
        }
        if(team->all_fainted() == 1 || monsters_fainted() == 1){
            battleflag = 1;
            if(team->all_fainted() == 1){
                cout << "Your team lost :(" << endl;
                for(it = hr.begin(); it != hr.end(); ++it){
                   (*it)->hp_tohalf();
                   (*it)->lost_round();
                }
            }else{
                cout << "Gg your team won the monsters!" << endl;
                for(it = hr.begin(); it != hr.end(); ++it){
                   (*it)->hp_tohalf();
                   (*it)->round_won();
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
movl $0x1, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xde50
leaq -0x20(%rbp), %rdi
callq 0x117a0
leaq -0x38(%rbp), %rdi
callq 0xde70
leaq -0x58(%rbp), %rdi
callq 0x32c0
movq 0xf61d(%rip), %rdi      # 0x1efd0
leaq 0x61f8(%rip), %rsi      # 0x15bb2
callq 0x31e0
movq %rax, -0x160(%rbp)
jmp 0xf9c8
movq -0x160(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x3320
movq %rax, -0x170(%rbp)
jmp 0xf9e0
movq -0x170(%rbp), %rdi
movq 0xf5d2(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xf9f5
movq 0xf5d4(%rip), %rdi      # 0x1efd0
leaq 0x61b6(%rip), %rsi      # 0x15bb9
callq 0x31e0
movq %rax, -0x178(%rbp)
jmp 0xfa11
movq -0x178(%rbp), %rdi
movq 0xf5a1(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xfa26
jmp 0xfa28
cmpl $0x0, -0x10(%rbp)
jne 0x1033e
movq -0x168(%rbp), %rax
movq 0x70(%rax), %rsi
leaq -0x80(%rbp), %rdi
callq 0x14050
jmp 0xfa48
leaq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xde90
leaq -0x80(%rbp), %rdi
callq 0xdec0
leaq -0x38(%rbp), %rdi
callq 0xdee0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xdf40
movq %rax, -0x90(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xdf10
testb $0x1, %al
jne 0xfaa2
jmp 0x10172
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x4df0
jmp 0xfabc
movq 0xf50d(%rip), %rdi      # 0x1efd0
leaq -0xb0(%rbp), %rsi
callq 0x31b0
movq %rax, -0x180(%rbp)
jmp 0xfad8
movq -0x180(%rbp), %rdi
leaq 0x60f2(%rip), %rsi      # 0x15bd8
callq 0x31e0
movq %rax, -0x188(%rbp)
jmp 0xfaf4
movq -0x188(%rbp), %rdi
movq 0xf4be(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xfb09
leaq -0xb0(%rbp), %rdi
callq 0x3120
movq 0xf4b4(%rip), %rdi      # 0x1efd0
leaq 0x60bd(%rip), %rsi      # 0x15be0
callq 0x31e0
movq %rax, -0x190(%rbp)
jmp 0xfb31
movq -0x190(%rbp), %rdi
movq 0xf481(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xfb46
movq -0x168(%rbp), %rdi
addq $0x48, %rdi
callq 0x117c0
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x168(%rbp), %rdi
addq $0x48, %rdi
callq 0x11820
movq %rax, -0xc0(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x117f0
testb $0x1, %al
jne 0xfb95
jmp 0xfbf9
leaq -0x20(%rbp), %rdi
callq 0x11850
movq (%rax), %rdi
callq 0x4e40
movl %eax, -0x194(%rbp)
jmp 0xfbae
movl -0x194(%rbp), %eax
cmpl $0x0, %eax
jle 0xfbe9
jmp 0xfbf9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10340
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3120
jmp 0x10340
jmp 0xfbeb
leaq -0x20(%rbp), %rdi
callq 0x118b0
jmp 0xfb68
movq 0xf3e0(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xfc0b
leaq 0x5fe2(%rip), %rsi      # 0x15bf4
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x195(%rbp)
jmp 0xfc23
movb -0x195(%rbp), %al
testb $0x1, %al
jne 0xfc32
jmp 0xff57
movq 0xf397(%rip), %rdi      # 0x1efd0
leaq 0x5fba(%rip), %rsi      # 0x15bfa
callq 0x31e0
movq %rax, -0x1a0(%rbp)
jmp 0xfc4e
movq -0x1a0(%rbp), %rdi
leaq 0x5fcb(%rip), %rsi      # 0x15c27
callq 0x31e0
movq %rax, -0x1a8(%rbp)
jmp 0xfc6a
movq -0x1a8(%rbp), %rdi
movq 0xf348(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xfc7f
movq 0xf35a(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xfc91
leaq 0x5fa7(%rip), %rsi      # 0x15c3f
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x1a9(%rbp)
jmp 0xfca9
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0xfcb8
jmp 0xfdf2
movq 0xf311(%rip), %rdi      # 0x1efd0
leaq 0x5f80(%rip), %rsi      # 0x15c46
callq 0x31e0
movq %rax, -0x1b8(%rbp)
jmp 0xfcd4
movq -0x1b8(%rbp), %rdi
leaq 0x5f93(%rip), %rsi      # 0x15c75
callq 0x31e0
movq %rax, -0x1c0(%rbp)
jmp 0xfcf0
movq -0x1c0(%rbp), %rdi
movq 0xf2c2(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xfd05
movq 0xf2d4(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xfd17
movl $0x0, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
jne 0xfded
leaq 0x5f71(%rip), %rsi      # 0x15ca6
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x1c1(%rbp)
jmp 0xfd46
movb -0x1c1(%rbp), %al
testb $0x1, %al
jne 0xfd52
jmp 0xfd67
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x6060
jmp 0xfd65
jmp 0xfdd6
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x30c0
jmp 0xfd8c
movq -0x1d0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x6550
jmp 0xfda1
leaq -0xe8(%rbp), %rdi
callq 0x3120
movl $0x1, -0xc4(%rbp)
jmp 0xfdd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x3120
jmp 0x10340
movq 0xf203(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xfde8
jmp 0xfd21
jmp 0xff52
leaq 0x5e40(%rip), %rsi      # 0x15c39
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x1d1(%rbp)
jmp 0xfe0a
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0xfe19
jmp 0xff50
movq 0xf1b0(%rip), %rdi      # 0x1efd0
leaq 0x5e87(%rip), %rsi      # 0x15cae
callq 0x31e0
movq %rax, -0x1e0(%rbp)
jmp 0xfe35
movq -0x1e0(%rbp), %rdi
leaq 0x5e99(%rip), %rsi      # 0x15cdc
callq 0x31e0
movq %rax, -0x1e8(%rbp)
jmp 0xfe51
movq -0x1e8(%rbp), %rdi
movq 0xf161(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xfe66
movq 0xf173(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xfe78
movl $0x0, -0xec(%rbp)
cmpl $0x0, -0xec(%rbp)
jne 0xff4e
leaq 0x5e10(%rip), %rsi      # 0x15ca6
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x1e9(%rbp)
jmp 0xfea7
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0xfeb3
jmp 0xfec8
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x61d0
jmp 0xfec6
jmp 0xff37
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x30c0
jmp 0xfeed
movq -0x1f8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x66c0
jmp 0xff02
leaq -0x110(%rbp), %rdi
callq 0x3120
movl $0x1, -0xec(%rbp)
jmp 0xff37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x3120
jmp 0x10340
movq 0xf0a2(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xff49
jmp 0xfe82
jmp 0xff50
jmp 0xff52
jmp 0x10162
leaq 0x6022(%rip), %rsi      # 0x15f80
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x1f9(%rbp)
jmp 0xff6f
movb -0x1f9(%rbp), %al
testb $0x1, %al
jne 0xff7e
jmp 0x100de
movq 0xf04b(%rip), %rdi      # 0x1efd0
leaq 0x5d80(%rip), %rsi      # 0x15d0c
callq 0x31e0
movq %rax, -0x208(%rbp)
jmp 0xff9a
movq -0x208(%rbp), %rdi
movq 0xf018(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xffaf
movq 0xf01a(%rip), %rdi      # 0x1efd0
leaq 0x5d7b(%rip), %rsi      # 0x15d38
callq 0x31e0
movq %rax, -0x210(%rbp)
jmp 0xffcb
movq -0x210(%rbp), %rdi
movq 0xefe7(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0xffe0
movq 0xeff9(%rip), %rdi      # 0x1efe0
leaq -0x58(%rbp), %rsi
callq 0x32a0
jmp 0xfff2
movl $0x0, -0x114(%rbp)
cmpl $0x2, -0x114(%rbp)
jge 0x100d9
leaq 0x5c96(%rip), %rsi      # 0x15ca6
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x211(%rbp)
jmp 0x10021
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0x1002d
jmp 0x10051
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x6300
jmp 0x10040
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x100c5
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rax
movq %rax, -0x220(%rbp)
leaq -0x138(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x30c0
jmp 0x10076
movq -0x220(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x6930
jmp 0x1008b
leaq -0x138(%rbp), %rdi
callq 0x3120
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x100c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x3120
jmp 0x10340
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0xfffc
jmp 0x10160
leaq 0x5c83(%rip), %rsi      # 0x15d68
leaq -0x58(%rbp), %rdi
callq 0x7f70
movb %al, -0x221(%rbp)
jmp 0x100f6
movb -0x221(%rbp), %al
testb $0x1, %al
jne 0x10102
jmp 0x1015e
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rax
movq %rax, -0x230(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x11850
movq -0x230(%rbp), %rdi
movq (%rax), %rsi
callq 0x6e00
jmp 0x1012f
leaq -0x20(%rbp), %rdi
callq 0x11850
movq (%rax), %rax
movq %rax, -0x238(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq -0x238(%rbp), %rdi
movq (%rax), %rsi
callq 0xb220
jmp 0x1015c
jmp 0x1015e
jmp 0x10160
jmp 0x10162
jmp 0x10164
leaq -0x18(%rbp), %rdi
callq 0xdf90
jmp 0xfa79
movq -0x168(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x140a0
movl %eax, -0x23c(%rbp)
jmp 0x1018a
movl -0x23c(%rbp), %eax
cmpl $0x1, %eax
je 0x101b8
movq -0x168(%rbp), %rdi
callq 0xf560
movl %eax, -0x240(%rbp)
jmp 0x101a9
movl -0x240(%rbp), %eax
cmpl $0x1, %eax
jne 0x10339
movq -0x168(%rbp), %rax
movl $0x1, -0x10(%rbp)
movq 0x70(%rax), %rdi
callq 0x140a0
movl %eax, -0x244(%rbp)
jmp 0x101d7
movl -0x244(%rbp), %eax
cmpl $0x1, %eax
jne 0x10290
movq 0xede3(%rip), %rdi      # 0x1efd0
leaq 0x5b7b(%rip), %rsi      # 0x15d6f
callq 0x31e0
movq %rax, -0x250(%rbp)
jmp 0x10202
movq -0x250(%rbp), %rdi
movq 0xedb0(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0x10217
leaq -0x38(%rbp), %rdi
callq 0xdee0
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xdf40
movq %rax, -0x148(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0xdf10
testb $0x1, %al
jne 0x10258
jmp 0x1028b
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x6520
jmp 0x1026b
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x6ec0
jmp 0x1027e
jmp 0x10280
leaq -0x18(%rbp), %rdi
callq 0xdf90
jmp 0x10232
jmp 0x10337
movq 0xed39(%rip), %rdi      # 0x1efd0
leaq 0x5ae3(%rip), %rsi      # 0x15d81
callq 0x31e0
movq %rax, -0x258(%rbp)
jmp 0x102ac
movq -0x258(%rbp), %rdi
movq 0xed06(%rip), %rsi      # 0x1efc0
callq 0x3210
jmp 0x102c1
leaq -0x38(%rbp), %rdi
callq 0xdee0
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xdf40
movq %rax, -0x158(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0xdf10
testb $0x1, %al
jne 0x10302
jmp 0x10335
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x6520
jmp 0x10315
leaq -0x18(%rbp), %rdi
callq 0xdf70
movq (%rax), %rdi
callq 0x6ef0
jmp 0x10328
jmp 0x1032a
leaq -0x18(%rbp), %rdi
callq 0xdf90
jmp 0x102dc
jmp 0x10337
jmp 0x10339
jmp 0xfa28
ud2
leaq -0x58(%rbp), %rdi
callq 0x3120
leaq -0x38(%rbp), %rdi
callq 0xdec0
movq -0x60(%rbp), %rdi
callq 0x3330
nopl (%rax,%rax)