// File: /workspace/github_cpp_makefile_star2_O2/BohangZhang[P]Sorcery-C-Project/player.cc
// Function: Player::play(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Player::play(int i, int p, string t) {
    if (getHand()->getHand().size() < i) throw 7; // Number; The card doesn't exist
    else {
        shared_ptr<Card> c = getHand()->getHand()[i - 1];
        if (getMagic() < c->getCost()) throw 6; // Number; You don't have enough Magic
        string card_type = c->getType();
        if (card_type == "Spell") { 
            c->action(p,t);
            getHand()->pop(i);
        } else if (card_type == "Enchantment") {
            if (t == "r") throw 9; // Number; Wrong command, Enchantment can't be played on Ritual
            
            shared_ptr<Player> targetplayer {nullptr};
            if (p == 1) {targetplayer = getGame()->get1();} 
            else {targetplayer = getGame()->get2();}   
    
            int j;
            istringstream ss{t};
            ss >> j;
            shared_ptr<Minion> m = targetplayer->getSlot()->getSlot()[j - 1];
            shared_ptr<Minion> h = dynamic_pointer_cast<Minion>(c);
            h->setOrigin(m);
            targetplayer->getSlot()->getSlot()[j - 1] = h;
            getHand()->pop(i);
        } else throw 10; // Number; Wrong command, this card can't be played to a target
        subMagic(c->getCost());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rcx, %r15
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, 0x18(%rsp)
leaq 0x38(%rdi), %r14
leaq 0xb8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x1a83e
movq (%r13), %rdi
callq 0x10e52
movq 0x8(%rax), %r13
subq (%rax), %r13
sarq $0x4, %r13
movl %ebp, %ebx
movslq %ebp, %rbp
leaq 0xc0(%rsp), %rdi
callq 0x8ea0
cmpq %rbp, %r13
jb 0x12e45
leaq 0xb8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x1a83e
movq (%r13), %rdi
callq 0x10e52
movq (%rax), %rax
shlq $0x4, %rbp
leaq (%rax,%rbp), %rsi
addq $-0x10, %rsi
leaq 0x48(%rsp), %r13
movq %r13, %rdi
callq 0xb86e
leaq 0xc0(%rsp), %rdi
callq 0x8ea0
movq 0x18(%rsp), %rax
movl 0x24(%rax), %ebp
movq (%r13), %rdi
callq 0xb418
cmpl %eax, %ebp
jl 0x12e64
movq 0x48(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0xb3f4
leaq 0xaca4(%rip), %rsi      # 0x1d84a
leaq 0x78(%rsp), %rdi
callq 0x8dc3
testb %al, %al
je 0x12c15
movq 0x48(%rsp), %r13
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x5290
movq (%r13), %rax
leaq 0x98(%rsp), %rdx
movq %r13, %rdi
movl %r12d, %esi
callq *0x48(%rax)
leaq 0x98(%rsp), %rdi
callq 0x5378
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a83e
movq (%r15), %rdi
movl %ebx, %esi
callq 0x10e84
leaq 0xc0(%rsp), %rdi
jmp 0x12e04
leaq 0xbbb8(%rip), %rsi      # 0x1e7d4
leaq 0x78(%rsp), %rdi
callq 0x8dc3
testb %al, %al
je 0x12e83
leaq 0xabbf(%rip), %rsi      # 0x1d7f4
movq %r15, %rdi
callq 0x8dc3
testb %al, %al
jne 0x12e87
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x18(%rsp), %rax
leaq 0x88(%rax), %rsi
cmpl $0x1, %r12d
jne 0x12c7f
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x8f1c
movq (%r12), %rsi
leaq 0xb8(%rsp), %rdi
callq 0xe58e
jmp 0x12c9d
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x8f1c
movq (%r12), %rsi
leaq 0xb8(%rsp), %rdi
callq 0xe5a0
leaq 0x20(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x9f0c
leaq 0xc0(%rsp), %rdi
callq 0x8ea0
leaq 0x10(%rsp), %rdi
callq 0x8ea0
leaq 0xb8(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r15, %rsi
callq 0x52f0
leaq 0xb8(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x5140
movq 0x20(%rsp), %rsi
addq $0x48, %rsi
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x1a802
movq (%r15), %rdi
callq 0x1b2e2
movslq 0x4(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x8f30
leaq 0x40(%rsp), %rdi
callq 0x8ea0
leaq 0x38(%rsp), %r12
leaq 0x48(%rsp), %rsi
movq %r12, %rdi
callq 0x1a7ac
movq (%r12), %r12
leaq 0x68(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x8f30
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0xf8(%rax)
leaq 0x70(%rsp), %rdi
callq 0x8ea0
movq 0x20(%rsp), %rsi
addq $0x48, %rsi
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x1a802
movq (%r15), %rdi
callq 0x1b2e2
movslq 0x4(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x10, %rdi
leaq 0x38(%rsp), %rsi
callq 0xb89e
leaq 0x60(%rsp), %rdi
callq 0x8ea0
leaq 0x58(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a83e
movq (%r15), %rdi
movl %ebx, %esi
callq 0x10e84
leaq 0x60(%rsp), %rdi
callq 0x8ea0
leaq 0x40(%rsp), %rdi
callq 0x8ea0
leaq 0x10(%rsp), %rdi
callq 0x8ea0
leaq 0xb8(%rsp), %rdi
callq 0x5100
leaq 0x28(%rsp), %rdi
callq 0x8ea0
movq 0x48(%rsp), %rdi
callq 0xb418
movq 0x18(%rsp), %rdi
movl %eax, %esi
callq 0x121d0
leaq 0x78(%rsp), %rdi
callq 0x5378
leaq 0x50(%rsp), %rdi
callq 0x8ea0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4
popq %rdi
callq 0x5120
movl $0x7, (%rax)
movq 0x18146(%rip), %rsi     # 0x2afa0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5310
pushq $0x4
popq %rdi
callq 0x5120
movl $0x6, (%rax)
movq 0x18127(%rip), %rsi     # 0x2afa0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5310
pushq $0xa
jmp 0x12e89
pushq $0x9
popq %rbx
pushq $0x4
popq %rdi
callq 0x5120
movl %ebx, (%rax)
movq 0x18105(%rip), %rsi     # 0x2afa0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5310
jmp 0x12ea7
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x8ea0
jmp 0x12eff
jmp 0x12eb8
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x12eca
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x8ea0
leaq 0x40(%rsp), %rdi
callq 0x8ea0
leaq 0x10(%rsp), %rdi
jmp 0x12ee8
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x8ea0
jmp 0x12ef2
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x5100
leaq 0x28(%rsp), %rdi
callq 0x8ea0
jmp 0x12f48
movq %rax, %rbx
jmp 0x12eff
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x12f04
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5378
jmp 0x12f48
jmp 0x12f40
jmp 0x12f33
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x12f57
movq %rax, %rbx
jmp 0x12f52
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5378
leaq 0x50(%rsp), %rdi
callq 0x8ea0
movq %rbx, %rdi
callq 0x5330