NAME

Game::Terminal::Kit::Log - what just happened, kept for the next frame

VERSION

Version 0.05

SYNOPSIS

use Game::Terminal::Kit::Log;

my $log = Game::Terminal::Kit::Log->new(keep => 2);

$log->record('Black sows from E: 2 in F, 1 in a, 1 in b.', 'Black takes 3 from b.');
$log->note('That house is empty.');

my $picker = Game::Terminal::Kit::Picker->new(items => \@moves, log => $log);

DESCRIPTION

A game says what a move did when the move is played, and a moment later it is the player's turn and the picker redraws the whole screen. Said once and then cleared, the opponent's move was on screen for no time at all, and the player is choosing a reply to something they never read.

So what happened is not printed, it is kept, and whatever owns the screen draws it in its own frame, every frame. A Game::Terminal::Kit::Picker, a Game::Terminal::Kit::Choose and a Game::Terminal::Kit::Form each take a log and do.

There are two kinds of line. What was recorded is a move: it stays until enough later moves push it out. What was noted is a remark, such as a key that does nothing or a value that was refused: it is drawn in one frame and then dropped.

ATTRIBUTES

keep

How many records are kept, 4 by default. One per player is a good number.

recent

notes

The records, oldest first, each an array reference of its lines; and the notes waiting to be shown.

METHODS

Each but "lines" returns the log.

record

$log->record('Black sows from E.', 'Black takes 3.');

One thing that happened, in as many lines as it takes. The oldest record is dropped when there are more than "keep". Write it in the past tense: it will be read after the fact.

note

$log->note('That key does nothing here.');

A line for the next frame only.

lines

Everything to draw: the records, oldest first, then the notes.

shown

The frame has been drawn; the notes are dropped and the records stay.

forget

Drops everything, for a new game.

SEE ALSO

Game::Terminal::Kit, Game::Terminal::Kit::Picker.

AUTHOR

LNATION, <email at lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)