// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movq %rdi, %rbx
movq 0xaf1e(%rip), %r14      # 0x13fd0
leaq 0x57eb(%rip), %rsi      # 0xe8a4
movl $0x25, %edx
movq %r14, %rdi
callq 0x31c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0xa8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq -0xd0(%rbp), %r15
movq %r15, 0x8(%r15)
movq %r15, (%r15)
movq %rax, 0x10(%r15)
leaq -0x90(%rbp), %r13
movq %rbx, -0x98(%rbp)
movq 0xaeb8(%rip), %rdi      # 0x13fe0
leaq -0xb8(%rbp), %rsi
callq 0x31e0
movq 0x78(%rbx), %rsi
movq %r13, %rdi
callq 0xdd6a
movq %r15, %rdi
movq %r13, %rsi
callq 0x9b9a
movq -0x90(%rbp), %rdi
cmpq %r13, %rdi
je 0x916c
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x3190
movq %rbx, %rdi
cmpq %r13, %rbx
jne 0x9157
movq %r15, %r12
movq (%r12), %r12
cmpq %r15, %r12
je 0x91e7
movq 0x10(%r12), %rsi
movq %r13, %rdi
callq 0x489a
movq -0x88(%rbp), %rdx
cmpq -0xb0(%rbp), %rdx
jne 0x91b5
testq %rdx, %rdx
je 0x91ba
movq -0xb8(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x31a0
testl %eax, %eax
sete %r14b
jmp 0x91bd
xorl %r14d, %r14d
jmp 0x91bd
movb $0x1, %r14b
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x91d9
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3190
testb %r14b, %r14b
je 0x916f
movq 0x10(%r12), %rax
movq %rax, -0x70(%rbp)
movq -0x98(%rbp), %rbx
cmpq %r15, %r12
jne 0x9259
movl $0x25, %edx
movq 0xadd1(%rip), %rdi      # 0x13fd0
leaq 0x54e0(%rip), %rsi      # 0xe6e6
callq 0x31c0
movq 0xadbe(%rip), %rcx      # 0x13fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xada0(%rip), %rdi      # 0x13fd0
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0xad9c(%rip), %rdi      # 0x13fe0
leaq -0xb8(%rbp), %rsi
callq 0x31e0
cmpq %r15, %r12
je 0x9121
movq 0xad70(%rip), %r15      # 0x13fd0
leaq 0x5663(%rip), %rsi      # 0xe8ca
movl $0x81, %edx
movq %r15, %rdi
callq 0x31c0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xad3e(%rip), %r15      # 0x13fd0
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x90(%rbp), %rsi
leaq -0x80(%rbp), %rax
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
movb $0x0, 0x10(%rsi)
movq 0xad1d(%rip), %rdi      # 0x13fe0
callq 0x31e0
leaq 0x53ee(%rip), %r12      # 0xe6bd
leaq -0x90(%rbp), %r13
leaq 0x53e2(%rip), %r14      # 0xe6bf
movq %r13, %rdi
movq %r12, %rsi
callq 0x30a0
testl %eax, %eax
je 0x9374
movq %r13, %rdi
movq %r14, %rsi
callq 0x30a0
testl %eax, %eax
je 0x9374
movq %r13, %rdi
leaq 0x5459(%rip), %rsi      # 0xe762
callq 0x30a0
testl %eax, %eax
je 0x9374
movq %r13, %rdi
leaq 0x5448(%rip), %rsi      # 0xe764
callq 0x30a0
testl %eax, %eax
je 0x9374
movl $0x15, %edx
movq %r15, %rdi
leaq 0x5432(%rip), %rsi      # 0xe766
callq 0x31c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0xac79(%rip), %rdi      # 0x13fe0
movq %r13, %rsi
callq 0x31e0
jmp 0x92dd
leaq 0x5342(%rip), %rsi      # 0xe6bd
leaq -0x90(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
je 0x9534
leaq 0x5329(%rip), %rsi      # 0xe6bf
leaq -0x90(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
je 0x9687
leaq 0x53b1(%rip), %rsi      # 0xe762
leaq -0x90(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
je 0x97db
leaq 0x5398(%rip), %rsi      # 0xe764
leaq -0x90(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
jne 0x9944
movq 0xabe9(%rip), %r15      # 0x13fd0
leaq 0x55e4(%rip), %rsi      # 0xe9d2
movl $0x2b, %edx
movq %r15, %rdi
callq 0x31c0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xabb7(%rip), %r14      # 0x13fd0
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xab9d(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
addq $0x48, %rbx
leaq -0x68(%rbp), %r13
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x94e4
xorl %r14d, %r14d
movq 0x10(%r15), %rsi
movq %r13, %rdi
callq 0xc78e
movq -0x40(%rbp), %rdx
cmpq -0x60(%rbp), %rdx
jne 0x9493
testq %rdx, %rdx
je 0x9498
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x31a0
testl %eax, %eax
sete %r12b
jmp 0x949b
xorl %r12d, %r12d
jmp 0x949b
movb $0x1, %r12b
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x94b4
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3190
testb %r12b, %r12b
je 0x94cc
movq 0x10(%r15), %rsi
movl $0x1, %r14d
movq -0x70(%rbp), %rdi
callq 0x5440
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x9463
testl %r14d, %r14d
movq 0xaaf2(%rip), %r14      # 0x13fd0
jne 0x992b
movl $0x1c, %edx
movq %r14, %rdi
leaq 0x5394(%rip), %rsi      # 0xe887
callq 0x31c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0xaaba(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x9454
movq 0xaa95(%rip), %r15      # 0x13fd0
leaq 0x540a(%rip), %rsi      # 0xe94c
movl $0x2c, %edx
movq %r15, %rdi
callq 0x31c0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xaa63(%rip), %r14      # 0x13fd0
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xaa49(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
leaq -0x58(%rbp), %r12
leaq -0x68(%rbp), %r13
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x9637
xorl %r14d, %r14d
movq 0x10(%r15), %rsi
movq %r13, %rdi
callq 0xc78e
movq -0x40(%rbp), %rdx
cmpq -0x60(%rbp), %rdx
jne 0x95e6
testq %rdx, %rdx
je 0x95ea
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x31a0
testl %eax, %eax
sete %bl
jmp 0x95ec
xorl %ebx, %ebx
jmp 0x95ec
movb $0x1, %bl
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x9601
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3190
testb %bl, %bl
je 0x9618
movq 0x10(%r15), %rsi
movl $0x1, %r14d
movq -0x70(%rbp), %rdi
callq 0x50c4
movq (%r15), %r15
movq -0x98(%rbp), %rbx
cmpq %rbx, %r15
jne 0x95b7
testl %r14d, %r14d
movq 0xa99f(%rip), %r14      # 0x13fd0
jne 0x992b
movl $0x1d, %edx
movq %r14, %rdi
leaq 0x5162(%rip), %rsi      # 0xe7a8
callq 0x31c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0xa967(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x95a8
movq 0xa942(%rip), %r15      # 0x13fd0
leaq 0x52e4(%rip), %rsi      # 0xe979
movl $0x2b, %edx
movq %r15, %rdi
callq 0x31c0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xa910(%rip), %r14      # 0x13fd0
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xa8f6(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
addq $0x18, %rbx
leaq -0x68(%rbp), %r13
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x978b
xorl %r14d, %r14d
movq 0x10(%r15), %rsi
movq %r13, %rdi
callq 0xc78e
movq -0x40(%rbp), %rdx
cmpq -0x60(%rbp), %rdx
jne 0x973a
testq %rdx, %rdx
je 0x973f
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x31a0
testl %eax, %eax
sete %r12b
jmp 0x9742
xorl %r12d, %r12d
jmp 0x9742
movb $0x1, %r12b
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x975b
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3190
testb %r12b, %r12b
je 0x9773
movq 0x10(%r15), %rsi
movl $0x1, %r14d
movq -0x70(%rbp), %rdi
callq 0x51ec
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x970a
testl %r14d, %r14d
movq 0xa84b(%rip), %r14      # 0x13fd0
jne 0x992b
movl $0x1c, %edx
movq %r14, %rdi
leaq 0x5057(%rip), %rsi      # 0xe7f1
callq 0x31c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0xa813(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x96fb
movq 0xa7ee(%rip), %r15      # 0x13fd0
leaq 0x51bc(%rip), %rsi      # 0xe9a5
movl $0x2c, %edx
movq %r15, %rdi
callq 0x31c0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xa7bc(%rip), %r14      # 0x13fd0
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xa7a2(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
addq $0x30, %rbx
leaq -0x68(%rbp), %r13
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x98db
xorl %r14d, %r14d
movq 0x10(%r15), %rsi
movq %r13, %rdi
callq 0xc78e
movq -0x40(%rbp), %rdx
cmpq -0x60(%rbp), %rdx
jne 0x988e
testq %rdx, %rdx
je 0x9893
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x31a0
testl %eax, %eax
sete %r12b
jmp 0x9896
xorl %r12d, %r12d
jmp 0x9896
movb $0x1, %r12b
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x98af
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3190
testb %r12b, %r12b
je 0x98c7
movq 0x10(%r15), %rsi
movl $0x1, %r14d
movq -0x70(%rbp), %rdi
callq 0x5316
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x985e
testl %r14d, %r14d
movq 0xa6f7(%rip), %r14      # 0x13fd0
jne 0x992b
movl $0x1d, %edx
movq %r14, %rdi
leaq 0x4f50(%rip), %rsi      # 0xe83a
callq 0x31c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0xa6c3(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x984f
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9944
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x9960
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3190
leaq -0xd0(%rbp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x9984
movq (%rdi), %r14
movl $0x18, %esi
callq 0x3190
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x996f
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x99a6
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x3190
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
jmp 0x99e3
jmp 0x99ca
jmp 0x99e3
jmp 0x99e8
jmp 0x99e8
movq %rax, %rbx
jmp 0x9a04
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
jmp 0x99e3
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
jmp 0x99e8
movq %rax, %rbx
jmp 0x9a20
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9a04
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x9a20
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3190
leaq -0xd0(%rbp), %r14
movq (%r14), %rdi
cmpq %r14, %rdi
je 0x9a44
movq (%rdi), %r15
movl $0x18, %esi
callq 0x3190
movq %r15, %rdi
cmpq %r14, %r15
jne 0x9a2f
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x9a66
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x3190
movq %rbx, %rdi
callq 0x3220