// File: /workspace/github_cpp_makefile_star2_O2/kaiming[P]Chamber-Crawler-3k/Board/board.cc
// Function: Board::Board(std::vector<std::vector<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>, std::allocator<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>>>, std::allocator<std::vector<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>, std::allocator<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>>>>>, std::vector<bool, std::allocator<bool>>, std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>, std::vector<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>, std::allocator<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>>>, std::vector<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>, std::allocator<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, bool, int)
Board::Board(
        std::vector<std::vector<std::vector<std::shared_ptr<Tile>>>> floors, 
        std::vector<bool> filled, 
        std::vector<std::shared_ptr<WalkableTile>> playerSpawns,
        std::vector<std::vector<std::shared_ptr<WalkableTile>>> enemies,
        std::vector<std::vector<std::shared_ptr<WalkableTile>>> dragonHoards,
        std::string race,
        int seed,
        bool enemyTracking,
        int radius
) : floors{floors}, filled{filled}, playerSpawns{playerSpawns}, enemies{enemies}, dragonHoards{dragonHoards}, enemyTracking{enemyTracking}, radius{radius}, player{static_cast<int>(playerSpawns.size()) > 0 ? playerSpawns[0] : nullptr}, floorNum{1} {

    // Set seed
    if (seed != -1) {
        std::srand(seed);
    }

    // Generate Player by given Race
    if (race == "s") {
        playerPtr = std::make_shared<Shade>();
        defaultAtk = 25;
        defaultDef = 25;
    } else if (race == "d") {
        playerPtr = std::make_shared<Drow>();
        defaultAtk = 25;
        defaultDef = 15;
    } else if (race == "v") {
        playerPtr = std::make_shared<Vampire>();
        defaultAtk = 25;
        defaultDef = 25;
    } else if (race == "g") {
        playerPtr = std::make_shared<Goblin>();
        defaultAtk = 15;
        defaultDef = 20;
    } else if (race == "t") {
        playerPtr = std::make_shared<Troll>();
        defaultAtk = 25;
        defaultDef = 15;
    }

    this->race = playerPtr->getRace(); 

    // First need to identify which tiles are a part of which chamber
    assignChambers();
    
    // If not filled, generate floor pieces
    if (!filled[floorNum - 1]) {
        generateFloor();
    } else {
        // If generated, store player into given tile
        player->setOccupant(playerPtr);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r15
movq %r8, %r13
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, %rbx
callq 0x68de
leaq 0x18(%rbx), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x6938
leaq 0x40(%rbx), %rdi
movq %rdi, 0x38(%rsp)
movq %r12, %rsi
movq %rbp, 0x40(%rsp)
callq 0x69b4
leaq 0x58(%rbx), %rdi
movq %rdi, 0x30(%rsp)
movq %r13, %rsi
callq 0x6a08
leaq 0x70(%rbx), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x6a08
movl 0xa8(%rsp), %eax
movl 0x98(%rsp), %ebp
movb 0xa0(%rsp), %cl
leaq 0x98(%rbx), %rdx
movq %rdx, 0x88(%rbx)
andq $0x0, 0x90(%rbx)
movb $0x0, 0x98(%rbx)
movb %cl, 0xa8(%rbx)
movl %eax, 0xac(%rbx)
leaq 0xb8(%rbx), %r15
movq (%r12), %rsi
movq 0x8(%r12), %rax
subq %rsi, %rax
shrq $0x4, %rax
testl %eax, %eax
movq %r13, 0x28(%rsp)
jle 0xca2f
movq %r15, %rdi
callq 0x7500
jmp 0xca36
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq 0x90(%rsp), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0xf8(%rbx)
movups %xmm0, 0xe8(%rbx)
movups %xmm0, 0xd8(%rbx)
movups %xmm0, 0xc8(%rbx)
movl $0x1, 0x108(%rbx)
andw $0x0, 0x10c(%rbx)
cmpl $-0x1, %ebp
je 0xca7b
movl %ebp, %edi
callq 0x51e0
leaq 0x88(%rbx), %rbp
leaq 0xf8(%rbx), %r12
leaq 0xb85f(%rip), %rsi      # 0x182ef
movq %r13, %rdi
callq 0x6801
testb %al, %al
je 0xcac6
leaq 0x8(%rsp), %rdi
callq 0x9dba
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x1278e
leaq 0x10(%rsp), %rdi
callq 0x6c00
movaps 0xc1ec(%rip), %xmm0     # 0x18cb0
jmp 0xcb06
leaq 0xb69c(%rip), %rsi      # 0x18169
movq %r13, %rdi
callq 0x6801
testb %al, %al
je 0xcb93
leaq 0x8(%rsp), %rdi
callq 0x122f7
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x1290c
leaq 0x10(%rsp), %rdi
callq 0x6c00
movsd 0xc18a(%rip), %xmm0     # 0x18c90
movlps %xmm0, 0xb0(%rbx)
movq (%r12), %rsi
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *(%rax)
leaq 0x8(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5270
movq %r13, %rdi
callq 0x5100
movq %rbx, %rdi
callq 0xcce0
movslq 0x108(%rbx), %rsi
decq %rsi
movq %r14, %rdi
callq 0x9ba2
testq %rdx, (%rax)
je 0xcb7c
movq (%r15), %r14
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x12db4
movq %r14, %rdi
movq %r15, %rsi
callq 0x17436
leaq 0x50(%rsp), %rdi
callq 0x6c00
jmp 0xcb84
movq %rbx, %rdi
callq 0xce80
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb721(%rip), %rsi      # 0x182bb
movq %r13, %rdi
callq 0x6801
testb %al, %al
je 0xcbc2
leaq 0x8(%rsp), %rdi
callq 0x12312
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x12a8a
jmp 0xcab3
leaq 0xc526(%rip), %rsi      # 0x190ef
movq %r13, %rdi
callq 0x6801
testb %al, %al
je 0xcc03
leaq 0x8(%rsp), %rdi
callq 0x1232d
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x12c08
leaq 0x10(%rsp), %rdi
callq 0x6c00
movsd 0xc0a2(%rip), %xmm0     # 0x18ca0
jmp 0xcb06
leaq 0xc214(%rip), %rsi      # 0x18e1e
movq %r13, %rdi
callq 0x6801
testb %al, %al
je 0xcb0d
leaq 0x8(%rsp), %rdi
callq 0x12348
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x12d86
jmp 0xcaf4
jmp 0xcc67
jmp 0xcc67
jmp 0xcc67
jmp 0xcc67
jmp 0xcc67
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x6c00
jmp 0xcc6a
jmp 0xcc67
jmp 0xcc67
movq %rax, %r14
jmp 0xccb2
movq %rax, %r14
jmp 0xccbc
movq %rax, %r14
jmp 0xccc6
movq %rax, %r14
jmp 0xccd0
movq %rax, %r14
leaq 0xc8(%rbx), %r15
leaq 0xe0(%rbx), %r12
leaq 0x100(%rbx), %rdi
callq 0x6c00
movq %r12, %rdi
callq 0x6a62
movq %r15, %rdi
callq 0x6bde
leaq 0xc0(%rbx), %rdi
callq 0x6c00
movq %rbp, %rdi
callq 0x5100
movq 0x28(%rsp), %rdi
callq 0x6a62
movq 0x30(%rsp), %rdi
callq 0x6a62
movq 0x38(%rsp), %rdi
callq 0x6a84
movq 0x40(%rsp), %rdi
callq 0x6aa6
movq %rbx, %rdi
callq 0x6ab6
movq %r14, %rdi
callq 0x5390