// File: /workspace/github_cpp_makefile_star2_O2/EstherJin[P]TetrisRemake/game.cc
// Function: Game::processDropCmd(int, int)
void Game::processDropCmd(int linesCleared, int board) {
	Board *tmp;
	Board *tmp2;
	if (board == 1) {
		tmp = brd1.get();
		tmp2 = brd2.get();
		//++brd1LastCleared;
	}
	else if (board == 2) {
		tmp = brd2.get();
		tmp2 = brd1.get();
		//++brd2LastCleared;
	}

	int score = tmp->getScore();
	if (score > highscore) highscore = score;

	// remove special effects from current board if there are any
	if (tmp->inSpecialEffect()) {
		if (board == 1) {
			Decorator *temp = static_cast <Decorator *>(brd1.get());
			brd1 = temp->removeDecorator();
		} else if (board == 2) {
			Decorator *temp = static_cast <Decorator *>(brd2.get());
			brd2 = temp->removeDecorator();
		}
	}
/*
	// update lines cleared
	if (linesCleared > 0) {
		if (board == 1) brd1LastCleared = 0;
		else brd2LastCleared = 0;
	}

	// add dot
	int lastCleared = board == 1 ? brd1LastCleared : brd2LastCleared;
	if (tmp->getLevel() == 4 && lastCleared % 5 == 0) {
		if (board == 1) {
			brd1 = make_shared<Force> (brd1, '.');
			brd1->setSpecialEffect();
		} else if (board == 2) {
			brd2 = make_shared<Force> (brd2, '.');
			brd2->setSpecialEffect();
		}
	}
	*/

	// activate special effects if lines are cleared
	if (linesCleared > 1) {
		cout << "Choose your special action" << endl;
		while (true) {
			string action;
			cin >> action;
			if (action == "blind") {
				if (board == 1) {
					brd2 = make_shared<Blind> (brd2);
					brd2->setSpecialEffect();
				} else if (board == 2) {
					brd1 = make_shared<Blind> (brd1);
					brd1->setSpecialEffect();
				}
				break;
			}
			else if (action == "heavy") {
				if (board == 1) {
					brd2 = make_shared<Heavy> (brd2);
					brd2->setSpecialEffect();
				} else if (board == 2) {
					brd1 = make_shared<Heavy> (brd1);
					brd1->setSpecialEffect();
				}
				break;
			}
			else if (action == "force") {
				char type;
				cin >> type;
				if (board == 1) {
					brd2 = make_shared<Force> (brd2, type);
					brd2->setSpecialEffect();
				} else if (board == 2) {
					brd1 = make_shared<Force> (brd1, type);
					brd1->setSpecialEffect();
				}
				break;
			}
			else cout << "Invalid input, try again" << endl;
		}
	}
	if (board == 1) brd2->getNextBlock();
	else brd1->getNextBlock();

	// check game over
	if (!brd1->validStartPos() || !brd2->validStartPos()) processWinner();

	throw 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
cmpl $0x1, %edx
jne 0x9035
movq 0x58(%r15), %rbx
jmp 0x903e
cmpl $0x2, %ebp
jne 0x903e
movq 0x68(%r15), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %r15, 0x8(%rsp)
cmpl 0x4(%r15), %eax
jle 0x905a
movq 0x8(%rsp), %rcx
movl %eax, 0x4(%rcx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x58(%rax)
testb %al, %al
je 0x90af
cmpl $0x1, %ebp
jne 0x907b
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %rbx
movq 0x58(%rax), %rsi
jmp 0x908d
cmpl $0x2, %ebp
jne 0x90af
movq 0x8(%rsp), %rax
leaq 0x68(%rax), %rbx
movq 0x68(%rax), %rsi
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x88ea
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9c34
leaq 0x30(%rsp), %rdi
callq 0x5e60
cmpl $0x2, %r14d
jl 0x92b7
movl %ebp, 0x24(%rsp)
movq 0x10efc(%rip), %rdi     # 0x19fc0
leaq 0x816e(%rip), %rsi      # 0x11239
callq 0x52b0
movq %rax, %rdi
callq 0x5160
movq 0x10ef9(%rip), %r15     # 0x19fd8
leaq 0x28(%rsp), %r12
leaq 0x8169(%rip), %r13      # 0x11254
leaq 0x8168(%rip), %rbp      # 0x1125a
leaq 0x8167(%rip), %rbx      # 0x11260
leaq 0x8166(%rip), %r14      # 0x11266
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x5340
movq %r12, %rdi
movq %r13, %rsi
callq 0x5d3d
testb %al, %al
jne 0x916e
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5d3d
testb %al, %al
jne 0x9196
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5d3d
testb %al, %al
jne 0x91be
movq 0x10e6c(%rip), %rdi     # 0x19fc0
movq %r14, %rsi
callq 0x52b0
movq %rax, %rdi
callq 0x5160
movq %r12, %rdi
callq 0x5140
jmp 0x9100
movl 0x24(%rsp), %ebp
cmpl $0x1, %ebp
jne 0x91fc
movq 0x8(%rsp), %rax
leaq 0x68(%rax), %r14
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x976c
jmp 0x921b
movl 0x24(%rsp), %ebp
cmpl $0x1, %ebp
jne 0x922a
movq 0x8(%rsp), %rax
leaq 0x68(%rax), %r14
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x974e
jmp 0x9245
movq 0x10e13(%rip), %rdi     # 0x19fd8
leaq 0x7(%rsp), %rsi
callq 0x5360
movl 0x24(%rsp), %ebp
cmpl $0x1, %ebp
jne 0x926a
movq 0x8(%rsp), %rax
leaq 0x68(%rax), %rbx
leaq 0x10(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %rbx, %rsi
callq 0x978a
jmp 0x928a
cmpl $0x2, %ebp
jne 0x92ad
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %r14
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x976c
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9e24
jmp 0x9252
cmpl $0x2, %ebp
jne 0x92ad
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %r14
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x974e
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9c06
leaq 0x18(%rsp), %rdi
callq 0x5e60
movq (%r14), %rdi
movq (%rdi), %rax
pushq $0x1
popq %rsi
callq *0x60(%rax)
jmp 0x92ad
cmpl $0x2, %ebp
jne 0x92ad
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %rbx
leaq 0x10(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %rbx, %rsi
callq 0x978a
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xa02a
leaq 0x18(%rsp), %rdi
callq 0x5e60
movq (%rbx), %rdi
movq (%rdi), %rax
pushq $0x1
popq %rsi
callq *0x60(%rax)
leaq 0x28(%rsp), %rdi
callq 0x5140
xorl %eax, %eax
cmpl $0x1, %ebp
sete %al
shll $0x4, %eax
movq 0x8(%rsp), %rbx
movq 0x58(%rax,%rbx), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
testb %al, %al
je 0x9313
movq 0x68(%rbx), %rdi
movq (%rdi), %rax
callq *0x80(%rax)
testb %al, %al
je 0x9313
pushq $0x4
popq %rdi
callq 0x5170
movl $0x1, (%rax)
movq 0x10c8f(%rip), %rsi     # 0x19f98
movq %rax, %rdi
xorl %edx, %edx
callq 0x5440
movq %rbx, %rdi
callq 0x8f8a
jmp 0x932b
jmp 0x932b
jmp 0x932b
jmp 0x932b
jmp 0x932b
jmp 0x932b
jmp 0x932b
jmp 0x932b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5140
movq %rbx, %rdi
callq 0x5450