// File: BohangZhang[P]Sorcery-C-Project/act_minion.cc
// Function: Act_Minion::use(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Act_Minion::use(int p, string t) {
    if (getSilent()) throw 1;//Number; The minion has been silented
    // use(int, "r"), bonus part if we want to add an action attacking the Ritual card
    shared_ptr<Player> targetplayer = nullptr;
    if (p == 1) {
        targetplayer = this->master->getGame()->get1();
    } else {
        targetplayer = this->master->getGame()->get2();
    }
    
    /*if (t == "r") {
        if (targetplayer->isRitualEmpty()) {
            throw 1; // You haven't played a Ritual card!
        }
        if (name == "Banish") {
            targetplayer->getRitual() = nullptr;
        } else {
            throw 4; // The Spell cannot be played upon a Ritual!
        }
    } else {
    */
    int j;
    istringstream ss{t};
    ss >> j;
    
    if (targetplayer->getSlot()->getSize() < j) throw 3; // The target Minion DNE!
    if (name == "Novice Pyromancer") {
        shared_ptr<Minion> m = targetplayer->getSlot()->getSlot()[j-1];
        m->subDefense(1);    
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdx, -0x240(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x238(%rbp)
movq (%rdi), %rax
callq *0x60(%rax)
testb $0x1, %al
jne 0x155d4
jmp 0x155f7
movl $0x4, %edi
callq 0x6160
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x3e9aa(%rip), %rsi     # 0x53f98
xorl %eax, %eax
movl %eax, %edx
callq 0x6430
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x15c60
cmpl $0x1, -0xc(%rbp)
jne 0x15692
movq -0x238(%rbp), %rdi
addq $0x70, %rdi
callq 0x12980
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x2a670
jmp 0x1562c
leaq -0x48(%rbp), %rdi
callq 0x12a20
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x22940
jmp 0x15643
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x15c80
leaq -0x38(%rbp), %rdi
callq 0x12a00
leaq -0x48(%rbp), %rdi
callq 0x12a70
jmp 0x15702
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x15908
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x12a70
jmp 0x15908
movq -0x238(%rbp), %rdi
addq $0x70, %rdi
callq 0x12980
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x2a670
jmp 0x156b0
leaq -0x78(%rbp), %rdi
callq 0x12a20
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x22970
jmp 0x156c7
leaq -0x28(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x15c80
leaq -0x68(%rbp), %rdi
callq 0x12a00
leaq -0x78(%rbp), %rdi
callq 0x12a70
jmp 0x15702
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x12a70
jmp 0x15908
movq -0x240(%rbp), %rsi
leaq -0x200(%rbp), %rdi
movl $0x8, %edx
callq 0x6410
jmp 0x1571c
leaq -0x200(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x61a0
jmp 0x1572e
leaq -0x28(%rbp), %rdi
callq 0x12980
movq %rax, %rsi
leaq -0x210(%rbp), %rdi
callq 0x2a6b0
jmp 0x15748
leaq -0x210(%rbp), %rdi
callq 0x12af0
movq %rax, %rdi
callq 0x3d230
movl %eax, -0x244(%rbp)
jmp 0x15764
movl -0x7c(%rbp), %eax
movl %eax, -0x248(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x12b30
movl -0x248(%rbp), %ecx
movl -0x244(%rbp), %eax
cmpl %ecx, %eax
jge 0x157df
movl $0x4, %edi
callq 0x6160
movq %rax, %rdi
movl $0x3, (%rdi)
movq 0x3e7f5(%rip), %rsi     # 0x53f98
xorl %eax, %eax
movl %eax, %edx
callq 0x6430
jmp 0x1591a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x158fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x12b30
jmp 0x158fc
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
leaq 0x2aff3(%rip), %rsi     # 0x407e4
callq 0x12920
movb %al, -0x249(%rbp)
jmp 0x157fe
movb -0x249(%rbp), %al
testb $0x1, %al
jne 0x1580d
jmp 0x158de
leaq -0x28(%rbp), %rdi
callq 0x12980
movq %rax, %rsi
leaq -0x230(%rbp), %rdi
callq 0x2a6b0
jmp 0x15827
leaq -0x230(%rbp), %rdi
callq 0x12af0
movq %rax, %rdi
callq 0x3d220
movq %rax, -0x258(%rbp)
jmp 0x15844
movq -0x258(%rbp), %rdi
movl -0x7c(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x12c80
movq %rax, %rsi
leaq -0x220(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x12c10
leaq -0x230(%rbp), %rdi
callq 0x12b30
movq -0x260(%rbp), %rdi
callq 0x12d30
movq %rax, %rdi
movq (%rdi), %rax
movq 0xb8(%rax), %rax
movl $0x1, %esi
callq *%rax
jmp 0x1589c
leaq -0x220(%rbp), %rdi
callq 0x12d50
jmp 0x158de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x12b30
jmp 0x158fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x12d50
jmp 0x158fc
leaq -0x200(%rbp), %rdi
callq 0x6150
leaq -0x28(%rbp), %rdi
callq 0x12a00
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
leaq -0x200(%rbp), %rdi
callq 0x6150
leaq -0x28(%rbp), %rdi
callq 0x12a00
movq -0x50(%rbp), %rdi
callq 0x6460
nopw (%rax,%rax)