// File: /workspace/github_cpp_makefile_star2_O2/dnegovan[P]Intruder-On-Donnar-V/Space.cpp
// Function: Space::killOccupant(Player&)
bool Space::killOccupant(Player& markNelson)
{
    //opportunity to cancel murder
    std::string prompt = "Are you sure you want to kill ";
    prompt += occupant->getName();
    prompt += "? [y/n]:";
    std::cout << RED;
    char answer = getYesNo(prompt);
    std::cout << RESET;
    if (answer == 'N')
    {
        //continue game
        return true;
    }

    //print this person's death text blurb
    std::cout << std::endl;
    std::string fileName = occupant->getName() + "Death.txt";
    printFile(fileName, NARRATOR_COLOR, 0);
    wait(LONG);

    //update game variables
    if (occupant->getInfected())
    {
        //death cures host
        occupant->setInfected(false);
        markNelson.crewInfected--;
        std::cout << NARRATOR_COLOR << "\nYou knew in your gut you had to do it."
                  << std::endl << occupant->getName()
                  << " had definitely been infected with the parasite.\n"
                  << RESET;
    }
    else
    {
        markNelson.innocentsShot++;
        std::cout << NARRATOR_COLOR << "\nYou are filled with doubt. \nThere "
                  << "wasn't really any evidence that "
                  << occupant->getName()
                  << " had been infected.\n"
                  << RESET;
    }

    wait(LONG);

    occupant->setAlive(false);
    markNelson.crewDead++;

    //trigger game endings if this was last infected person
    if (markNelson.crewInfected == 0)
    {
        if (!markNelson.incubated && markNelson.innocentsShot == 0)
        {
            if (!markNelson.injectedWrong)
            {
                markNelson.state = KILLED_WIFE_PRE_INCUBATION;
                return false;
            }
            else
            {
                markNelson.state = KILLED_WIFE_WRONG_INJECTION;
                return false;
            }
        }
        if (markNelson.innocentsShot > 0)  //incubation doesn't matter for these
        {
            if (markNelson.crewDead < ALL_CREW)
            {
                markNelson.state = SHOT_INNOCENT_AND_WIFE;
                return false;
            }
            if (markNelson.crewDead == ALL_CREW)
            {
                markNelson.state = SHOT_ALL_SOME_INNOCENT;;
                return false;
            }
        }

        //only get to here if you didn't kill any innocents
        if (markNelson.incubated)
        {
            if (markNelson.crewDead == 1)
            {
                markNelson.state = KILLED_WIFE_BEFORE_SPREAD;
                return false;
            }
            if (markNelson.crewDead == 2 && markNelson.injectedWrong)
            {
                //this ending is in two places, see above
                markNelson.state = KILLED_WIFE_WRONG_INJECTION;
                return false;
            }
            if (markNelson.crewDead > 1 && markNelson.crewDead < ALL_CREW)
            {
                markNelson.state = INCUBATED_SOME_SURVIVE;
                return false;
            }
        }
    	if (markNelson.crewDead == ALL_CREW) //incubation doesn't matter here
        {
    		markNelson.state = ALL_CREW_DEAD_YOU_SURVIVE;
            return false;
        }

    }
    //if we made it here, keep playing
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2818(%rip), %rsi      # 0x11409
leaq -0x80(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x30b0
movq 0x8(%r14), %rsi
leaq -0x60(%rbp), %rdi
callq 0xa5b4
leaq -0x80(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3350
leaq -0x60(%rbp), %rdi
callq 0x3368
leaq 0x2800(%rip), %rsi      # 0x11428
leaq -0x80(%rbp), %rdi
callq 0x3330
movq 0x7390(%rip), %rdi      # 0x15fc8
leaq 0x1d64(%rip), %rsi      # 0x109a3
callq 0x31d0
leaq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3250
leaq -0xe0(%rbp), %rdi
callq 0xae36
movl %eax, %r12d
leaq -0xe0(%rbp), %rdi
callq 0x3368
movq 0x7352(%rip), %rdi      # 0x15fc8
leaq 0x1436(%rip), %rsi      # 0x100b3
callq 0x31d0
movb $0x1, %r15b
cmpb $0x4e, %r12b
je 0xeedc
movq 0x7332(%rip), %rdi      # 0x15fc8
callq 0x30f0
movq 0x8(%r14), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa5b4
leaq 0x2782(%rip), %rdx      # 0x11431
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xf202
leaq -0x40(%rbp), %rdi
callq 0x3368
leaq -0xc0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3250
leaq 0x13bc(%rip), %rsi      # 0x10098
leaq -0xa0(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x30b0
leaq -0xc0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0xb8ec
leaq -0xa0(%rbp), %rdi
callq 0x3368
leaq -0xc0(%rbp), %rdi
callq 0x3368
movsd 0x19de(%rip), %xmm0     # 0x10700
callq 0xbaf9
movq 0x8(%r14), %rdi
callq 0xa5ee
testb %al, %al
je 0xeda8
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0xa5e4
decl 0x24(%rbx)
movq 0x727f(%rip), %rdi      # 0x15fc8
leaq 0x1348(%rip), %rsi      # 0x10098
callq 0x31d0
leaq 0x26df(%rip), %rsi      # 0x1143b
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
movq 0x8(%r14), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa5b4
leaq -0x40(%rbp), %rsi
movq %r15, %rdi
callq 0x31b0
leaq 0x26d4(%rip), %rsi      # 0x11463
movq %rax, %rdi
callq 0x31d0
leaq 0x1315(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
jmp 0xee16
incl 0x2c(%rbx)
movq 0x7216(%rip), %rdi      # 0x15fc8
leaq 0x12df(%rip), %rsi      # 0x10098
callq 0x31d0
leaq 0x26d0(%rip), %rsi      # 0x11495
movq %rax, %rdi
callq 0x31d0
leaq 0x26e5(%rip), %rsi      # 0x114b9
movq %rax, %rdi
callq 0x31d0
movq %rax, %r15
movq 0x8(%r14), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa5b4
leaq -0x40(%rbp), %rsi
movq %r15, %rdi
callq 0x31b0
leaq 0x26db(%rip), %rsi      # 0x114da
movq %rax, %rdi
callq 0x31d0
leaq 0x12a5(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
leaq -0x40(%rbp), %rdi
callq 0x3368
movsd 0x18d9(%rip), %xmm0     # 0x10700
callq 0xbaf9
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0xa5d0
movl 0x20(%rbx), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x20(%rbx)
movb $0x1, %r15b
cmpl $0x0, 0x24(%rbx)
jne 0xeed3
movb 0x28(%rbx), %dl
movl 0x2c(%rbx), %esi
testl %esi, %esi
setne %dil
orb %dl, %dil
je 0xee70
testl %esi, %esi
jle 0xee96
cmpl $0x3, %ecx
jg 0xee88
movl $0xc, 0x30(%rbx)
jmp 0xeed0
cmpb $0x0, 0x18(%rbx)
je 0xee7f
movl $0x4, 0x30(%rbx)
jmp 0xeed0
movl $0x3, 0x30(%rbx)
jmp 0xeed0
cmpl $0x5, %eax
jne 0xee96
movl $0xd, 0x30(%rbx)
jmp 0xeed0
testb %dl, %dl
je 0xeec4
cmpl $0x1, %ecx
je 0xeeac
testl %ecx, %ecx
jne 0xeeb4
movl $0x5, 0x30(%rbx)
jmp 0xeed0
cmpb $0x1, 0x18(%rbx)
je 0xee76
jmp 0xeebb
decl %ecx
cmpl $0x2, %ecx
ja 0xeec4
movl $0xb, 0x30(%rbx)
jmp 0xeed0
cmpl $0x5, %eax
jne 0xeed3
movl $0xa, 0x30(%rbx)
xorl %r15d, %r15d
leaq -0x60(%rbp), %rdi
callq 0x3368
leaq -0x80(%rbp), %rdi
callq 0x3368
movl %r15d, %eax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0xef4b
jmp 0xef4b
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x3368
jmp 0xef10
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0xef2d
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
jmp 0xef52
jmp 0xef46
jmp 0xef26
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x3368
jmp 0xef4e
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0xef52
jmp 0xef4b
jmp 0xef46
jmp 0xef46
movq %rax, %rbx
jmp 0xef57
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3368
leaq -0x80(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3300