// File: /workspace/github_cpp_makefile_star2_O2/kongrigoriou[P]Text-Based-RPG/src/Grid.cpp
// Function: Grid::gameplay()
void Grid::gameplay(){
    cout << "Welcome to our game!" << endl;
    cout << "Choose heroes for your team! You can pick up to 3 heroes" << endl;

    int flag = 0;
    int BattleFlag = 0;
    int possibility;
    string input;
    while(flag == 0){
        cout << "1: to check the available heroes" << "\n" 
        << "2: if you are ready!" << "\n"
        << "if you have dicided the hero you want just write their name and he/she will be added to your squad!" << endl;
        
        cout << "3: to display your team" << endl;
        cin >> input;
        if(input == "1")
            team->display_allHeroes();
        else if(input == "3")
            team->display_myHeroes();
        else if (input == "2"){
            if(team->get_count() == 0){
                cout << "Your team is empty! You are not ready yet." << endl;
            }else{
                flag = 1;
            }
        }else if(team->search_Hero(input)){
            if(team->get_count() < 3){
                team->select_hero(input);
            }else{
                flag = 1;
            }
        }else{
            cout << "Wrong input. Try again" << endl;
        }
    }

    Map[x][y] = 3;
    display_Map();

    cout << "When you are in a common/market square you can use these commands: \n"
        << "stats: to check a hero's stats\n"
        << "inv: to ckeck a hero's inventory\n"
        << "equip: to equip a Weapon/Armor\n"
        << "use: to use a potion" << endl; 

    int play = 0;
    int monsterlvl = 0;
    list <Hero*> temp;

    display_generalinfo();
    while(play == 0){
        list <Hero*>::iterator it;
        list <Monster*>::iterator mit;
        Hero* he;
        cin >> input;
        if(input == "q" || input == "Q"){
            play = 1;
        }else {
            if(input == "W" || input == "w"){
                move_up();
                BattleFlag = 1;
            }else if(input == "A" || input == "a"){
                move_left();
                BattleFlag = 1;
            }else if(input == "S" || input == "s"){
                move_down();
                BattleFlag = 1;
            }else if(input == "D" || input == "d"){
                move_right();
                BattleFlag = 1;
            }else if(input == "stats"){
                cout << "Whose stats do you want to display?\n"
                    << "Enter the hero's name" << endl;
                cin >> input;
                he = team->search_Hero(input);
                while(he == NULL){
                    cin >> input;
                    he = team->search_Hero(input);
                }
                he->display_stats();
            }else if(input == "inv"){
                cout << "Whose inventory do you want  to display? \n"
                    << "Enter the hero's name" << endl;
                cin >> input;
                he = team->search_Hero(input);
                while(he == NULL){
                    cin >> input;
                    he = team->search_Hero(input);
                }
                he->display_inventory();
            }else 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;
                    if(input == "display"){
                        he->display_Weapons();
                    }else{
                        he->equip_weapon(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;
                    if(input == "display"){
                        he->display_Armors();
                    }else{
                        he->equip_armor(input);
                    }
                }
            }else if(input == "use"){
                cout << "Type the name of the potion you want to use\n"
                    << "To display the available potions type 'display'" << endl;
                cin >> input;
                if(input == "display"){
                    he->display_Potions();
                }else{
                    he->usePotion(input);
                }
            }
            display_Map();
        }

        possibility = rand()%100;

        if(possibility < 20 && pt == 1 && BattleFlag == 1 && input != "use" && input != "stats" && input != "equip" && input != "inv"){

            cout << "Possibility: "<< possibility << endl;
            temp = team->get_HeroList();
            for(it = temp.begin(); it != temp.end(); ++it){
                monsterlvl += (*it)->get_level();
                cout << (*it)->get_name() << endl;
            }
            monsterlvl = monsterlvl/3;
            get_monsters(monsterlvl);

            this->enter_battle();

        }else if(pt == 2){
            cout << "There's a Market near you, would you like to visit?" << endl;
            cout << "Reply with yes/no" << endl;
            int flag = 0;
            cin >> input;
            while(flag == 0){
                if(input == "yes"){            
                while (flag == 0){
                
                    market->EnterMarket();
                    cout << "Woould you like to leave the Market?" << endl;
                    cin >> input;
                    if(input == "yes")
                        flag = 1;
                }
                }else if (input == "no"){
                    flag = 1;
                }else{
                    cout << "Wrong input try again" << endl;
                    cin >> input;
                }
            }
            display_Map();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %rbx
movq 0xa034(%rip), %r14      # 0x12fd0
leaq 0x3dfd(%rip), %rsi      # 0xcda0
movq %r14, %rdi
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq 0x3dfb(%rip), %rsi      # 0xcdb5
movq %r14, %r12
movq %r14, %rdi
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x70(%rbp), %r13
movq %r12, %rdi
leaq 0x3e03(%rip), %rsi      # 0xcdee
callq 0x31a0
movq %rax, %rdi
leaq 0x3f14(%rip), %rsi      # 0xcf0e
callq 0x31a0
movq %rax, %rdi
leaq 0x3e06(%rip), %rsi      # 0xce0f
callq 0x31a0
movq %rax, %rdi
leaq 0x3ef6(%rip), %rsi      # 0xcf0e
callq 0x31a0
movq %rax, %rdi
leaq 0x3dfd(%rip), %rsi      # 0xce24
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r12, %rdi
leaq 0x3e4a(%rip), %rsi      # 0xce88
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0x9f8e(%rip), %rdi      # 0x12fe0
movq %r13, %rsi
callq 0x31f0
movq %r13, %rdi
leaq 0x365b(%rip), %rsi      # 0xc6bf
callq 0x5d10
testb %al, %al
je 0x907b
movq 0x70(%rbx), %rdi
callq 0xa6ba
jmp 0x8fe1
movq %r13, %rdi
leaq 0x36df(%rip), %rsi      # 0xc764
callq 0x5d10
testb %al, %al
je 0x909c
movq 0x70(%rbx), %rdi
callq 0xaa66
jmp 0x8fe1
movq %r13, %rdi
leaq 0x361b(%rip), %rsi      # 0xc6c1
callq 0x5d10
movq 0x70(%rbx), %r15
testb %al, %al
je 0x90cb
movq %r15, %rdi
callq 0xadaa
leaq 0x3dde(%rip), %rsi      # 0xcea0
testl %eax, %eax
je 0x9143
jmp 0x9158
leaq -0x170(%rbp), %rdi
movq %r13, %rsi
callq 0x3200
movq %r15, %rdi
leaq -0x170(%rbp), %r14
movq %r14, %rsi
callq 0xac86
movq %rax, %r15
movq %r14, %rdi
callq 0x30e0
leaq 0x3a9d(%rip), %rsi      # 0xcb9b
testq %r15, %r15
je 0x9143
movq 0x70(%rbx), %rdi
callq 0xadaa
cmpl $0x2, %eax
jg 0x9158
movq 0x70(%rbx), %r15
leaq -0x150(%rbp), %rdi
movq %r13, %rsi
callq 0x3200
movq %r15, %rdi
leaq -0x150(%rbp), %r14
movq %r14, %rsi
callq 0xab8c
movq %r14, %rdi
callq 0x30e0
jmp 0x8fe1
movq %r12, %rdi
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
jmp 0x8fe1
movq 0x60(%rbx), %rax
movslq 0x78(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x7c(%rbx), %rcx
movl $0x3, (%rax,%rcx,4)
movq %rbx, %rdi
callq 0x88b0
movq 0x9e52(%rip), %rdi      # 0x12fd0
leaq 0x3d46(%rip), %rsi      # 0xcecb
callq 0x31a0
leaq 0x3d7f(%rip), %rsi      # 0xcf10
movq %rax, %rdi
callq 0x31a0
leaq 0x3d90(%rip), %rsi      # 0xcf30
movq %rax, %rdi
callq 0x31a0
leaq 0x3da3(%rip), %rsi      # 0xcf52
movq %rax, %rdi
callq 0x31a0
leaq 0x3db4(%rip), %rsi      # 0xcf72
movq %rax, %rdi
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x50(%rbp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
andq $0x0, 0x10(%rax)
callq 0x86a2
movl $0x0, -0x34(%rbp)
movq 0x9def(%rip), %r15      # 0x12fe0
leaq -0x70(%rbp), %r12
xorl %r14d, %r14d
movq %rbx, -0x30(%rbp)
testl %r14d, %r14d
jne 0x9852
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq %r12, %rdi
leaq 0x38d5(%rip), %rsi      # 0xcaef
callq 0x5d10
testb %al, %al
jne 0x9236
movq %r12, %rdi
leaq 0x3d5a(%rip), %rsi      # 0xcf87
callq 0x5d10
testb %al, %al
je 0x923b
pushq $0x1
popq %rbx
jmp 0x9282
movq %r12, %rdi
leaq 0x3d44(%rip), %rsi      # 0xcf89
callq 0x5d10
testb %al, %al
movq -0x30(%rbp), %rbx
jne 0x9269
movq %r12, %rdi
leaq 0x3d2f(%rip), %rsi      # 0xcf8b
callq 0x5d10
testb %al, %al
je 0x9409
movq %rbx, %rdi
callq 0x8234
pushq $0x1
popq %rax
movl %eax, -0x34(%rbp)
xorl %ebx, %ebx
movq -0x30(%rbp), %rdi
callq 0x88b0
movq %r15, %r14
movq %r13, %r15
callq 0x3070
cltd
pushq $0x64
popq %rcx
idivl %ecx
cmpl $0x13, %edx
jg 0x9304
movl %edx, %r13d
movq -0x30(%rbp), %rax
movl 0x88(%rax), %eax
movl %eax, %ecx
xorl $0x1, %ecx
movl -0x34(%rbp), %edx
xorl $0x1, %edx
orl %ecx, %edx
jne 0x930e
movq %r12, %rdi
leaq 0x3a76(%rip), %rsi      # 0xcd34
callq 0x7f76
testb %al, %al
je 0x9304
movq %r12, %rdi
leaq 0x3cc4(%rip), %rsi      # 0xcf95
callq 0x7f76
testb %al, %al
je 0x9304
movq %r12, %rdi
leaq 0x3910(%rip), %rsi      # 0xcbf4
callq 0x7f76
testb %al, %al
je 0x9304
movq %r12, %rdi
leaq 0x3cdf(%rip), %rsi      # 0xcfd6
callq 0x7f76
testb %al, %al
jne 0x9876
movq -0x30(%rbp), %rax
movl 0x88(%rax), %eax
cmpl $0x2, %eax
movq %r15, %r13
movq %r14, %r15
movl %ebx, %r14d
jne 0x91fc
movq 0x9ca9(%rip), %rdi      # 0x12fd0
leaq 0x3d42(%rip), %rsi      # 0xd070
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0x9c8e(%rip), %rdi      # 0x12fd0
leaq 0x3d5b(%rip), %rsi      # 0xd0a4
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq -0x30(%rbp), %rbx
movq %r12, %rdi
leaq 0x3d47(%rip), %rsi      # 0xd0b6
callq 0x5d10
testb %al, %al
jne 0x93b3
movq %r12, %rdi
leaq 0x3d31(%rip), %rsi      # 0xd0b3
callq 0x5d10
testb %al, %al
jne 0x93fc
movq 0x9c3e(%rip), %rdi      # 0x12fd0
leaq 0x3d46(%rip), %rsi      # 0xd0df
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
jmp 0x9365
xorl %eax, %eax
testl %eax, %eax
jne 0x93fc
movq 0x68(%rbx), %rdi
callq 0x711e
movq 0x9c07(%rip), %rdi      # 0x12fd0
leaq 0x3cea(%rip), %rsi      # 0xd0ba
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq %r12, %rdi
leaq 0x3cc4(%rip), %rsi      # 0xd0b6
callq 0x5d10
movzbl %al, %eax
jmp 0x93b5
movq %rbx, %rdi
callq 0x88b0
jmp 0x91fc
movq %r12, %rdi
leaq 0x3b7a(%rip), %rsi      # 0xcf8d
callq 0x5d10
testb %al, %al
jne 0x942f
movq %r12, %rdi
leaq 0x3b69(%rip), %rsi      # 0xcf8f
callq 0x5d10
testb %al, %al
je 0x9442
movq %rbx, %rdi
callq 0x8376
pushq $0x1
popq %rax
movl %eax, -0x34(%rbp)
jmp 0x9277
movq %r12, %rdi
leaq 0x3b45(%rip), %rsi      # 0xcf91
callq 0x5d10
testb %al, %al
jne 0x9468
movq %r12, %rdi
leaq 0x35b8(%rip), %rsi      # 0xca17
callq 0x5d10
testb %al, %al
je 0x947b
movq %rbx, %rdi
callq 0x82c2
pushq $0x1
popq %rax
movl %eax, -0x34(%rbp)
jmp 0x9277
movq %r12, %rdi
leaq 0x3b0e(%rip), %rsi      # 0xcf93
callq 0x5d10
testb %al, %al
jne 0x94a1
movq %r12, %rdi
leaq 0x30ef(%rip), %rsi      # 0xc587
callq 0x5d10
testb %al, %al
je 0x94b4
movq %rbx, %rdi
callq 0x83fe
pushq $0x1
popq %rax
movl %eax, -0x34(%rbp)
jmp 0x9277
movq %r12, %rdi
leaq 0x3ad7(%rip), %rsi      # 0xcf95
callq 0x5d10
testb %al, %al
je 0x9572
movq 0x9afe(%rip), %rdi      # 0x12fd0
leaq 0x3ac2(%rip), %rsi      # 0xcf9b
callq 0x31a0
movq %rax, %rdi
leaq 0x3ad8(%rip), %rsi      # 0xcfc0
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq -0x30(%rbp), %rax
movq 0x70(%rax), %r13
leaq -0x130(%rbp), %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
leaq -0x130(%rbp), %r14
movq %r14, %rsi
callq 0xac86
movq %rax, %r13
movq -0x30(%rbp), %rbx
movq %r14, %rdi
callq 0x30e0
testq %r13, %r13
jne 0x9630
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
leaq -0x1b0(%rbp), %r14
movq 0x70(%rbx), %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
movq %r14, %rsi
callq 0xac86
movq %rax, %r13
jmp 0x9530
movq %r12, %rdi
leaq 0x3a5a(%rip), %rsi      # 0xcfd6
callq 0x5d10
testb %al, %al
je 0x963d
movq 0x9a40(%rip), %rdi      # 0x12fd0
leaq 0x3a43(%rip), %rsi      # 0xcfda
callq 0x31a0
movq %rax, %rdi
leaq 0x3a1a(%rip), %rsi      # 0xcfc0
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq -0x30(%rbp), %rax
movq 0x70(%rax), %r13
leaq -0x110(%rbp), %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
leaq -0x110(%rbp), %r14
movq %r14, %rsi
callq 0xac86
movq %rax, %r13
movq -0x30(%rbp), %rbx
movq %r14, %rdi
callq 0x30e0
testq %r13, %r13
jne 0x96f9
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
leaq -0x190(%rbp), %r14
movq 0x70(%rbx), %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
movq %r14, %rsi
callq 0xac86
movq %rax, %r13
jmp 0x95ee
movq %r13, %rdi
callq 0x4da2
jmp 0x9277
movq %r12, %rdi
leaq 0x35ad(%rip), %rsi      # 0xcbf4
callq 0x5d10
testb %al, %al
je 0x9706
movq 0x9975(%rip), %rdi      # 0x12fd0
leaq 0x3598(%rip), %rsi      # 0xcbfa
callq 0x31a0
movq %rax, %rdi
leaq 0x35b6(%rip), %rsi      # 0xcc27
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq %r12, %rdi
leaq 0x35ac(%rip), %rsi      # 0xcc3f
callq 0x5d10
testb %al, %al
je 0x9772
movq 0x9929(%rip), %rdi      # 0x12fd0
leaq 0x3598(%rip), %rsi      # 0xcc46
callq 0x31a0
movq %rax, %rdi
leaq 0x35b8(%rip), %rsi      # 0xcc75
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq %r12, %rdi
leaq 0x35c7(%rip), %rsi      # 0xcca6
callq 0x5d10
testb %al, %al
je 0x9801
movq %r13, %rdi
callq 0x4f10
jmp 0x9277
movq %r13, %rdi
callq 0x4b9a
jmp 0x9277
movq %r12, %rdi
leaq 0x3624(%rip), %rsi      # 0xcd34
callq 0x5d10
testb %al, %al
je 0x9277
movq 0x98ac(%rip), %rdi      # 0x12fd0
leaq 0x38da(%rip), %rsi      # 0xd005
callq 0x31a0
movq %rax, %rdi
leaq 0x38f8(%rip), %rsi      # 0xd032
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq %r12, %rdi
leaq 0x354a(%rip), %rsi      # 0xcca6
callq 0x5d10
testb %al, %al
je 0x97de
movq %r13, %rdi
callq 0x5098
jmp 0x9277
movq %r12, %rdi
leaq 0x34bd(%rip), %rsi      # 0xcc39
callq 0x5d10
testb %al, %al
je 0x9277
movq 0x9840(%rip), %rdi      # 0x12fd0
leaq 0x3517(%rip), %rsi      # 0xccae
callq 0x31a0
movq %rax, %rdi
leaq 0x3536(%rip), %rsi      # 0xccdc
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x31f0
movq %r12, %rdi
leaq 0x34de(%rip), %rsi      # 0xcca6
callq 0x5d10
testb %al, %al
je 0x9824
movq %r13, %rdi
callq 0x4fec
jmp 0x9277
leaq -0xb0(%rbp), %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
leaq -0xb0(%rbp), %r14
movq %r14, %rsi
callq 0x53e0
jmp 0x9845
leaq -0xf0(%rbp), %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
leaq -0xf0(%rbp), %r14
movq %r14, %rsi
callq 0x51e2
jmp 0x9845
leaq -0xd0(%rbp), %rdi
movq %r12, %rsi
callq 0x3200
movq %r13, %rdi
leaq -0xd0(%rbp), %r14
movq %r14, %rsi
callq 0x529e
movq %r14, %rdi
callq 0x30e0
jmp 0x9277
leaq -0x50(%rbp), %rdi
callq 0x7fb8
leaq -0x70(%rbp), %rdi
callq 0x30e0
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9753(%rip), %rdi      # 0x12fd0
leaq 0x37de(%rip), %rsi      # 0xd062
callq 0x31a0
movq %rax, %rdi
movl %r13d, %esi
callq 0x3230
movq %rax, %rdi
callq 0x30f0
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rsi
leaq -0x90(%rbp), %rdi
callq 0xad92
leaq -0x90(%rbp), %r14
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x8058
movq %r14, %rdi
callq 0x7fb8
xorl %r15d, %r15d
movq 0x96f8(%rip), %rbx      # 0x12fd0
movq (%r12), %r12
leaq -0x50(%rbp), %rax
cmpq %rax, %r12
je 0x991f
movq 0x10(%r12), %rdi
callq 0x42fc
movl %eax, %r13d
movq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x42e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3170
movq %rax, %rdi
callq 0x30f0
addl %r13d, %r15d
movq %r14, %rdi
callq 0x30e0
jmp 0x98d8
pushq $0x3
popq %rcx
movl %r15d, %eax
cltd
idivl %ecx
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x86fa
movq -0x30(%rbp), %rdi
callq 0x8922
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x99a0
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
jmp 0x99a0
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
jmp 0x99a0
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0x99a0
jmp 0x99d4
jmp 0x99d4
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0x99a0
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x99a0
jmp 0x99d4
movq %rax, %rbx
leaq -0x190(%rbp), %rdi
jmp 0x99a0
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x30e0
jmp 0x99d7
jmp 0x99d4
jmp 0x99d4
jmp 0x99d4
jmp 0x99d4
jmp 0x99e2
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
jmp 0x99c7
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x30e0
jmp 0x99e5
jmp 0x99d4
jmp 0x99d4
jmp 0x99d4
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x7fb8
jmp 0x99e5
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x30e0
movq %rbx, %rdi
callq 0x3240