// File: /workspace/github_cpp_makefile_star2_O1/Matlock42[P]Jeopardy/jgameClass.cpp
// Function: Game::showQuestion(int)
bool Game::showQuestion(int aPrompt)
{	
	int lCatagory, lPrice;
	int lPrompt;
	bool lCorrect;
	// split 2 digit prompt into category and price (and make base zero)
	lCatagory = (aPrompt / 10 % 10) - 1;	// tens digit
	lPrice = (aPrompt % 10) - 1;			// ones digit

	// make sure selection is a valid choice
	if( lCatagory >= 0 && lCatagory < this->mSize && lPrice >= 0 && lPrice < this->mSize)
	{
		// make sure it hasn't been played before
		if(!mQuestionSet[lCatagory][lPrice]->hasBeenPlayed())
		{
			// display the question from the questionSet
			mQuestionSet[lCatagory][lPrice]->askQuestion();
			cout << "\n\n";
			mQuestionSet[lCatagory][lPrice]->showAnswers();
		}
		else // has been played
		{
			cout << "This question has already been played.\n";
			return false;
		}
	}
	else // not a valid choice
	{
		cout << "Invalid input: out of bounds.\n";
		return false;
	}

	// validate the input
	bool lInputError = false;
	do
	{
		cout << "What is your answer: \n";
	    if (cin >> lPrompt) // Sanitize input to an integer
	    {
	    	lInputError = false;
	    } 
	    else
	    {
	        cout << "Entered value is not an Integer.\n\n";
	        cin.clear();
	        cin.ignore(numeric_limits<streamsize>::max(), '\n');
	        lInputError = true;
	    }
	    // ensure that the prompt is 1,2,3,4
	    if (lPrompt > 4 || lPrompt < 1)
	    {
	    	cout << "Not a valid answer.\n\n";
	    	lInputError = true;
	    }
	} while (lInputError);

	// Play the user's answer
	lCorrect = mQuestionSet[lCatagory][lPrice]->play(lPrompt);
	
	if(lCorrect)
	{
		cout << "That is correct!\n";
		// add to the score
		mScore += ((lPrice + 1) * 100);
	}
	else
	{
		cout << "That is incorrect.\n";
	}
	
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movslq %esi, %rax
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x22, %rcx
addl %eax, %ecx
movslq %ecx, %rax
imulq $0x66666667, %rax, %rdx # imm = 0x66666667
movq %rdx, %rdi
shrq $0x3f, %rdi
sarq $0x22, %rdx
addl %edi, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %eax
testl %eax, %eax
jle 0x348f
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
movl %esi, %r14d
subl %ecx, %r14d
movl 0x8(%rbx), %edx
cmpl %edx, %r14d
jg 0x348f
testl %r14d, %r14d
jle 0x348f
cmpl %edx, %eax
jg 0x348f
decl %eax
negl %ecx
addl %esi, %ecx
decl %ecx
movq 0x10(%rbx), %rdx
movl %eax, %r15d
movq (%rdx,%r15,8), %rax
movl %ecx, %r12d
movq (%rax,%r12,8), %rdi
callq 0x5ec4
testb %al, %al
je 0x34b8
movq 0x5b3f(%rip), %rdi      # 0x8fc0
leaq 0x2caf(%rip), %rsi      # 0x6137
movl $0x27, %edx
jmp 0x34a2
movq 0x5b2a(%rip), %rdi      # 0x8fc0
leaq 0x2cc2(%rip), %rsi      # 0x615f
movl $0x1e, %edx
callq 0x2230
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, -0x2c(%rbp)
movq 0x10(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%r12,8), %rdi
callq 0x5f1e
movq 0x5aec(%rip), %r14      # 0x8fc0
leaq 0x2cda(%rip), %rsi      # 0x61b5
movl $0x2, %edx
movq %r14, %rdi
callq 0x2230
movq %rbx, -0x48(%rbp)
movq 0x10(%rbx), %rax
movq %r15, -0x40(%rbp)
movq (%rax,%r15,8), %rax
movq %r12, -0x38(%rbp)
movq (%rax,%r12,8), %rdi
callq 0x5f3a
leaq 0x2c72(%rip), %r15      # 0x617e
movq 0x5abd(%rip), %r12      # 0x8fd0
leaq -0x30(%rbp), %r13
movl $0x16, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2230
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x20(%rax,%rcx), %ebx
testb $0x5, %bl
je 0x357f
movl $0x22, %edx
movq %r14, %rdi
leaq 0x2c44(%rip), %rsi      # 0x6195
callq 0x2230
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
xorl %esi, %esi
callq 0x2320
movq %r12, %rdi
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
movl $0xa, %edx
callq 0x2120
movl -0x30(%rbp), %esi
leal -0x5(%rsi), %eax
cmpl $-0x5, %eax
ja 0x35a3
movl $0x15, %edx
movq %r14, %rdi
leaq 0x2c1f(%rip), %rsi      # 0x61b8
callq 0x2230
jmp 0x3517
testb $0x5, %bl
jne 0x3517
movq -0x48(%rbp), %rbx
movq 0x10(%rbx), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5ed0
movq 0x59f0(%rip), %rdi      # 0x8fc0
testb %al, %al
je 0x35ee
leaq 0x2bf3(%rip), %rsi      # 0x61ce
movl $0x11, %edx
callq 0x2230
imull $0x64, -0x2c(%rbp), %eax
addl %eax, 0x4(%rbx)
jmp 0x35ff
leaq 0x2beb(%rip), %rsi      # 0x61e0
movl $0x13, %edx
callq 0x2230
movb $0x1, %al
jmp 0x34a9