On the Subject of KTHearts

“I come not, friends, to steal away your hearts...” - Julius Caesar, Act III, scene ii
“No robux for you” - Speakingevil, Twitch Plays KTANE, #bug-reports

This module imitates a match of Hearts. To solve the module, finish a match without losing it. In case of losing, a new match will generate and no strikes will be issued.

Rules

Hearts is a trick-taking card game for four players, in which the first player to reach 100 or more points loses the game.

Dealing and Passing Cards

Each player is dealt 13 cards. At the start of the first round, every player passes three of their cards to the player on their left. At the start of the second round, cards are passed to the player on the right; at the start of the third, to the player sitting opposite. The fourth round is played without passing any cards. This cycle repeats from the fifth round onwards: cards are passed to the player on the left, then to the player on the right, then to the player opposite, followed by a round with no passing.

Playing Tricks

The player holding the two of clubs must lead it to begin the first trick. For subsequent tricks, the lead is taken by the player who won the previous trick.

The first card played in a trick establishes the suit that all other players must follow, if they are able to do so; if a player does not have a card of that suit, they may discard any card from their hand. At the beginning of a round, a trick cannot be led with a heart or the queen of spades, provided the player has other cards available. Once a player is unable to follow suit and plays a heart, the hearts are considered “broken”, and subsequent tricks may be led with any card.

The trick is won by the player who played the highest-ranking card of the suit that was led.

Scoring

A player receives 1 point for every heart taken in their tricks, and 13 points for taking the queen of spades. A player who takes all the hearts and the queen of spades has “shot the moon”; they receive no points, while each of their opponents receives 26 points. A player who takes every single trick has “shot the sun”; they receive no points, while each of their opponents receives 52 points.