// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq 0xaece(%rip), %r14      # 0x13fd0
leaq 0x579b(%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 -0xb0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq -0xd8(%rbp), %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
movq %rax, 0x10(%rcx)
movq 0xae76(%rip), %r15      # 0x13fe0
leaq -0x98(%rbp), %r12
movq %rbx, -0x50(%rbp)
movq %r15, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x31e0
movq 0x78(%rbx), %rsi
movq %r12, %rdi
callq 0xdde2
leaq -0xd8(%rbp), %rdi
movq %r12, %rsi
callq 0x9c4e
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x91c0
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x3190
movq %rbx, %rdi
cmpq %r12, %rbx
jne 0x91ab
leaq -0xd8(%rbp), %r15
movq -0x50(%rbp), %rbx
movq (%r15), %r15
leaq -0xd8(%rbp), %rax
cmpq %rax, %r15
je 0x924d
movq 0x10(%r15), %rsi
movq %r12, %rdi
callq 0x489e
movq -0x90(%rbp), %rdx
cmpq -0xb8(%rbp), %rdx
jne 0x9219
movq -0x98(%rbp), %r13
testq %rdx, %rdx
je 0x9225
movq -0xc0(%rbp), %rsi
movq %r13, %rdi
callq 0x31a0
testl %eax, %eax
sete %r14b
jmp 0x9228
movq -0x98(%rbp), %r13
xorl %r14d, %r14d
jmp 0x9228
movb $0x1, %r14b
leaq -0x88(%rbp), %rax
cmpq %rax, %r13
je 0x9246
movq -0x88(%rbp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x3190
testb %r14b, %r14b
je 0x91cb
jmp 0x92aa
movl $0x25, %edx
movq 0xad77(%rip), %r14      # 0x13fd0
movq %r14, %rdi
leaq 0x5483(%rip), %rsi      # 0xe6e6
callq 0x31c0
movq 0xad71(%rip), %r15      # 0x13fe0
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 %r15, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x31e0
jmp 0x9175
movq 0x10(%r15), %rax
movq %rax, -0x78(%rbp)
movq 0xad17(%rip), %r14      # 0x13fd0
leaq 0x560a(%rip), %rsi      # 0xe8ca
movl $0x81, %edx
movq %r14, %rdi
callq 0x31c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xace5(%rip), %r14      # 0x13fd0
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x98(%rbp), %rsi
leaq -0x88(%rbp), %rax
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
movb $0x0, 0x10(%rsi)
movq 0xacc1(%rip), %rdi      # 0x13fe0
callq 0x31e0
leaq 0x5392(%rip), %r15      # 0xe6bd
leaq -0x98(%rbp), %r12
leaq 0x5386(%rip), %r13      # 0xe6bf
movq %r12, %rdi
movq %r15, %rsi
callq 0x30a0
testl %eax, %eax
je 0x93d0
movq %r12, %rdi
movq %r13, %rsi
callq 0x30a0
testl %eax, %eax
je 0x93d0
movq %r12, %rdi
leaq 0x53fd(%rip), %rsi      # 0xe762
callq 0x30a0
testl %eax, %eax
je 0x93d0
movq %r12, %rdi
leaq 0x53ec(%rip), %rsi      # 0xe764
callq 0x30a0
testl %eax, %eax
je 0x93d0
movl $0x15, %edx
movq %r14, %rdi
leaq 0x53d6(%rip), %rsi      # 0xe766
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 0xac1d(%rip), %rdi      # 0x13fe0
movq %r12, %rsi
callq 0x31e0
jmp 0x9339
leaq 0x52e6(%rip), %rsi      # 0xe6bd
leaq -0x98(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
je 0x95a1
leaq 0x52cd(%rip), %rsi      # 0xe6bf
leaq -0x98(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
je 0x9710
leaq 0x5355(%rip), %rsi      # 0xe762
leaq -0x98(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
je 0x9875
leaq 0x533c(%rip), %rsi      # 0xe764
leaq -0x98(%rbp), %rdi
callq 0x30a0
testl %eax, %eax
jne 0x99ec
movq 0xab8d(%rip), %r14      # 0x13fd0
leaq 0x5588(%rip), %rsi      # 0xe9d2
movl $0x2b, %edx
movq %r14, %rdi
callq 0x31c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xab5b(%rip), %rdi      # 0x13fd0
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xab44(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
addq $0x48, %rbx
leaq -0x70(%rbp), %r14
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x954a
movb $0x1, %al
movl %eax, -0x50(%rbp)
movq 0x10(%r15), %rsi
movq %r14, %rdi
callq 0xc812
movq -0x40(%rbp), %rdx
cmpq -0x68(%rbp), %rdx
jne 0x94f1
movq -0x70(%rbp), %r13
testq %rdx, %rdx
je 0x94fa
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x31a0
testl %eax, %eax
sete %r12b
jmp 0x94fd
movq -0x70(%rbp), %r13
xorl %r12d, %r12d
jmp 0x94fd
movb $0x1, %r12b
leaq -0x60(%rbp), %rax
cmpq %rax, %r13
je 0x9515
movq -0x60(%rbp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x3190
testb %r12b, %r12b
jne 0x9524
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x94be
jmp 0x9540
movq 0x10(%r15), %rsi
movq -0x78(%rbp), %rdi
callq 0x5444
movq (%r15), %r15
xorl %eax, %eax
cmpq %rbx, %r15
jne 0x94bb
jmp 0x99d3
testb $0x1, -0x50(%rbp)
je 0x99d3
movl $0x1c, %edx
movq 0xaa7a(%rip), %r15      # 0x13fd0
movq %r15, %rdi
leaq 0x5327(%rip), %rsi      # 0xe887
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 0xaa4d(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x94ad
movq 0xaa28(%rip), %r14      # 0x13fd0
leaq 0x539d(%rip), %rsi      # 0xe94c
movl $0x2c, %edx
movq %r14, %rdi
callq 0x31c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xa9f6(%rip), %rdi      # 0x13fd0
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xa9df(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
leaq -0x60(%rbp), %r14
leaq -0x70(%rbp), %r12
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x96b9
movb $0x1, %cl
movl %ecx, -0x9c(%rbp)
movq 0x10(%r15), %rsi
movq %r12, %rdi
callq 0xc812
movq -0x40(%rbp), %rdx
cmpq -0x68(%rbp), %rdx
jne 0x9658
movq -0x70(%rbp), %r13
testq %rdx, %rdx
je 0x9660
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x31a0
testl %eax, %eax
sete %bl
jmp 0x9662
movq -0x70(%rbp), %r13
xorl %ebx, %ebx
jmp 0x9662
movb $0x1, %bl
cmpq %r14, %r13
je 0x9676
movq -0x60(%rbp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x3190
testb %bl, %bl
jne 0x9688
movq (%r15), %r15
movq -0x50(%rbp), %rbx
cmpq %rbx, %r15
jne 0x9626
jmp 0x96ac
movq 0x10(%r15), %rsi
movq -0x78(%rbp), %rdi
callq 0x50c8
movq -0x50(%rbp), %rax
movq (%r15), %r15
xorl %ecx, %ecx
cmpq %rax, %r15
jne 0x9620
jmp 0x99d3
testb $0x1, -0x9c(%rbp)
je 0x99d3
movl $0x1d, %edx
movq 0xa90b(%rip), %r15      # 0x13fd0
movq %r15, %rdi
leaq 0x50d9(%rip), %rsi      # 0xe7a8
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 0xa8de(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x9612
movq 0xa8b9(%rip), %r14      # 0x13fd0
leaq 0x525b(%rip), %rsi      # 0xe979
movl $0x2b, %edx
movq %r14, %rdi
callq 0x31c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xa887(%rip), %rdi      # 0x13fd0
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xa870(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
addq $0x18, %rbx
leaq -0x70(%rbp), %r12
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x981e
movb $0x1, %al
movl %eax, -0x50(%rbp)
movq 0x10(%r15), %rsi
movq %r12, %rdi
callq 0xc812
movq -0x40(%rbp), %rdx
cmpq -0x68(%rbp), %rdx
jne 0x97c5
movq -0x70(%rbp), %r13
testq %rdx, %rdx
je 0x97ce
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x31a0
testl %eax, %eax
sete %r14b
jmp 0x97d1
movq -0x70(%rbp), %r13
xorl %r14d, %r14d
jmp 0x97d1
movb $0x1, %r14b
leaq -0x60(%rbp), %rax
cmpq %rax, %r13
je 0x97e9
movq -0x60(%rbp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x3190
testb %r14b, %r14b
jne 0x97f8
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x9792
jmp 0x9814
movq 0x10(%r15), %rsi
movq -0x78(%rbp), %rdi
callq 0x51f0
movq (%r15), %r15
xorl %eax, %eax
cmpq %rbx, %r15
jne 0x978f
jmp 0x99d3
testb $0x1, -0x50(%rbp)
je 0x99d3
movl $0x1c, %edx
movq 0xa7a6(%rip), %r14      # 0x13fd0
movq %r14, %rdi
leaq 0x4fbd(%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 0xa779(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x9781
movq 0xa754(%rip), %r14      # 0x13fd0
leaq 0x5122(%rip), %rsi      # 0xe9a5
movl $0x2c, %edx
movq %r14, %rdi
callq 0x31c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq 0xa722(%rip), %rdi      # 0x13fd0
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xa70b(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
addq $0x30, %rbx
leaq -0x70(%rbp), %r14
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x997c
movb $0x1, %al
movl %eax, -0x50(%rbp)
movq 0x10(%r15), %rsi
movq %r14, %rdi
callq 0xc812
movq -0x40(%rbp), %rdx
cmpq -0x68(%rbp), %rdx
jne 0x992a
movq -0x70(%rbp), %r13
testq %rdx, %rdx
je 0x9933
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x31a0
testl %eax, %eax
sete %r12b
jmp 0x9936
movq -0x70(%rbp), %r13
xorl %r12d, %r12d
jmp 0x9936
movb $0x1, %r12b
leaq -0x60(%rbp), %rax
cmpq %rax, %r13
je 0x994e
movq -0x60(%rbp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x3190
testb %r12b, %r12b
jne 0x995d
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x98f7
jmp 0x9976
movq 0x10(%r15), %rsi
movq -0x78(%rbp), %rdi
callq 0x531a
movq (%r15), %r15
xorl %eax, %eax
cmpq %rbx, %r15
jne 0x98f4
jmp 0x99d3
testb $0x1, -0x50(%rbp)
je 0x99d3
movl $0x1d, %edx
movq 0xa648(%rip), %r15      # 0x13fd0
movq %r15, %rdi
leaq 0x4ea8(%rip), %rsi      # 0xe83a
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 0xa61b(%rip), %rdi      # 0x13fe0
leaq -0x48(%rbp), %rsi
callq 0x31e0
jmp 0x98e6
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x99ec
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x9a0e
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x3190
leaq -0xd8(%rbp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x9a32
movq (%rdi), %r14
movl $0x18, %esi
callq 0x3190
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x9a1d
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x9a54
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x3190
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9a96
jmp 0x9a96
jmp 0x9a96
jmp 0x9a96
jmp 0x9a96
jmp 0x9a84
jmp 0x9a96
jmp 0x9a96
jmp 0x9a84
jmp 0x9a89
jmp 0x9a96
jmp 0x9a84
jmp 0x9a96
jmp 0x9a96
jmp 0x9a96
movq %rax, %rbx
jmp 0x9ad4
movq %rax, %rbx
jmp 0x9ab2
jmp 0x9a96
jmp 0x9a96
jmp 0x9a96
jmp 0x9a96
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9ab2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x9ad4
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x3190
leaq -0xd8(%rbp), %r14
movq (%r14), %rdi
cmpq %r14, %rdi
je 0x9af8
movq (%rdi), %r15
movl $0x18, %esi
callq 0x3190
movq %r15, %rdi
cmpq %r14, %r15
jne 0x9ae3
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x9b1a
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x3190
movq %rbx, %rdi
callq 0x3220