Skip to content

Installation

tilttek/reading-quests
composer require tilttek/reading-quests

The package needs PHP 8.5 or later, with the mbstring extension that phil/reading-progress reads text with. It depends on phil/reading-progress, which measures how far a reader got; tilttek/activity, the journal it records the reading in; tilttek/quests, whose steps it builds; phil/resource, the reference of a reader and a book; and psr/clock, the clock a yearly goal is read against.

A first reading quest

use Symfony\Component\Clock\NativeClock;
use Tilttek\Activity\Journal;
use Tilttek\Activity\Log\InMemoryActivityLog;
use Tilttek\ReadingQuests\InMemoryBookShelf;
use Tilttek\ReadingQuests\ReadingActivities;
use Tilttek\ReadingQuests\ReadingMeasure;
use Tilttek\ReadingQuests\ReadingRecorder;

$journal = new Journal(new InMemoryActivityLog(), new NativeClock());
$shelf = InMemoryBookShelf::fromArray([
    'core-rulebook' => ['pages' => 320, 'facts' => ['system' => 'dnd5e', 'supplement' => false]],
]);
$recorder = new ReadingRecorder($journal, $shelf, new ReadingActivities(ReadingMeasure::pages()));

$result = $recorder->record($before, $document, 'member:44', $position, $clock->now());
$row->progress = $result->update->progress->toString();

The application keeps the documents, the stored progress and the goals; the library keeps nothing. The quests read the journal through tilttek/quests, as Quests shows.