// File: 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
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %r9, -0x118(%rbp)
movq %r8, -0x110(%rbp)
movq %rcx, -0x108(%rbp)
movq %rdx, -0xe8(%rbp)
movl 0x28(%rbp), %eax
movb 0x20(%rbp), %al
movl 0x18(%rbp), %r10d
movq 0x10(%rbp), %r10
movq %r10, -0x100(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
callq 0x8d70
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
addq $0x18, %rdi
movq %rdi, -0xe0(%rbp)
callq 0x8e60
jmp 0x22ee3
movq -0x108(%rbp), %rsi
movq -0xf8(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x120(%rbp)
callq 0x8ff0
jmp 0x22f03
movq -0x110(%rbp), %rsi
movq -0xf8(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x128(%rbp)
callq 0x90e0
jmp 0x22f23
movq -0x118(%rbp), %rsi
movq -0xf8(%rbp), %rdi
addq $0x70, %rdi
movq %rdi, -0x130(%rbp)
callq 0x90e0
jmp 0x22f43
movq -0xf8(%rbp), %rdi
addq $0x88, %rdi
movq %rdi, -0x140(%rbp)
callq 0x6430
movq -0xf8(%rbp), %rax
movq -0x108(%rbp), %rdi
movb -0x31(%rbp), %cl
andb $0x1, %cl
movb %cl, 0xa8(%rax)
movl 0x28(%rbp), %ecx
movl %ecx, 0xac(%rax)
addq $0xb8, %rax
movq %rax, -0x138(%rbp)
callq 0xd010
cmpl $0x0, %eax
jle 0x22fb8
movq -0x108(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2dc70
movq -0x138(%rbp), %rdi
movq %rax, %rsi
callq 0xd550
jmp 0x22fc8
movq -0x138(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2dc90
movq -0xf8(%rbp), %rdi
addq $0xc8, %rdi
movq %rdi, -0x158(%rbp)
callq 0x2dcb0
movq -0xf8(%rbp), %rdi
addq $0xe0, %rdi
movq %rdi, -0x150(%rbp)
callq 0x89b0
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
movq %rdi, -0x148(%rbp)
callq 0x2dcd0
movq -0xf8(%rbp), %rax
movl $0x1, 0x108(%rax)
movb $0x0, 0x10c(%rax)
movb $0x0, 0x10d(%rax)
cmpl $-0x1, 0x18(%rbp)
je 0x23089
movl 0x18(%rbp), %edi
callq 0x62c0
jmp 0x23089
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x234a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x23497
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2348b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2347f
movq -0x100(%rbp), %rdi
leaq 0x1a258(%rip), %rsi     # 0x3d2ef
callq 0x8ae0
movb %al, -0x159(%rbp)
jmp 0x230a4
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x230b0
jmp 0x2310c
leaq -0x58(%rbp), %rdi
callq 0x12fd0
jmp 0x230bb
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
leaq -0x58(%rbp), %rsi
callq 0x2dcf0
leaq -0x58(%rbp), %rdi
callq 0x13070
movq -0xf8(%rbp), %rax
movl $0x19, 0xb0(%rax)
movl $0x19, 0xb4(%rax)
jmp 0x232e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x23437
movq -0x100(%rbp), %rdi
leaq 0x1a04f(%rip), %rsi     # 0x3d169
callq 0x8ae0
movb %al, -0x15a(%rbp)
jmp 0x23127
movb -0x15a(%rbp), %al
testb $0x1, %al
jne 0x23133
jmp 0x2317e
leaq -0x68(%rbp), %rdi
callq 0x2dd20
jmp 0x2313e
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
leaq -0x68(%rbp), %rsi
callq 0x2dd90
leaq -0x68(%rbp), %rdi
callq 0x2ddc0
movq -0xf8(%rbp), %rax
movl $0x19, 0xb0(%rax)
movl $0xf, 0xb4(%rax)
jmp 0x232e4
movq -0x100(%rbp), %rdi
leaq 0x1a12f(%rip), %rsi     # 0x3d2bb
callq 0x8ae0
movb %al, -0x15b(%rbp)
jmp 0x23199
movb -0x15b(%rbp), %al
testb $0x1, %al
jne 0x231a5
jmp 0x231f0
leaq -0x78(%rbp), %rdi
callq 0x2dde0
jmp 0x231b0
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
leaq -0x78(%rbp), %rsi
callq 0x2de50
leaq -0x78(%rbp), %rdi
callq 0x2de80
movq -0xf8(%rbp), %rax
movl $0x19, 0xb0(%rax)
movl $0x19, 0xb4(%rax)
jmp 0x232e2
movq -0x100(%rbp), %rdi
leaq 0x1ae99(%rip), %rsi     # 0x3e097
callq 0x8ae0
movb %al, -0x15c(%rbp)
jmp 0x2320b
movb -0x15c(%rbp), %al
testb $0x1, %al
jne 0x23217
jmp 0x23268
leaq -0x88(%rbp), %rdi
callq 0x2dea0
jmp 0x23225
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
leaq -0x88(%rbp), %rsi
callq 0x2df10
leaq -0x88(%rbp), %rdi
callq 0x2df40
movq -0xf8(%rbp), %rax
movl $0xf, 0xb0(%rax)
movl $0x14, 0xb4(%rax)
jmp 0x232e0
movq -0x100(%rbp), %rdi
leaq 0x1ab50(%rip), %rsi     # 0x3ddc6
callq 0x8ae0
movb %al, -0x15d(%rbp)
jmp 0x23283
movb -0x15d(%rbp), %al
testb $0x1, %al
jne 0x2328f
jmp 0x232de
leaq -0x98(%rbp), %rdi
callq 0x2df60
jmp 0x2329d
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
leaq -0x98(%rbp), %rsi
callq 0x2dfd0
leaq -0x98(%rbp), %rdi
callq 0x2e000
movq -0xf8(%rbp), %rax
movl $0x19, 0xb0(%rax)
movl $0xf, 0xb4(%rax)
jmp 0x232e0
jmp 0x232e2
jmp 0x232e4
jmp 0x232e6
movq -0xf8(%rbp), %rdi
addq $0xf8, %rdi
callq 0x2e020
movq %rax, %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0xb8(%rbp), %rdi
callq *%rax
jmp 0x2330d
movq -0xf8(%rbp), %rdi
addq $0x88, %rdi
leaq -0xb8(%rbp), %rsi
movq %rsi, -0x168(%rbp)
callq 0x63c0
movq -0x168(%rbp), %rdi
callq 0x61c0
movq -0xf8(%rbp), %rdi
callq 0x234c0
jmp 0x23348
movq -0xe8(%rbp), %rdi
movq -0xf8(%rbp), %rax
movl 0x108(%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x12120
movq %rdx, -0x178(%rbp)
movq %rax, -0x170(%rbp)
jmp 0x23376
movq -0x178(%rbp), %rax
movq -0x170(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xcf70
xorb $-0x1, %al
testb $0x1, %al
jne 0x233a6
jmp 0x233b6
movq -0xf8(%rbp), %rdi
callq 0x237b0
jmp 0x233b4
jmp 0x2342e
movq -0xf8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x2e040
movq -0xf8(%rbp), %rsi
movq %rax, -0x188(%rbp)
addq $0xf8, %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x2e060
movq -0x188(%rbp), %rdi
movq -0x180(%rbp), %rsi
callq 0x3bf90
jmp 0x23406
leaq -0xd8(%rbp), %rdi
callq 0x11fa0
jmp 0x2342e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x11fa0
jmp 0x23437
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0x148(%rbp), %rdi
callq 0x9960
movq -0x150(%rbp), %rdi
callq 0x91d0
movq -0x158(%rbp), %rdi
callq 0x9980
movq -0x138(%rbp), %rdi
callq 0x99e0
movq -0x140(%rbp), %rdi
callq 0x61c0
movq -0x130(%rbp), %rdi
callq 0x91d0
movq -0x128(%rbp), %rdi
callq 0x91d0
movq -0x120(%rbp), %rdi
callq 0x9230
movq -0xe0(%rbp), %rdi
callq 0x9290
movq -0xf0(%rbp), %rdi
callq 0x92b0
movq -0x40(%rbp), %rdi
callq 0x6540
nopl (%rax,%rax)