// File: 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
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rcx, -0x300(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x2f8(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x2a770
movq -0x2f0(%rbp), %rdi
callq 0x12e10
movq %rax, %rdi
callq 0x278e0
movq %rax, -0x2e8(%rbp)
jmp 0x2ba98
movq -0x2e8(%rbp), %rdi
callq 0x1d510
movq %rax, -0x308(%rbp)
movslq -0xc(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x12e30
movq -0x310(%rbp), %rcx
movq -0x308(%rbp), %rax
cmpq %rcx, %rax
jae 0x2bb0f
movl $0x4, %edi
callq 0x6160
movq %rax, %rdi
movl $0x7, (%rdi)
movq 0x284ac(%rip), %rsi     # 0x53f98
xorl %eax, %eax
movl %eax, %edx
callq 0x6430
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x12e30
jmp 0x2c1f3
movq -0x2f8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0x2a770
movq -0x320(%rbp), %rdi
callq 0x12e10
movq %rax, %rdi
callq 0x278e0
movq %rax, -0x318(%rbp)
jmp 0x2bb43
movq -0x318(%rbp), %rdi
movl -0xc(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x287a0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x1a1f0
leaq -0x58(%rbp), %rdi
callq 0x12e30
movq -0x2f8(%rbp), %rdi
callq 0x2a620
movq -0x330(%rbp), %rdi
movl %eax, -0x328(%rbp)
callq 0x15c20
movq %rax, %rdi
callq 0x19c80
movl %eax, -0x324(%rbp)
jmp 0x2bba1
movl -0x328(%rbp), %eax
movl -0x324(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2bc04
movl $0x4, %edi
callq 0x6160
movq %rax, %rdi
movl $0x6, (%rdi)
movq 0x283cd(%rip), %rsi     # 0x53f98
xorl %eax, %eax
movl %eax, %edx
callq 0x6430
jmp 0x2c1fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x12e30
jmp 0x2c1f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2c1df
leaq -0x48(%rbp), %rdi
callq 0x15c20
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x19c20
jmp 0x2bc1b
leaq 0x14c28(%rip), %rsi     # 0x4084a
leaq -0x78(%rbp), %rdi
callq 0x12920
movb %al, -0x331(%rbp)
jmp 0x2bc33
movb -0x331(%rbp), %al
testb $0x1, %al
jne 0x2bc42
jmp 0x2bd2a
leaq -0x48(%rbp), %rdi
callq 0x15c20
movq -0x300(%rbp), %rsi
movq %rax, -0x340(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x338(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6100
jmp 0x2bc70
movl -0x338(%rbp), %esi
movq -0x340(%rbp), %rdi
movq (%rdi), %rax
movq 0x48(%rax), %rax
leaq -0x98(%rbp), %rdx
callq *%rax
jmp 0x2bc8f
leaq -0x98(%rbp), %rdi
callq 0x64c8
movq -0x2f8(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0x2a770
movq -0x348(%rbp), %rdi
callq 0x12e10
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x27990
jmp 0x2bcce
leaq -0xa8(%rbp), %rdi
callq 0x12e30
jmp 0x2c195
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2c1d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x64c8
jmp 0x2c1d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x12e30
jmp 0x2c1d6
leaq 0x15aa3(%rip), %rsi     # 0x417d4
leaq -0x78(%rbp), %rdi
callq 0x12920
movb %al, -0x349(%rbp)
jmp 0x2bd42
movb -0x349(%rbp), %al
testb $0x1, %al
jne 0x2bd51
jmp 0x2c16e
movq -0x300(%rbp), %rdi
leaq 0x14a95(%rip), %rsi     # 0x407f4
callq 0x12920
movb %al, -0x34a(%rbp)
jmp 0x2bd6c
movb -0x34a(%rbp), %al
testb $0x1, %al
jne 0x2bd78
jmp 0x2bda0
movl $0x4, %edi
callq 0x6160
movq %rax, %rdi
movl $0x9, (%rdi)
movq 0x28206(%rip), %rsi     # 0x53f98
xorl %eax, %eax
movl %eax, %edx
callq 0x6430
jmp 0x2c1fc
leaq -0xb8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x15c60
cmpl $0x1, -0x10(%rbp)
jne 0x2be3e
movq -0x2f8(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x2a670
movq -0x358(%rbp), %rdi
callq 0x12a20
movq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x22940
jmp 0x2bdf1
leaq -0xb8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x15c80
leaq -0xc8(%rbp), %rdi
callq 0x12a00
leaq -0xd8(%rbp), %rdi
callq 0x12a70
jmp 0x2bebf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x12a70
jmp 0x2c160
movq -0x2f8(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0x2a670
movq -0x360(%rbp), %rdi
callq 0x12a20
movq %rax, %rsi
leaq -0xe8(%rbp), %rdi
callq 0x22970
jmp 0x2be75
leaq -0xb8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x15c80
leaq -0xe8(%rbp), %rdi
callq 0x12a00
leaq -0xf8(%rbp), %rdi
callq 0x12a70
jmp 0x2bebf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x12a70
jmp 0x2c160
movq -0x300(%rbp), %rsi
leaq -0x280(%rbp), %rdi
movl $0x8, %edx
callq 0x6410
jmp 0x2bed9
leaq -0x280(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x61a0
jmp 0x2beee
leaq -0xb8(%rbp), %rdi
callq 0x12980
movq %rax, %rsi
leaq -0x2a0(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x2a6b0
movq -0x370(%rbp), %rdi
callq 0x12af0
movq %rax, %rdi
callq 0x3d220
movq %rax, -0x368(%rbp)
jmp 0x2bf2d
movq -0x368(%rbp), %rdi
movl -0xfc(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x12c80
movq %rax, %rsi
leaq -0x290(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x12c10
leaq -0x2a0(%rbp), %rdi
callq 0x12b30
leaq -0x2b0(%rbp), %rdi
movq %rdi, -0x390(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x3ad20
movq -0x390(%rbp), %rdi
callq 0x12d30
movq -0x388(%rbp), %rsi
movq %rax, -0x380(%rbp)
leaq -0x2c0(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x12c10
movq -0x380(%rbp), %rdi
movq -0x378(%rbp), %rsi
movq (%rdi), %rax
movq 0xf8(%rax), %rax
callq *%rax
jmp 0x2bfc6
leaq -0x2c0(%rbp), %rdi
callq 0x12d50
leaq -0xb8(%rbp), %rdi
callq 0x12980
movq %rax, %rsi
leaq -0x2d0(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x2a6b0
movq -0x3a0(%rbp), %rdi
callq 0x12af0
movq %rax, %rdi
callq 0x3d220
movq %rax, -0x398(%rbp)
jmp 0x2c011
movq -0x398(%rbp), %rdi
movl -0xfc(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x12c80
movq %rax, %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x1a4f0
leaq -0x2d0(%rbp), %rdi
callq 0x12b30
movq -0x2f8(%rbp), %rsi
leaq -0x2e0(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x2a770
movq -0x3a8(%rbp), %rdi
callq 0x12e10
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x27990
jmp 0x2c076
leaq -0x2e0(%rbp), %rdi
callq 0x12e30
leaq -0x2b0(%rbp), %rdi
callq 0x12d50
leaq -0x290(%rbp), %rdi
callq 0x12d50
leaq -0x280(%rbp), %rdi
callq 0x6150
leaq -0xb8(%rbp), %rdi
callq 0x12a00
jmp 0x2c193
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2c160
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2c154
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x12b30
jmp 0x2c154
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x12d50
jmp 0x2c13c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2d0(%rbp), %rdi
callq 0x12b30
jmp 0x2c13c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x12e30
leaq -0x2b0(%rbp), %rdi
callq 0x12d50
leaq -0x290(%rbp), %rdi
callq 0x12d50
leaq -0x280(%rbp), %rdi
callq 0x6150
leaq -0xb8(%rbp), %rdi
callq 0x12a00
jmp 0x2c1d6
movl $0x4, %edi
callq 0x6160
movq %rax, %rdi
movl $0xa, (%rdi)
movq 0x27e10(%rip), %rsi     # 0x53f98
xorl %eax, %eax
movl %eax, %edx
callq 0x6430
jmp 0x2c1fc
jmp 0x2c195
leaq -0x48(%rbp), %rdi
callq 0x15c20
movq %rax, %rdi
callq 0x19c80
movl %eax, -0x3ac(%rbp)
jmp 0x2c1ae
movl -0x3ac(%rbp), %esi
movq -0x2f8(%rbp), %rdi
callq 0x2a7c0
jmp 0x2c1c2
leaq -0x78(%rbp), %rdi
callq 0x64c8
leaq -0x48(%rbp), %rdi
callq 0x15c40
jmp 0x2c1ea
leaq -0x78(%rbp), %rdi
callq 0x64c8
leaq -0x48(%rbp), %rdi
callq 0x15c40
jmp 0x2c1f3
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x6460
nopl (%rax)