// File: /workspace/github_cpp_makefile_star2_O2/kaiming[P]Chamber-Crawler-3k/TextDisplay/textdisplay.cc
// Function: TextDisplay::drawFloor(std::ostream&, Board&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void TextDisplay::drawFloor(std::ostream& out, Board& board, std::string action) {
    // Print out floor diagram

    // Iterate through the current floor
    for(auto it_i = board.floors[board.getFloorNum() - 1].begin(); it_i != board.floors[board.getFloorNum() - 1].end(); ++ it_i) {
        for (auto it_j = it_i->begin(); it_j != it_i->end(); ++ it_j) {
            
            // Determine if Walkable Tile
            if (std::dynamic_pointer_cast<WalkableTile>(*it_j)) {
                // Walkable Tile 
                // Determine symbol to print
                
                // Check for Exit, Gold, Potion, or Character
                
                if (std::static_pointer_cast<WalkableTile>(*it_j)->getOccupant() != nullptr) {
                    // Determine Player or Enemy
                    
                    // Check if player
                    if ((*it_j) == board.player) {
                        // Print "@" for player
                        out << "@";
                        continue;
                    }

                    // Determine enemy type 
                    std::string enemy = std::static_pointer_cast<WalkableTile>(*it_j)->getOccupant()->getRace();

                    if (enemy == "Human") {
                        // Print "H" for Human
                        out << "H";
                    } else if (enemy == "Dwarf") {
                        // Print "W" for Dwarf
                        out << "W";
                    } else if (enemy == "Elf") {
                        // Print "E" for Elf
                        out << "E";
                    } else if (enemy == "Orc") {
                        // Print "O" for Orc
                        out << "O";
                    } else if (enemy == "Merchant") {
                        // Print "M" for Merchant
                        out << "M";
                    } else if (enemy == "Dragon") {
                        // Print "D" for Dragon
                        out << "D";
                    } else if (enemy == "Halfling") {
                        // Print "L" for Halfling
                        out << "L";
                    }

                } else if (std::static_pointer_cast<WalkableTile>(*it_j)->isExit()) {
                    // Print "\" for stairs
                    out << "\\";
                } else if (std::static_pointer_cast<WalkableTile>(*it_j)->getPotion() != nullptr) {
                    // Print "P" for potion
                    out << "P";
                } else if (std::static_pointer_cast<WalkableTile>(*it_j)->getGold() != nullptr) {
                    // Print "G" for gold
                    out << "G";
                } else {
                    // Not occupied, print type
                    out << (std::static_pointer_cast<WalkableTile>(*it_j)->getType());
                }

            } else {
                // Regular Tile, print type
                out << (*it_j)->getType();
            }

        } // End of inner loop

        // Print new line
        out << std::endl;

    } // End of outer loop


    // Print status

    // Print Status format
    // Race: XXXXX  Gold: XXX             Floor: XX
    // HP: XXX
    // Atk: XXX
    // Def: XXX
    // Action:

    // Race: XXXXX  Gold: XXX             Floor: XX
    // 24 chars Race + Gold & 9 Chars for Floor: XX
    out << "Race: " << std::left << std::setw(7) << board.playerPtr->getRace() << "  Gold: " << std::setw(3) << board.playerPtr->getGold() << std::right << std::setw(board.floors[board.floorNum -1][1].size() - 33) << "Floor: " << std::setw(2) << board.floorNum << std::endl; 
    // HP: XXX
    out << "HP: " << board.playerPtr->getHP() << std::endl;
    // Atk: XXX
    out << "Atk: " << board.playerPtr->getAtk() << std::endl;
    // Def: XXX
    out << "Def: " << board.playerPtr->getDef() << std::endl;
    // Action:
    out << "Action: " << action << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x40(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdx, %rdi
callq 0xdb20
movq %rbx, 0x8(%rsp)
movq (%rbx), %rcx
cltq
imulq $0x18, %rax, %rax
movq -0x18(%rcx,%rax), %rbx
leaq 0x20(%rsp), %rbp
leaq 0x10(%rsp), %r13
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xdb20
movq (%r15), %rcx
cltq
imulq $0x18, %rax, %rax
cmpq -0x10(%rcx,%rax), %rbx
je 0x17154
movq (%rbx), %r12
cmpq 0x8(%rbx), %r12
je 0x17143
movq %rbp, %rdi
movq %r12, %rsi
callq 0x12363
movq 0x20(%rsp), %r15
leaq 0x28(%rsp), %rdi
callq 0x6c00
testq %r15, %r15
je 0x17029
movq %r13, %rdi
movq %r12, %rsi
callq 0x9ce1
movq 0x10(%rsp), %rsi
movq %rbp, %rdi
callq 0x17424
movq 0x20(%rsp), %r15
leaq 0x28(%rsp), %rdi
callq 0x6c00
leaq 0x18(%rsp), %rdi
callq 0x6c00
testq %r15, %r15
je 0x17042
movq (%r12), %rax
movq 0x8(%rsp), %rcx
cmpq 0xb8(%rcx), %rax
je 0x17078
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x9ce1
movq 0x48(%rsp), %rsi
movq %r13, %rdi
callq 0x17424
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
movq %rbp, %rdi
callq *(%rax)
leaq 0x18(%rsp), %rdi
callq 0x6c00
leaq 0x50(%rsp), %rdi
callq 0x6c00
movq %rbp, %rdi
leaq 0x1e98(%rip), %rsi      # 0x18df8
callq 0x6801
leaq 0x2365(%rip), %rsi      # 0x192d1
testb %al, %al
jne 0x17014
movq %rbp, %rdi
leaq 0x2132(%rip), %rsi      # 0x190b0
callq 0x6801
leaq 0x2364(%rip), %rsi      # 0x192ee
testb %al, %al
jne 0x17014
movq %rbp, %rdi
leaq 0x2134(%rip), %rsi      # 0x190d0
callq 0x6801
leaq 0x2348(%rip), %rsi      # 0x192f0
testb %al, %al
jne 0x17014
movq %rbp, %rdi
leaq 0x218a(%rip), %rsi      # 0x19140
callq 0x6801
leaq 0x2330(%rip), %rsi      # 0x192f2
testb %al, %al
jne 0x17014
movq %rbp, %rdi
leaq 0x1e47(%rip), %rsi      # 0x18e17
callq 0x6801
leaq 0x2318(%rip), %rsi      # 0x192f4
testb %al, %al
jne 0x17014
movq %rbp, %rdi
leaq 0x1df7(%rip), %rsi      # 0x18de1
callq 0x6801
leaq 0x22cb(%rip), %rsi      # 0x192c1
testb %al, %al
jne 0x17014
movq %rbp, %rdi
leaq 0x20e4(%rip), %rsi      # 0x190e8
callq 0x6801
leaq 0x22e6(%rip), %rsi      # 0x192f6
testb %al, %al
je 0x1701c
movq %r14, %rdi
callq 0x51f0
movq %rbp, %rdi
callq 0x5100
jmp 0x1710e
movq (%r12), %rdi
callq 0x173b8
movsbl %al, %esi
movq %r14, %rdi
callq 0x5260
jmp 0x1710e
movq %rbp, %rdi
movq %r12, %rsi
callq 0x9ce1
movq 0x20(%rsp), %rdi
callq 0x17478
movl %eax, %r15d
leaq 0x28(%rsp), %rdi
callq 0x6c00
testb %r15b, %r15b
je 0x17087
movq %r14, %rdi
leaq 0x2285(%rip), %rsi      # 0x192f8
jmp 0x17109
movq %r14, %rdi
leaq 0x226a(%rip), %rsi      # 0x192ec
jmp 0x17109
movq %r13, %rdi
movq %r12, %rsi
callq 0x9ce1
movq 0x10(%rsp), %rsi
movq %rbp, %rdi
callq 0x17440
movq 0x20(%rsp), %r15
leaq 0x28(%rsp), %rdi
callq 0x6c00
leaq 0x18(%rsp), %rdi
callq 0x6c00
testq %r15, %r15
je 0x170c9
movq %r14, %rdi
leaq 0x2233(%rip), %rsi      # 0x192fa
jmp 0x17109
movq %r13, %rdi
movq %r12, %rsi
callq 0x9ce1
movq 0x10(%rsp), %rsi
movq %rbp, %rdi
callq 0x1745c
movq 0x20(%rsp), %r15
leaq 0x28(%rsp), %rdi
callq 0x6c00
leaq 0x18(%rsp), %rdi
callq 0x6c00
testq %r15, %r15
je 0x17117
movq %r14, %rdi
leaq 0x21f3(%rip), %rsi      # 0x192fc
callq 0x51f0
addq $0x10, %r12
jmp 0x16e9e
movq %rbp, %rdi
movq %r12, %rsi
callq 0x9ce1
movq 0x20(%rsp), %rdi
callq 0x173b8
movsbl %al, %esi
movq %r14, %rdi
callq 0x5260
leaq 0x28(%rsp), %rdi
callq 0x6c00
jmp 0x1710e
movq %r14, %rdi
callq 0x5120
addq $0x18, %rbx
jmp 0x16e7a
leaq 0x21a3(%rip), %rsi      # 0x192fe
movq %r14, %rdi
callq 0x51f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rcx
movl $0xffffff4f, %edx       # imm = 0xFFFFFF4F
andl 0x18(%rbx,%rcx), %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq $0x7, 0x10(%rbx,%rax)
movq 0x8(%rsp), %rax
movq 0xf8(%rax), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq *(%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x51d0
leaq 0x2150(%rip), %rsi      # 0x19305
movq %rax, %rdi
callq 0x51f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rax
movq $0x3, 0x10(%rbx,%rax)
movq 0x8(%rsp), %rax
movq 0xf8(%rax), %rdi
callq 0x15c44
movq %rbx, %rdi
movl %eax, %esi
callq 0x5380
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl $0xffffff4f, %esi       # imm = 0xFFFFFF4F
andl 0x18(%rax,%rdx), %esi
orl $0x80, %esi
movl %esi, 0x18(%rax,%rdx)
movq 0x8(%rsp), %rsi
movslq 0x108(%rsi), %rdx
movq (%rsi), %rsi
imulq $0x18, %rdx, %rdx
movq -0x18(%rsi,%rdx), %rdx
movq 0x20(%rdx), %rsi
subq 0x18(%rdx), %rsi
movq -0x18(%rcx), %rcx
shlq $0x1c, %rsi
movabsq $-0x2100000000, %rdx    # imm = 0xFFFFFFDF00000000
addq %rsi, %rdx
sarq $0x20, %rdx
movq %rdx, 0x10(%rax,%rcx)
leaq 0x20c4(%rip), %rsi      # 0x1930e
movq %rax, %rdi
callq 0x51f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq 0x8(%rsp), %rcx
movl 0x108(%rcx), %esi
movq %rax, %rdi
callq 0x5380
movq %rax, %rdi
callq 0x5120
leaq 0x20(%rsp), %rdi
callq 0x5100
leaq 0x2088(%rip), %rsi      # 0x19316
movq %r14, %rdi
callq 0x51f0
movq %rax, %rbx
movq 0x8(%rsp), %r15
movq 0xf8(%r15), %rdi
callq 0x135da
movq %rbx, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x5120
leaq 0x205a(%rip), %rsi      # 0x1931b
movq %r14, %rdi
callq 0x51f0
movq %rax, %rbx
movq 0xf8(%r15), %rdi
callq 0x135e0
movq %rbx, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x5120
leaq 0x2032(%rip), %rsi      # 0x19321
movq %r14, %rdi
callq 0x51f0
movq %rax, %rbx
movq 0xf8(%r15), %rdi
callq 0x135e6
movq %rbx, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x5120
leaq 0x200a(%rip), %rsi      # 0x19327
movq %r14, %rdi
callq 0x51f0
movq %rax, %rdi
movq 0x40(%rsp), %rsi
callq 0x51d0
movq %rax, %rdi
callq 0x5120
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1735b
jmp 0x17351
jmp 0x17383
jmp 0x17383
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x1738b
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5100
jmp 0x17390
movq %rax, %rbx
jmp 0x1737c
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6c00
leaq 0x50(%rsp), %rdi
jmp 0x1738b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6c00
movq %rbx, %rdi
callq 0x5390