function [hand, table] = makeplay(hand, table, card)
%  MAKEPLAY  Play the given card and update the current game state.
%  ENCODE(HAND, TABLE, CARD), where HAND is the player's hand, TABLE
%  represents the current table configuration of Seven, and CARD is the
%  card to play, returns the updated hand and table after the card is played.


%
%  If the card is in the hand, then remove the card from the hand and insert
%  it into the table.
%
if ~isempty(hand)
    index = find(hand == card);
    if (index > 0)
        hand(index) = [];

        suit = floor((card - 1) / 13) + 1;
        value = mod(card - 1, 13) + 1;

        if (value == 7)
            table(suit, :) = [7 7];
        elseif (value > 7)
            table(suit, 2) = value;
        else
            table(suit, 1) = value;
        end
    end
end
