// File: kongrigoriou[P]Text-Based-RPG/src/Market.cpp
// Function: Market::sell()
void Market::sell(){

	cout << "Which hero is selling?Type their name" << endl;
	string hero_name;
	Hero* h;
	list<Hero*> :: iterator hr;
	list<Hero*> hrList;
	int flag = 0;

	int heroFlag = 0;													//check if the hero name exists
	while(heroFlag == 0){
		cin >> hero_name;
		hrList = team->get_HeroList();
		for(hr = hrList.begin(); hr != hrList.end(); ++hr){
			if((*hr)->get_name() == hero_name){
				h = *hr;
				heroFlag = 1;
				break;
			}
		}
		if(heroFlag == 0){
			cout << "I could not find that name. Try again" << endl;
			cin >> hero_name;
		}
	}
	
	cout << "What item do you want to sell? Press 1 for Weapon,2 for Armor,3 for Potion,4 for IceSpell,5 for FireSpell and 6 for LightingSpell" << endl;
	string answer;
	cin >> answer;
	while(answer != "1" && answer!= "2" && answer!="3" && answer!="4" ){
		cout <<"Wrong input,try again" << endl;
		cin >> answer;
	}

	if(answer == "1"){

		cout << "Type the name of the weapon you want to sell" << endl;
		string weapon_name;
		cin >> weapon_name;
		list<Weapon*> ::iterator it;
		flag = 0;

		while(flag == 0){

			for (it = Weapons.begin(); it !=  Weapons.end(); ++it){

				if(weapon_name == (*it)->get_name()){
					flag = 1;
					h->sell_Weapon(*it);
				}	
			}
			if(flag == 0){
				cout <<"Weapon doesnt exist.Try again" << endl;
				cin >> weapon_name;
			}
		}

	}else if (answer == "2") {

		cout << "Type the name of the armor you want to sell" << endl;
		string armor_name;
		cin >> armor_name;
		list<Armor*> :: iterator ar;
		flag = 0;

		while(flag ==0){

			for (ar = Armors.begin(); ar !=  Armors.end(); ++ar){
	
				if(armor_name == (*ar)->get_name()){
					flag = 1;
					h->sell_Armor(*ar);
				}
			}

			if(flag == 0){
				cout <<"Armor doesnt exist.Try again" << endl;
				cin >> armor_name;
			}
		}	

	}else if(answer == "3"){

		cout << "Type the name of the potion you want to sell" << endl;
		string potion_name;
		cin >> potion_name;
		list<Potion*> :: iterator pt;
		flag =0;

		while(flag == 0){
			for (pt = Potions.begin(); pt !=  Potions.end(); ++pt){
	
				if(potion_name == (*pt)->get_name()){
					flag = 1;
					h->sell_Potion(*pt);
				}
			}
			if(flag == 0){
				cout <<"Potion doesnt exist.Try again" << endl;
				cin >> potion_name;
			}
		}

	}else if(answer == "4"){

		cout << "Type the name of the spell you want to sell" << endl;
		string spell_name;
		cin >> spell_name;
		list<Spell*> :: iterator sp;

		while(flag == 0){

			for(sp = Spells.begin(); sp!= Spells.end(); ++sp){

				if(spell_name == (*sp)->get_name()){
					flag = 1;
					h->sell_Spell(*sp);
				}
			}
			if(flag ==0 ){
				cout <<"Spell doesnt exist.Try again" << endl;
				cin >> spell_name;
			}

		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq 0x11e7f(%rip), %rdi     # 0x1efd0
leaq 0x874e(%rip), %rsi      # 0x158a6
callq 0x31e0
movq %rax, %rdi
movq 0x11e59(%rip), %rsi     # 0x1efc0
callq 0x3210
leaq -0x28(%rbp), %rdi
callq 0x32c0
leaq -0x38(%rbp), %rdi
callq 0xde50
leaq -0x50(%rbp), %rdi
callq 0xde70
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0xd2f3
movq 0x11e3a(%rip), %rdi     # 0x1efe0
leaq -0x28(%rbp), %rsi
callq 0x32a0
jmp 0xd1b1
movq -0x238(%rbp), %rax
movq 0x78(%rax), %rsi
leaq -0x80(%rbp), %rdi
callq 0x14050
jmp 0xd1c7
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xde90
leaq -0x80(%rbp), %rdi
callq 0xdec0
leaq -0x50(%rbp), %rdi
callq 0xdee0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xdf40
movq %rax, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xdf10
testb $0x1, %al
jne 0xd221
jmp 0xd2a3
leaq -0x38(%rbp), %rdi
callq 0xdf70
movq (%rax), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x4df0
jmp 0xd23b
leaq -0xb0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x7eb0
movb %al, -0x239(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3120
movb -0x239(%rbp), %al
testb $0x1, %al
jne 0xd269
jmp 0xd293
leaq -0x38(%rbp), %rdi
callq 0xdf70
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0xd2a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xdcc3
jmp 0xd295
leaq -0x38(%rbp), %rdi
callq 0xdf90
jmp 0xd1f8
cmpl $0x0, -0x58(%rbp)
jne 0xd2ee
movq 0x11d20(%rip), %rdi     # 0x1efd0
leaq 0x8431(%rip), %rsi      # 0x156e8
callq 0x31e0
movq %rax, -0x248(%rbp)
jmp 0xd2c5
movq -0x248(%rbp), %rdi
movq 0x11ced(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd2da
movq 0x11cff(%rip), %rdi     # 0x1efe0
leaq -0x28(%rbp), %rsi
callq 0x32a0
jmp 0xd2ec
jmp 0xd2ee
jmp 0xd195
movq 0x11cd6(%rip), %rdi     # 0x1efd0
leaq 0x85cb(%rip), %rsi      # 0x158cc
callq 0x31e0
movq %rax, -0x250(%rbp)
jmp 0xd30f
movq -0x250(%rbp), %rdi
movq 0x11ca3(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd324
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x32c0
movq -0x258(%rbp), %rsi
movq 0x11c9b(%rip), %rdi     # 0x1efe0
callq 0x32a0
jmp 0xd34c
jmp 0xd34e
leaq 0x836a(%rip), %rsi      # 0x156bf
leaq -0xd0(%rbp), %rdi
callq 0xdfb0
movb %al, -0x259(%rbp)
jmp 0xd369
movb -0x259(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x25a(%rbp)
jne 0xd381
jmp 0xd40a
leaq 0x8339(%rip), %rsi      # 0x156c1
leaq -0xd0(%rbp), %rdi
callq 0xdfb0
movb %al, -0x25b(%rbp)
jmp 0xd39c
movb -0x25b(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x25a(%rbp)
jne 0xd3b1
jmp 0xd40a
leaq 0x83ac(%rip), %rsi      # 0x15764
leaq -0xd0(%rbp), %rdi
callq 0xdfb0
movb %al, -0x25c(%rbp)
jmp 0xd3cc
movb -0x25c(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x25a(%rbp)
jne 0xd3e1
jmp 0xd40a
leaq 0x837e(%rip), %rsi      # 0x15766
leaq -0xd0(%rbp), %rdi
callq 0xdfb0
movb %al, -0x25d(%rbp)
jmp 0xd3fc
movb -0x25d(%rbp), %al
movb %al, -0x25a(%rbp)
jmp 0xd40a
movb -0x25a(%rbp), %al
testb $0x1, %al
jne 0xd416
jmp 0xd472
movq 0x11bb3(%rip), %rdi     # 0x1efd0
leaq 0x8344(%rip), %rsi      # 0x15768
callq 0x31e0
movq %rax, -0x268(%rbp)
jmp 0xd432
movq -0x268(%rbp), %rdi
movq 0x11b80(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd447
movq 0x11b92(%rip), %rdi     # 0x1efe0
leaq -0xd0(%rbp), %rsi
callq 0x32a0
jmp 0xd45c
jmp 0xd34e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xdcb7
leaq 0x8246(%rip), %rsi      # 0x156bf
leaq -0xd0(%rbp), %rdi
callq 0x7f70
movb %al, -0x269(%rbp)
jmp 0xd48d
movb -0x269(%rbp), %al
testb $0x1, %al
jne 0xd49c
jmp 0xd675
movq 0x11b2d(%rip), %rdi     # 0x1efd0
leaq 0x84a4(%rip), %rsi      # 0x1594e
callq 0x31e0
movq %rax, -0x278(%rbp)
jmp 0xd4b8
movq -0x278(%rbp), %rdi
movq 0x11afa(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd4cd
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x32c0
movq -0x280(%rbp), %rsi
movq 0x11af2(%rip), %rdi     # 0x1efe0
callq 0x32a0
jmp 0xd4f5
leaq -0xf8(%rbp), %rdi
callq 0x7ad0
movl $0x0, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0xd664
movq -0x238(%rbp), %rdi
callq 0x7b50
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x238(%rbp), %rdi
callq 0x7bb0
movq %rax, -0x108(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x7b80
testb $0x1, %al
jne 0xd562
jmp 0xd611
leaq -0xf8(%rbp), %rdi
callq 0x7be0
movq (%rax), %rsi
leaq -0x128(%rbp), %rdi
callq 0x12640
jmp 0xd57f
leaq -0xf0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x7eb0
movb %al, -0x281(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3120
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0xd5b0
jmp 0xd5fe
movl $0x1, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x7be0
movq -0x290(%rbp), %rdi
movq (%rax), %rsi
callq 0x5560
jmp 0xd5df
jmp 0xd5fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3120
jmp 0xdcb7
jmp 0xd600
leaq -0xf8(%rbp), %rdi
callq 0x7c00
jmp 0xd533
cmpl $0x0, -0x54(%rbp)
jne 0xd65f
movq 0x119b2(%rip), %rdi     # 0x1efd0
leaq 0x8185(%rip), %rsi      # 0x157aa
callq 0x31e0
movq %rax, -0x298(%rbp)
jmp 0xd633
movq -0x298(%rbp), %rdi
movq 0x1197f(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd648
movq 0x11991(%rip), %rdi     # 0x1efe0
leaq -0xf0(%rbp), %rsi
callq 0x32a0
jmp 0xd65d
jmp 0xd65f
jmp 0xd508
leaq -0xf0(%rbp), %rdi
callq 0x3120
jmp 0xdc90
leaq 0x8045(%rip), %rsi      # 0x156c1
leaq -0xd0(%rbp), %rdi
callq 0x7f70
movb %al, -0x299(%rbp)
jmp 0xd690
movb -0x299(%rbp), %al
testb $0x1, %al
jne 0xd69f
jmp 0xd880
movq 0x1192a(%rip), %rdi     # 0x1efd0
leaq 0x82ce(%rip), %rsi      # 0x1597b
callq 0x31e0
movq %rax, -0x2a8(%rbp)
jmp 0xd6bb
movq -0x2a8(%rbp), %rdi
movq 0x118f7(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd6d0
leaq -0x148(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x32c0
movq -0x2b0(%rbp), %rsi
movq 0x118ef(%rip), %rdi     # 0x1efe0
callq 0x32a0
jmp 0xd6f8
leaq -0x150(%rbp), %rdi
callq 0x7af0
movl $0x0, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0xd86f
movq -0x238(%rbp), %rdi
addq $0x18, %rdi
callq 0x7c20
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x238(%rbp), %rdi
addq $0x18, %rdi
callq 0x7c80
movq %rax, -0x160(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x7c50
testb $0x1, %al
jne 0xd76d
jmp 0xd81c
leaq -0x150(%rbp), %rdi
callq 0x7cb0
movq (%rax), %rsi
leaq -0x180(%rbp), %rdi
callq 0x12640
jmp 0xd78a
leaq -0x148(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x7eb0
movb %al, -0x2b1(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x3120
movb -0x2b1(%rbp), %al
testb $0x1, %al
jne 0xd7bb
jmp 0xd809
movl $0x1, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x7cb0
movq -0x2c0(%rbp), %rdi
movq (%rax), %rsi
callq 0x5680
jmp 0xd7ea
jmp 0xd809
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3120
jmp 0xdcb7
jmp 0xd80b
leaq -0x150(%rbp), %rdi
callq 0x7cd0
jmp 0xd73a
cmpl $0x0, -0x54(%rbp)
jne 0xd86a
movq 0x117a7(%rip), %rdi     # 0x1efd0
leaq 0x7fc3(%rip), %rsi      # 0x157f3
callq 0x31e0
movq %rax, -0x2c8(%rbp)
jmp 0xd83e
movq -0x2c8(%rbp), %rdi
movq 0x11774(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd853
movq 0x11786(%rip), %rdi     # 0x1efe0
leaq -0x148(%rbp), %rsi
callq 0x32a0
jmp 0xd868
jmp 0xd86a
jmp 0xd70b
leaq -0x148(%rbp), %rdi
callq 0x3120
jmp 0xdc8e
leaq 0x7edd(%rip), %rsi      # 0x15764
leaq -0xd0(%rbp), %rdi
callq 0x7f70
movb %al, -0x2c9(%rbp)
jmp 0xd89b
movb -0x2c9(%rbp), %al
testb $0x1, %al
jne 0xd8aa
jmp 0xda8b
movq 0x1171f(%rip), %rdi     # 0x1efd0
leaq 0x80ef(%rip), %rsi      # 0x159a7
callq 0x31e0
movq %rax, -0x2d8(%rbp)
jmp 0xd8c6
movq -0x2d8(%rbp), %rdi
movq 0x116ec(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xd8db
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x32c0
movq -0x2e0(%rbp), %rsi
movq 0x116e4(%rip), %rdi     # 0x1efe0
callq 0x32a0
jmp 0xd903
leaq -0x1a8(%rbp), %rdi
callq 0x7b10
movl $0x0, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0xda7a
movq -0x238(%rbp), %rdi
addq $0x30, %rdi
callq 0x7cf0
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x238(%rbp), %rdi
addq $0x30, %rdi
callq 0x7d50
movq %rax, -0x1b8(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7d20
testb $0x1, %al
jne 0xd978
jmp 0xda27
leaq -0x1a8(%rbp), %rdi
callq 0x7d80
movq (%rax), %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x12640
jmp 0xd995
leaq -0x1a0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x7eb0
movb %al, -0x2e1(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x3120
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0xd9c6
jmp 0xda14
movl $0x1, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x2f0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x7d80
movq -0x2f0(%rbp), %rdi
movq (%rax), %rsi
callq 0x57a0
jmp 0xd9f5
jmp 0xda14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x3120
jmp 0xdcb7
jmp 0xda16
leaq -0x1a8(%rbp), %rdi
callq 0x7da0
jmp 0xd945
cmpl $0x0, -0x54(%rbp)
jne 0xda75
movq 0x1159c(%rip), %rdi     # 0x1efd0
leaq 0x7e01(%rip), %rsi      # 0x1583c
callq 0x31e0
movq %rax, -0x2f8(%rbp)
jmp 0xda49
movq -0x2f8(%rbp), %rdi
movq 0x11569(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xda5e
movq 0x1157b(%rip), %rdi     # 0x1efe0
leaq -0x1a0(%rbp), %rsi
callq 0x32a0
jmp 0xda73
jmp 0xda75
jmp 0xd916
leaq -0x1a0(%rbp), %rdi
callq 0x3120
jmp 0xdc8c
leaq 0x7cd4(%rip), %rsi      # 0x15766
leaq -0xd0(%rbp), %rdi
callq 0x7f70
movb %al, -0x2f9(%rbp)
jmp 0xdaa6
movb -0x2f9(%rbp), %al
testb $0x1, %al
jne 0xdab5
jmp 0xdc8a
movq 0x11514(%rip), %rdi     # 0x1efd0
leaq 0x7f11(%rip), %rsi      # 0x159d4
callq 0x31e0
movq %rax, -0x308(%rbp)
jmp 0xdad1
movq -0x308(%rbp), %rdi
movq 0x114e1(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xdae6
leaq -0x1f8(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x32c0
movq -0x310(%rbp), %rsi
movq 0x114d9(%rip), %rdi     # 0x1efe0
callq 0x32a0
jmp 0xdb0e
leaq -0x200(%rbp), %rdi
callq 0x7b30
cmpl $0x0, -0x54(%rbp)
jne 0xdc7e
movq -0x238(%rbp), %rdi
addq $0x48, %rdi
callq 0x7dc0
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x238(%rbp), %rdi
addq $0x48, %rdi
callq 0x7e20
movq %rax, -0x210(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x7df0
testb $0x1, %al
jne 0xdb7c
jmp 0xdc2b
leaq -0x200(%rbp), %rdi
callq 0x7e50
movq (%rax), %rsi
leaq -0x230(%rbp), %rdi
callq 0x12640
jmp 0xdb99
leaq -0x1f8(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x7eb0
movb %al, -0x311(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3120
movb -0x311(%rbp), %al
testb $0x1, %al
jne 0xdbca
jmp 0xdc18
movl $0x1, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x7e50
movq -0x320(%rbp), %rdi
movq (%rax), %rsi
callq 0x58c0
jmp 0xdbf9
jmp 0xdc18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3120
jmp 0xdcb7
jmp 0xdc1a
leaq -0x200(%rbp), %rdi
callq 0x7e70
jmp 0xdb49
cmpl $0x0, -0x54(%rbp)
jne 0xdc79
movq 0x11398(%rip), %rdi     # 0x1efd0
leaq 0x7c4a(%rip), %rsi      # 0x15889
callq 0x31e0
movq %rax, -0x328(%rbp)
jmp 0xdc4d
movq -0x328(%rbp), %rdi
movq 0x11365(%rip), %rsi     # 0x1efc0
callq 0x3210
jmp 0xdc62
movq 0x11377(%rip), %rdi     # 0x1efe0
leaq -0x1f8(%rbp), %rsi
callq 0x32a0
jmp 0xdc77
jmp 0xdc79
jmp 0xdb1a
leaq -0x1f8(%rbp), %rdi
callq 0x3120
jmp 0xdc8c
jmp 0xdc8e
jmp 0xdc90
leaq -0xd0(%rbp), %rdi
callq 0x3120
leaq -0x50(%rbp), %rdi
callq 0xdec0
leaq -0x28(%rbp), %rdi
callq 0x3120
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0xd0(%rbp), %rdi
callq 0x3120
leaq -0x50(%rbp), %rdi
callq 0xdec0
leaq -0x28(%rbp), %rdi
callq 0x3120
movq -0x60(%rbp), %rdi
callq 0x3330
nop