// File: Thomas1995[P]Rentz/src/table.cpp
// Function: Table::PlayerAction(Connection&)
void Table::PlayerAction(Connection &connection) {
  // send connection the cards that were played and get his played card
  connection.sendCards(cardStack);

  Card playedCard = connection.getCardChoice();

  std::cout << connection.getName() << " played " << playedCard << "\n";

  // check if the played card can be played
  if(cardStack.size() > 1) {
    if(!playedCard.isSameSuite(cardStack.front())) {
      auto cards = connection.getHand();
      for(auto c : cards)
        require(!cardStack.front().isSameSuite(c),
            connection.getName() + " had chosen a card of a different suite.\n");
    }
  }

  // push the card in play
  cardStack.push_back(playedCard);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rsi
callq 0xb4a0
movq -0x10(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0xb1b0
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0xb840
movq -0xd0(%rbp), %rsi
movq 0x111ce(%rip), %rdi     # 0x20fc8
callq 0x32b0
movq %rax, -0xc8(%rbp)
jmp 0xfe08
movq -0xc8(%rbp), %rdi
leaq 0x6839(%rip), %rsi      # 0x1664f
callq 0x32d0
movq %rax, -0xe0(%rbp)
jmp 0xfe24
movq -0xe0(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xe060
movq %rax, -0xe8(%rbp)
jmp 0xfe3d
movq -0xe8(%rbp), %rdi
leaq 0x6758(%rip), %rsi      # 0x165a3
callq 0x32d0
jmp 0xfe52
leaq -0x38(%rbp), %rdi
callq 0x31c0
movq -0xd8(%rbp), %rdi
addq $0x28, %rdi
callq 0x8e10
cmpq $0x1, %rax
jbe 0x10006
movq -0xd8(%rbp), %rdi
addq $0x28, %rdi
callq 0x10620
movq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0xe010
testb $0x1, %al
jne 0x10004
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0xb880
leaq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x58b0
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x58e0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5910
testb $0x1, %al
jne 0xfede
jmp 0xffee
leaq -0x70(%rbp), %rdi
callq 0x5950
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0xdd80
jmp 0xfef5
movq -0xd8(%rbp), %rdi
addq $0x28, %rdi
callq 0x10620
movq %rax, %rdi
leaq -0x80(%rbp), %rsi
callq 0xe010
movb %al, -0xe9(%rbp)
jmp 0xff19
movb -0xe9(%rbp), %al
xorb $0x1, %al
movb %al, -0xea(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0xb840
jmp 0xff39
leaq 0x6718(%rip), %rdx      # 0x16658
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x10520
jmp 0xff55
movb -0xea(%rbp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq -0xa0(%rbp), %rsi
callq 0x14a60
jmp 0xff6f
leaq -0xa0(%rbp), %rdi
callq 0x31c0
leaq -0xc0(%rbp), %rdi
callq 0x31c0
leaq -0x70(%rbp), %rdi
callq 0x5970
jmp 0xfec8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31c0
jmp 0x10023
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xfff9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xffe0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x31c0
leaq -0xc0(%rbp), %rdi
callq 0x31c0
jmp 0xfff9
leaq -0x60(%rbp), %rdi
callq 0x9670
jmp 0x10004
leaq -0x60(%rbp), %rdi
callq 0x9670
jmp 0x10023
jmp 0x10006
movq -0xd8(%rbp), %rdi
addq $0x28, %rdi
leaq -0x18(%rbp), %rsi
callq 0x10650
addq $0xf0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x34d0
nopl (%rax)