// File: negativeview[P]Software-Business-Sim/EmployeesCommand.cpp
// Function: EmployeesCommand::executeCommand(char const*)
void EmployeesCommand::executeCommand(const char *line) {
	int n_choices = this->_masterState->getPlayerCompany()->getEmployees()->size();
    keypad(stdscr, TRUE);
	MENU *my_menu = this->setupMenu((vector<NamedObject *> *)(this->_masterState->getPlayerCompany()->getEmployees()));
	WINDOW *my_menu_win = this->setupWindow(my_menu, "Employees");
	refresh();

	WINDOW *my_details_win = newwin(10, 30, 4, 44);
    box(my_details_win, 0, 0);
    mvwprintw(my_details_win, 1, 2, "Details");
	mvwaddch(my_details_win, 2, 0, ACS_LTEE);
	mvwhline(my_details_win, 2, 1, ACS_HLINE, 38);
	mvwaddch(my_details_win, 2, 39, ACS_RTEE);

    int c;
    int done = 0;
	while(!done) {
		ITEM *currentItem = current_item(my_menu);
		if (currentItem) {
			Person *p = (Person *)item_userptr(currentItem);

			list<Trait *> *realTraits = p->getRealTraits();
			int down = 3;
			for(list<Trait *>::iterator it = realTraits->begin(); it != realTraits->end(); ++it) {
				Trait *t = *it;
				char message[30];
				sprintf(message, "%10s: %s", t->getName().c_str(), t->getDiscoveryModifiedText().c_str());
				wmove(my_details_win, down, 2);
				down++;
				wprintw(my_details_win, message);
			}
		}
		wrefresh(my_details_win);

		c = wgetch(my_menu_win);
		switch(c) {
			case KEY_DOWN:
				menu_driver(my_menu, REQ_DOWN_ITEM);
				break;
			case KEY_UP:
				menu_driver(my_menu, REQ_UP_ITEM);
				break;
			case 27:
				done = 1;
				break;
		}

		wrefresh(my_menu_win);
	}

	/* Unpost and free all the memory taken up */
	unpost_menu(my_menu);

	ITEM **my_items = menu_items(my_menu);
	for(int i = 0; i < n_choices; ++i)
		free_item(my_items[i]);
	endwin();
	free_menu(my_menu);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq 0x8(%rax), %rdi
callq 0x12e20
movq %rax, %rdi
callq 0xc250
movq %rax, %rdi
callq 0x4060
movl %eax, -0x14(%rbp)
movq 0x1b3ef(%rip), %rax     # 0x23fd0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x3140
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x12e20
movq %rax, %rdi
callq 0xc250
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0xaa40
movq -0xf8(%rbp), %rdi
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0xf515(%rip), %rdx      # 0x18140
callq 0xab50
movq %rax, -0x28(%rbp)
callq 0x35b0
movl $0xa, %edi
movl $0x1e, %esi
movl $0x4, %edx
movl $0x2c, %ecx
callq 0x33b0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3620
movq -0x30(%rbp), %rdi
movl $0x1, %esi
movl $0x2, %edx
leaq 0xf8a2(%rip), %rcx      # 0x1851a
movb $0x0, %al
callq 0x30b0
movq -0x30(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x33c0
cmpl $-0x1, %eax
jne 0x8c96
jmp 0x8cac
movq -0x30(%rbp), %rdi
movq 0x1b317(%rip), %rax     # 0x23fb8
movl 0x1d0(%rax), %esi
callq 0x3100
movq -0x30(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x33c0
cmpl $-0x1, %eax
jne 0x8cc6
jmp 0x8ce1
movq -0x30(%rbp), %rdi
movq 0x1b2e7(%rip), %rax     # 0x23fb8
movl 0x1c4(%rax), %esi
movl $0x26, %edx
callq 0x3310
movq -0x30(%rbp), %rdi
movl $0x2, %esi
movl $0x27, %edx
callq 0x33c0
cmpl $-0x1, %eax
jne 0x8cfb
jmp 0x8d11
movq -0x30(%rbp), %rdi
movq 0x1b2b2(%rip), %rax     # 0x23fb8
movl 0x1d4(%rax), %esi
callq 0x3100
movl $0x0, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x8d2a
jmp 0x8f07
movq -0x20(%rbp), %rdi
callq 0x3560
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x8e8f
movq -0x40(%rbp), %rdi
callq 0x3580
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x10f10
movq %rax, -0x50(%rbp)
movl $0x3, -0x54(%rbp)
movq -0x50(%rbp), %rdi
callq 0x8fa0
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9000
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x8fd0
testb $0x1, %al
jne 0x8d93
jmp 0x8e8d
leaq -0x60(%rbp), %rdi
callq 0x9030
movq (%rax), %rax
movq %rax, -0x70(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x70(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x17090
movq -0x108(%rbp), %rdi
callq 0x3180
movq %rax, -0x100(%rbp)
movq -0x70(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x170c0
jmp 0x8ded
leaq -0xd0(%rbp), %rdi
callq 0x3180
movq -0x110(%rbp), %rdi
movq -0x100(%rbp), %rdx
movq %rax, %rcx
leaq 0xf920(%rip), %rsi      # 0x18731
movb $0x0, %al
callq 0x30a0
leaq -0xd0(%rbp), %rdi
callq 0x3210
leaq -0xb0(%rbp), %rdi
callq 0x3210
movq -0x30(%rbp), %rdi
movl -0x54(%rbp), %esi
movl $0x2, %edx
callq 0x33c0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movb $0x0, %al
callq 0x3060
leaq -0x60(%rbp), %rdi
callq 0x9060
jmp 0x8d70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3210
jmp 0x8f74
jmp 0x8e8f
movq -0x30(%rbp), %rdi
callq 0x3430
movq -0x28(%rbp), %rdi
callq 0x3130
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x114(%rbp)
subl $0x1b, %eax
je 0x8ef2
jmp 0x8eb4
movl -0x114(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x8ed2
jmp 0x8ec3
movl -0x114(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x8ee2
jmp 0x8ef9
movq -0x20(%rbp), %rdi
movl $0x203, %esi            # imm = 0x203
callq 0x32d0
jmp 0x8ef9
movq -0x20(%rbp), %rdi
movl $0x202, %esi            # imm = 0x202
callq 0x32d0
jmp 0x8ef9
movl $0x1, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3430
jmp 0x8d18
movq -0x20(%rbp), %rdi
callq 0x3290
movq -0x20(%rbp), %rdi
callq 0x30d0
movq %rax, -0xe8(%rbp)
movl $0x0, -0xec(%rbp)
movl -0xec(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x8f5d
movq -0xe8(%rbp), %rax
movslq -0xec(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3470
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x8f2a
callq 0x3450
movq -0x20(%rbp), %rdi
callq 0x3110
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0x35d0