// File: permui[P]CastleAdventure/src/command.cpp
// Function: Command(Player&, Grid&, std::map<Position, Grid, std::less<Position>, std::allocator<std::pair<Position const, Grid>>>&)
void Command(Player &player, Grid &grid, map<Position, Grid> &mp) {
	switch (grid.info.t) {
		case GT::Monster: {
			EncounterMonster(player, grid);
			if (player.pos == FAIL_POS || player.pos == QUIT_POS) return;
			break;
		}
		case GT::Princess: {
			EncounterPrincess(player, grid);
			break;
		}
		default:
			break;
	}
	cout << "Commands:";
	if (grid.commands.empty()) {
		// if the design is right, this is impossible
		cout << " no commands availible" << endl;
		return;
	}
	for (const auto &pr: grid.commands) cout << ' ' << pr.first;
	cout << endl;
	map<string, Action>::iterator it;
	while (true) {
		string com = GetA<string>();
		it = grid.commands.find(com);
		if (it != grid.commands.end()) break;
		cout << "given command not available, see the command list" << endl;
	}
	it->second(player, grid, mp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x88(%rbp)
testl %eax, %eax
je 0x10e95
jmp 0x10e4a
movl -0x88(%rbp), %eax
subl $0x1, %eax
jne 0x10ea4
jmp 0x10e57
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x110a0
movq -0x8(%rbp), %rdi
leaq 0x1be1(%rip), %rsi      # 0x12a50
callq 0x7800
testb $0x1, %al
jne 0x10e8e
movq -0x8(%rbp), %rdi
leaq 0x1bd5(%rip), %rsi      # 0x12a58
callq 0x7800
testb $0x1, %al
jne 0x10e8e
jmp 0x10e93
jmp 0x1107f
jmp 0x10ea6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x11380
jmp 0x10ea6
jmp 0x10ea6
movq 0x9123(%rip), %rdi      # 0x19fd0
leaq 0x1bac(%rip), %rsi      # 0x12a60
callq 0x3210
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
callq 0x11490
testb $0x1, %al
jne 0x10ecc
jmp 0x10ef3
movq 0x90fd(%rip), %rdi      # 0x19fd0
leaq 0x1b90(%rip), %rsi      # 0x12a6a
callq 0x3210
movq %rax, %rdi
movq 0x90d7(%rip), %rsi      # 0x19fc0
callq 0x3250
jmp 0x1107f
movq -0x10(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x114b0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x114e0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x11510
testb $0x1, %al
jne 0x10f2c
jmp 0x10f61
leaq -0x28(%rbp), %rdi
callq 0x11540
movq %rax, -0x38(%rbp)
movq 0x9090(%rip), %rdi      # 0x19fd0
movl $0x20, %esi
callq 0x32a0
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x31f0
leaq -0x28(%rbp), %rdi
callq 0xf970
jmp 0x10f19
movq 0x9068(%rip), %rdi      # 0x19fd0
movq 0x9051(%rip), %rsi      # 0x19fc0
callq 0x3250
leaq -0x40(%rbp), %rdi
callq 0x11570
leaq -0x60(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x11590
movq -0x98(%rbp), %rsi
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
callq 0x116b0
movq %rax, -0x90(%rbp)
jmp 0x10faa
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
callq 0x114e0
movq %rax, -0x80(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x11510
testb $0x1, %al
jne 0x10fe1
jmp 0x11007
movl $0x6, -0x84(%rbp)
jmp 0x11042
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3130
jmp 0x11088
movq 0x8fc2(%rip), %rdi      # 0x19fd0
leaq 0x1a6c(%rip), %rsi      # 0x12a81
callq 0x3210
movq %rax, -0xa0(%rbp)
jmp 0x11023
movq -0xa0(%rbp), %rdi
movq 0x8f8f(%rip), %rsi      # 0x19fc0
callq 0x3250
jmp 0x11038
movl $0x0, -0x84(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3130
movl -0x84(%rbp), %eax
testl %eax, %eax
je 0x11059
jmp 0x11057
jmp 0x1105e
jmp 0x10f7d
leaq -0x40(%rbp), %rdi
callq 0x116e0
movq %rax, %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x11700
addq $0xa0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x33a0
nopw %cs:(%rax,%rax)