NAME

Game::Schnapsen::Terminal - the whole of the input and output

VERSION

Version 0.01

SYNOPSIS

Game::Schnapsen::Terminal->new(
    variant => 'schnapsen',
    mode    => 'bot',
    level   => 2,
    seat    => 'p1',
)->play(seed => $thirty_two_bytes);

# and with no terminal at all, which is how it is tested
my $t = Game::Schnapsen::Terminal->new(
    variant => 'sixtysix', mode => 'watch',
    in => $read_handle, out => $write_handle, ascii => 1, colour => 0);

DESCRIPTION

Nothing else in this distribution prints, reads a handle, or calls rand. This is the only module that does any of the three.

in and out are attributes rather than STDIN and STDOUT, which is what makes the whole of it testable with no terminal present. A version that reached for the real handles would be exercised only by a person sitting in front of it.

The score line runs the way its game runs

Sixty-Six counts up to seven and Schnapsen counts down to zero, so the line says "Game points" for one and "Game points left" for the other, and names the direction. Showing both as a count up would be the first place the two games started to blur into one, and a player reading a Schnapsen scoreboard expects to watch a number fall.

What a player types

A card name plays it: KH, TH, and 10H for the same card. Then m H for a marriage in hearts, x to exchange for the trump card, c to close the talon, out to claim 66, d to draw. ? lists whatever is legal now.

Only what is legal is accepted, because every option comes from $game->legal rather than from a list kept here. That means a rule added to the engine reaches the prompt without this file being touched, and a rule removed cannot be played from it.

Claiming is typed out in full

out, claim or 66, and never a single letter. A false claim loses the deal, and the prompt shows the player their own card points, so the only way to make one is a slip. It should not be one keystroke away from something else.

METHODS

new

Takes variant, mode (bot, hotseat or watch), level, seat, in, out, ascii and colour.

play

$terminal->play(seed => $seed, variant => ..., dealer => ...);

Runs a match to the end and returns the Game::Schnapsen, or an error if it could not be built. Without a seed it makes one.

game, out, in, mode, level, seat, variant, ascii, colour

What it was built with. game is set by play.

render, show, table_lines, hand_lines, score_line

The screen, as a list of lines and then printed. Split up so a test can look at one part without a terminal.

card_art, card_back, fan, pretty

A card as seven rows, a face-down card, a row of them, and a card as two characters for a sentence.

ask, say_to, paint

One line in, one line out, and colour if the output is a terminal and NO_COLOR is unset.

describe, announce, deal_result_line, result_line

What just happened, in words, from the point of view of the seat being played.

human_move, bot_move, is_human, options, card_named

Where a move comes from. card_named accepts 10H as well as TH, because the card itself says 10.

other

The other seat.

SEE ALSO

Game::Schnapsen, Game::Schnapsen::Bot.

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.