NAME

Game::Schnapsen::Trick - who wins a trick, and what may answer a lead

VERSION

Version 0.01

SYNOPSIS

use Game::Schnapsen::Trick qw(winner_of legal_follows);

winner_of($lead, $follow, 'H');    # the winning card id

my $can = legal_follows($hand, $lead, 'H', 2);

DESCRIPTION

Both published rulesets give a deal two phases with opposite rules, and the two games agree about every word of this module. Nothing here takes a variant.

Phase 1, while the talon is open

There is no requirement to follow suit and none to try to win the trick. Any card, always.

Phase 2, once the talon is exhausted or closed

Players must follow suit and, subject to that, win the trick if possible. The second player must, in this order:

1. play a higher card of the suit led, if holding one;
2. otherwise a lower card of the suit led;
3. otherwise a trump;
4. otherwise anything.

That is a strict cascade and not a list of preferences. legal_follows returns exactly one of those bands and never a union of them. A version returning "anything in the suit, or a trump, or anything" would let every game a bot plays run to the end looking correct, and be wrong only in the positions where the rule decides anything.

A lead that is itself a trump makes the first two bands and the third the same cards, so the third is unreachable and needs no special case.

Winning

Trump beats non-trump. Otherwise the higher card of the suit led wins, and a card of neither the led suit nor trump cannot win.

There are no ties to break. Neither pack holds a duplicate, so two cards in a trick are never equal and the comparison is a strict one.

FUNCTIONS

Nothing is exported by default.

winner_of

winner_of($lead, $follow, $trump);

The id of the winning card. The caller knows which seat played which.

value_of

The card points in a trick, which go to whoever took it.

follow_band

follow_band($hand, $lead, $trump, $phase);

Which rule applies: beat, follow, trump or free. Exposed because a consumer explaining a refusal to a player wants to say which of the four it was, and because it is the part worth testing directly.

legal_follows($hand, $lead, $trump, $phase);

The cards that may answer this lead, as an arrayref, in the hand's own order.

SEE ALSO

Game::Schnapsen::Deal, Game::Schnapsen::Card.

AUTHOR

LNATION, <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under the Artistic License 2.0.