// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, -0x38(%rbp)
movq 0xb751(%rip), %rdi      # 0x12fd0
leaq 0x5020(%rip), %rsi      # 0xc8a6
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0xc8(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0xb8(%rbp), %r12
movq %r12, 0x8(%r12)
movq %r12, (%r12)
andq $0x0, 0x10(%r12)
movb $0x1, %al
leaq -0xd8(%rbp), %r14
leaq -0x80(%rbp), %r15
testb $0x1, %al
je 0x7975
movq 0xb708(%rip), %rdi      # 0x12fe0
movq %r14, %rsi
callq 0x31f0
movq -0x38(%rbp), %rax
movq 0x78(%rax), %rsi
movq %r15, %rdi
callq 0xad92
movq %r12, %rdi
movq %r15, %rsi
callq 0x8058
movq %r15, %rdi
callq 0x7fb8
movq %r12, %rbx
movq (%rbx), %rbx
cmpq %r12, %rbx
je 0x7937
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x42e0
movq %r15, %rdi
movq %r14, %rsi
callq 0x5ce4
movl %eax, %r13d
movq %r15, %rdi
callq 0x30e0
testb %r13b, %r13b
je 0x7906
jmp 0x7966
movq 0xb692(%rip), %rdi      # 0x12fd0
leaq 0x4da3(%rip), %rsi      # 0xc6e8
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0xb687(%rip), %rdi      # 0x12fe0
movq %r14, %rsi
callq 0x31f0
jmp 0x78d1
movq 0x10(%rbx), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
jmp 0x78c9
movq 0xb654(%rip), %rdi      # 0x12fd0
leaq 0x4f49(%rip), %rsi      # 0xc8cc
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xb639(%rip), %rdi      # 0x12fe0
leaq -0x80(%rbp), %rsi
callq 0x31f0
leaq 0x4d08(%rip), %r14      # 0xc6bf
leaq -0x80(%rbp), %r15
leaq 0x4cff(%rip), %r12      # 0xc6c1
leaq 0x4d9b(%rip), %r13      # 0xc764
leaq 0x4d96(%rip), %rbx      # 0xc766
movq %r15, %rdi
movq %r14, %rsi
callq 0x7f76
testb %al, %al
je 0x7a38
movq %r15, %rdi
movq %r12, %rsi
callq 0x7f76
testb %al, %al
je 0x7a38
movq %r15, %rdi
movq %r13, %rsi
callq 0x7f76
testb %al, %al
je 0x7a38
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7f76
testb %al, %al
je 0x7a38
movq 0xb5bd(%rip), %rdi      # 0x12fd0
leaq 0x4d4e(%rip), %rsi      # 0xc768
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0xb5b2(%rip), %rdi      # 0x12fe0
movq %r15, %rsi
callq 0x31f0
jmp 0x79d0
leaq 0x4c80(%rip), %rsi      # 0xc6bf
leaq -0x80(%rbp), %rdi
callq 0x5d10
testb %al, %al
je 0x7b2d
movq 0xb579(%rip), %rdi      # 0x12fd0
leaq 0x4ef0(%rip), %rsi      # 0xc94e
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xb55e(%rip), %rdi      # 0x12fe0
leaq -0x60(%rbp), %rsi
callq 0x31f0
xorl %r12d, %r12d
leaq -0x60(%rbp), %r13
leaq -0xa0(%rbp), %r14
testl %r12d, %r12d
jne 0x7e1b
xorl %r12d, %r12d
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rbx
movq (%rbx), %rbx
cmpq -0x38(%rbp), %rbx
je 0x7af8
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x9f40
movq %r13, %rdi
movq %r14, %rsi
callq 0x5ce4
movl %eax, %r15d
movq %r14, %rdi
callq 0x30e0
testb %r15b, %r15b
je 0x7aae
movq 0x10(%rbx), %rsi
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x484a
pushq $0x1
popq %r12
jmp 0x7aae
testb $0x1, -0x2c(%rbp)
je 0x7a99
movq 0xb4cb(%rip), %rdi      # 0x12fd0
leaq 0x4c9e(%rip), %rsi      # 0xc7aa
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0xb4c0(%rip), %rdi      # 0x12fe0
movq %r13, %rsi
callq 0x31f0
jmp 0x7a99
leaq 0x4b8d(%rip), %rsi      # 0xc6c1
leaq -0x80(%rbp), %rdi
callq 0x5d10
testb %al, %al
je 0x7c27
movq 0xb484(%rip), %rdi      # 0x12fd0
leaq 0x4e28(%rip), %rsi      # 0xc97b
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xb469(%rip), %rdi      # 0x12fe0
leaq -0x60(%rbp), %rsi
callq 0x31f0
addq $0x18, -0x38(%rbp)
xorl %r12d, %r12d
leaq -0x60(%rbp), %r13
leaq -0xa0(%rbp), %r14
testl %r12d, %r12d
jne 0x7e1b
xorl %r12d, %r12d
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rbx
movq (%rbx), %rbx
cmpq -0x38(%rbp), %rbx
je 0x7bf2
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x9f40
movq %r13, %rdi
movq %r14, %rsi
callq 0x5ce4
movl %eax, %r15d
movq %r14, %rdi
callq 0x30e0
testb %r15b, %r15b
je 0x7ba8
movq 0x10(%rbx), %rsi
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x491c
pushq $0x1
popq %r12
jmp 0x7ba8
testb $0x1, -0x2c(%rbp)
je 0x7b93
movq 0xb3d1(%rip), %rdi      # 0x12fd0
leaq 0x4bed(%rip), %rsi      # 0xc7f3
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0xb3c6(%rip), %rdi      # 0x12fe0
movq %r13, %rsi
callq 0x31f0
jmp 0x7b93
leaq 0x4b36(%rip), %rsi      # 0xc764
leaq -0x80(%rbp), %rdi
callq 0x5d10
testb %al, %al
je 0x7d21
movq 0xb38a(%rip), %rdi      # 0x12fd0
leaq 0x4d5a(%rip), %rsi      # 0xc9a7
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xb36f(%rip), %rdi      # 0x12fe0
leaq -0x60(%rbp), %rsi
callq 0x31f0
addq $0x30, -0x38(%rbp)
xorl %r12d, %r12d
leaq -0x60(%rbp), %r13
leaq -0xa0(%rbp), %r14
testl %r12d, %r12d
jne 0x7e1b
xorl %r12d, %r12d
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rbx
movq (%rbx), %rbx
cmpq -0x38(%rbp), %rbx
je 0x7cec
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x9f40
movq %r13, %rdi
movq %r14, %rsi
callq 0x5ce4
movl %eax, %r15d
movq %r14, %rdi
callq 0x30e0
testb %r15b, %r15b
je 0x7ca2
movq 0x10(%rbx), %rsi
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x49f2
pushq $0x1
popq %r12
jmp 0x7ca2
testb $0x1, -0x2c(%rbp)
je 0x7c8d
movq 0xb2d7(%rip), %rdi      # 0x12fd0
leaq 0x4b3c(%rip), %rsi      # 0xc83c
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0xb2cc(%rip), %rdi      # 0x12fe0
movq %r13, %rsi
callq 0x31f0
jmp 0x7c8d
leaq 0x4a3e(%rip), %rsi      # 0xc766
leaq -0x80(%rbp), %rdi
callq 0x5d10
testb %al, %al
je 0x7e24
movq 0xb290(%rip), %rdi      # 0x12fd0
leaq 0x4c8d(%rip), %rsi      # 0xc9d4
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xb275(%rip), %rdi      # 0x12fe0
leaq -0x60(%rbp), %rsi
callq 0x31f0
addq $0x48, -0x38(%rbp)
xorl %r12d, %r12d
leaq -0x60(%rbp), %r13
leaq -0xa0(%rbp), %r14
testl %r12d, %r12d
jne 0x7e1b
xorl %r12d, %r12d
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rbx
movq (%rbx), %rbx
cmpq -0x38(%rbp), %rbx
je 0x7de6
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x9f40
movq %r13, %rdi
movq %r14, %rsi
callq 0x5ce4
movl %eax, %r15d
movq %r14, %rdi
callq 0x30e0
testb %r15b, %r15b
je 0x7d9c
movq 0x10(%rbx), %rsi
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x4ac8
pushq $0x1
popq %r12
jmp 0x7d9c
testb $0x1, -0x2c(%rbp)
je 0x7d87
movq 0xb1dd(%rip), %rdi      # 0x12fd0
leaq 0x4a8f(%rip), %rsi      # 0xc889
callq 0x31a0
movq %rax, %rdi
callq 0x30f0
movq 0xb1d2(%rip), %rdi      # 0x12fe0
movq %r13, %rsi
callq 0x31f0
jmp 0x7d87
leaq -0x60(%rbp), %rdi
callq 0x30e0
leaq -0x80(%rbp), %rdi
callq 0x30e0
leaq -0xb8(%rbp), %rdi
callq 0x7fb8
leaq -0xd8(%rbp), %rdi
callq 0x30e0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
jmp 0x7e99
jmp 0x7e71
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
jmp 0x7e82
movq %rax, %rbx
jmp 0x7e8e
jmp 0x7e82
jmp 0x7e82
jmp 0x7e99
jmp 0x7e82
jmp 0x7e99
jmp 0x7e82
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x30e0
leaq -0x80(%rbp), %rdi
callq 0x30e0
jmp 0x7e9c
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x7fb8
leaq -0xd8(%rbp), %rdi
callq 0x30e0
movq %rbx, %rdi
callq 0x3240