// File: 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
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpl $0x1, -0x10(%rbp)
jne 0x156c0
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
callq 0x12f70
movq -0x100(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x68, %rdi
callq 0x12f70
movq %rax, -0x20(%rbp)
jmp 0x156f0
cmpl $0x2, -0x10(%rbp)
jne 0x156ee
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
callq 0x12f70
movq -0x100(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x58, %rdi
callq 0x12f70
movq %rax, -0x20(%rbp)
jmp 0x156f0
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x100(%rbp), %rcx
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x4(%rcx), %eax
jle 0x15719
movq -0x100(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
testb $0x1, %al
jne 0x1572c
jmp 0x157ba
cmpl $0x1, -0x10(%rbp)
jne 0x15772
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
callq 0x12f70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x14610
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
leaq -0x40(%rbp), %rsi
callq 0x16770
leaq -0x40(%rbp), %rdi
callq 0x76e0
jmp 0x157b8
cmpl $0x2, -0x10(%rbp)
jne 0x157b6
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
callq 0x12f70
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x14610
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
leaq -0x58(%rbp), %rsi
callq 0x16770
leaq -0x58(%rbp), %rdi
callq 0x76e0
jmp 0x157b8
jmp 0x157ba
cmpl $0x1, -0xc(%rbp)
jle 0x15bfc
movq 0x2c7f5(%rip), %rdi     # 0x41fc0
leaq 0x179dc(%rip), %rsi     # 0x2d1ae
callq 0x6360
movq %rax, %rdi
movq 0x2c7bf(%rip), %rsi     # 0x41fa0
callq 0x63c0
leaq -0x78(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x64c0
movq -0x108(%rbp), %rsi
movq 0x2c7d4(%rip), %rdi     # 0x41fd8
callq 0x6460
jmp 0x1580b
leaq 0x179b7(%rip), %rsi     # 0x2d1c9
leaq -0x78(%rbp), %rdi
callq 0x7460
movb %al, -0x109(%rbp)
jmp 0x15823
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x15832
jmp 0x15949
cmpl $0x1, -0x10(%rbp)
jne 0x158c7
movq -0x100(%rbp), %rsi
addq $0x68, %rsi
leaq -0x98(%rbp), %rdi
callq 0x167a0
jmp 0x15855
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
movq %rdi, -0x118(%rbp)
leaq -0x98(%rbp), %rsi
movq %rsi, -0x120(%rbp)
callq 0x16810
movq -0x120(%rbp), %rdi
callq 0x16840
movq -0x118(%rbp), %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x158a5
jmp 0x1593a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x6230
jmp 0x15ca7
cmpl $0x2, -0x10(%rbp)
jne 0x15938
movq -0x100(%rbp), %rsi
addq $0x58, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x167a0
jmp 0x158e6
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x128(%rbp)
leaq -0xa8(%rbp), %rsi
movq %rsi, -0x130(%rbp)
callq 0x16810
movq -0x130(%rbp), %rdi
callq 0x16840
movq -0x128(%rbp), %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x15936
jmp 0x15938
jmp 0x1593a
movl $0x3, -0xac(%rbp)
jmp 0x15bde
leaq 0x1787f(%rip), %rsi     # 0x2d1cf
leaq -0x78(%rbp), %rdi
callq 0x7460
movb %al, -0x131(%rbp)
jmp 0x15961
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x15970
jmp 0x15a63
cmpl $0x1, -0x10(%rbp)
jne 0x159e1
movq -0x100(%rbp), %rsi
addq $0x68, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x166b0
jmp 0x1598f
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
movq %rdi, -0x140(%rbp)
leaq -0xc0(%rbp), %rsi
movq %rsi, -0x148(%rbp)
callq 0x16720
movq -0x148(%rbp), %rdi
callq 0x16750
movq -0x140(%rbp), %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x159df
jmp 0x15a54
cmpl $0x2, -0x10(%rbp)
jne 0x15a52
movq -0x100(%rbp), %rsi
addq $0x58, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x166b0
jmp 0x15a00
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x150(%rbp)
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x158(%rbp)
callq 0x16720
movq -0x158(%rbp), %rdi
callq 0x16750
movq -0x150(%rbp), %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x15a50
jmp 0x15a52
jmp 0x15a54
movl $0x3, -0xac(%rbp)
jmp 0x15bde
leaq 0x1776b(%rip), %rsi     # 0x2d1d5
leaq -0x78(%rbp), %rdi
callq 0x7460
movb %al, -0x159(%rbp)
jmp 0x15a7b
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x15a8a
jmp 0x15b9d
movq 0x2c547(%rip), %rdi     # 0x41fd8
leaq -0xd1(%rbp), %rsi
callq 0x6490
jmp 0x15a9f
cmpl $0x1, -0x10(%rbp)
jne 0x15b17
movq -0x100(%rbp), %rsi
addq $0x68, %rsi
leaq -0xe8(%rbp), %rdi
leaq -0xd1(%rbp), %rdx
callq 0x16860
jmp 0x15ac5
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
movq %rdi, -0x168(%rbp)
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x170(%rbp)
callq 0x168e0
movq -0x170(%rbp), %rdi
callq 0x16910
movq -0x168(%rbp), %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x15b15
jmp 0x15b91
cmpl $0x2, -0x10(%rbp)
jne 0x15b8f
movq -0x100(%rbp), %rsi
addq $0x58, %rsi
leaq -0xf8(%rbp), %rdi
leaq -0xd1(%rbp), %rdx
callq 0x16860
jmp 0x15b3d
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x178(%rbp)
leaq -0xf8(%rbp), %rsi
movq %rsi, -0x180(%rbp)
callq 0x168e0
movq -0x180(%rbp), %rdi
callq 0x16910
movq -0x178(%rbp), %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x15b8d
jmp 0x15b8f
jmp 0x15b91
movl $0x3, -0xac(%rbp)
jmp 0x15bde
movq 0x2c41c(%rip), %rdi     # 0x41fc0
leaq 0x17630(%rip), %rsi     # 0x2d1db
callq 0x6360
movq %rax, -0x188(%rbp)
jmp 0x15bb9
movq -0x188(%rbp), %rdi
movq 0x2c3d9(%rip), %rsi     # 0x41fa0
callq 0x63c0
jmp 0x15bce
jmp 0x15bd0
jmp 0x15bd2
jmp 0x15bd4
movl $0x0, -0xac(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x6230
movl -0xac(%rbp), %eax
testl %eax, %eax
je 0x15bf5
jmp 0x15bf3
jmp 0x15bfa
jmp 0x157e6
jmp 0x15bfc
cmpl $0x1, -0x10(%rbp)
jne 0x15c1d
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
callq *0x48(%rax)
jmp 0x15c36
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x100(%rbp), %rdi
addq $0x58, %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
callq *0x80(%rax)
testb $0x1, %al
jne 0x15c58
jmp 0x15c78
movq -0x100(%rbp), %rdi
addq $0x68, %rdi
callq 0x12de0
movq %rax, %rdi
movq (%rdi), %rax
callq *0x80(%rax)
testb $0x1, %al
jne 0x15c84
movq -0x100(%rbp), %rdi
callq 0x15550
movl $0x4, %edi
callq 0x61a0
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x2c2f2(%rip), %rsi     # 0x41f90
xorl %eax, %eax
movl %eax, %edx
callq 0x65b0
movq -0x80(%rbp), %rdi
callq 0x65c0