| 1 | # Copyright (c) 2026 Philipp Schafft | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | # ABSTRACT: Work with Gamebook data in TagDBs, container for exits | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | package Data::TagDB::Plugin::Gamebook::Exit; | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | ▶ | use v5.10; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | ▶ | use parent 'Data::Identifier::Interface::Simple'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | our $VERSION = v0.02; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | #@returns Data::TagDB::Tag | ||||||||||||||||||||
| 22 | 0 | ▶ | sub tag { | ||||||||||||||||||
|
Subroutine
tag: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 23 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | return $self->{tag}; | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | #@returns Data::TagDB | ||||||||||||||||||||
| 32 | 0 | ▶ | sub db { | ||||||||||||||||||
|
Subroutine
db: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 33 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | return $self->{db} //= $self->{tag}->db; | ||||||||||||||||||
|
Condition0%0/3
$self->{"db"} //= $self->{"tag"}->db
MC/DC0%0/2
$self->{"db"} //= $self->{"tag"}->db
$self->{"db"}
$self->{"tag"}->db
Truth table0%0/3
A //= B
A= $self->{"db"}B= $self->{"tag"}->db
| |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | sub label { | ||||||||||||||||||
|
Subroutine
label: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 42 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | return $self->{label} //= $self->{tag}->get('Data::TagDB::Plugin::Gamebook#title') // croak 'No label found'; | ||||||||||||||||||
|
Condition0%0/4
$self->{"label"} //= $self->{"tag"}->get("Data::TagDB::Plugin::Gamebook#title") // croak("No label found")
$self->{"tag"}->get("Data::TagDB::Plugin::Gamebook#title") // croak("No label found")
MC/DC0%0/1
$self->{"label"} //= $self->{"tag"}->get("Data::TagDB::Plugin::Gamebook#title") // croak("No label found")
$self->{"label"}
Truth table0%0/2
A
A= $self->{"label"}
| |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | #@returns Data::TagDB::Tag | ||||||||||||||||||||
| 51 | 0 | ▶ | sub direction { | ||||||||||||||||||
|
Subroutine
direction: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 52 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | return $self->{direction} if defined $self->{direction}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | { | ||||||||||||||||||||
| 59 | 0 | my Data::TagDB $db = $self->db; | |||||||||||||||||||
| 60 | 0 | my Data::TagDB::Relation $link = $db->relation(tag => $self->{tag}, relation => $db->tag_by_id(uuid => '64df20b4-3a22-4054-881c-e750cdabf850'))->one; | |||||||||||||||||||
| 61 | 0 | ▶ | return $self->{direction} //= $link->related; | ||||||||||||||||||
|
Condition0%0/3
$self->{"direction"} //= $link->related
MC/DC0%0/2
$self->{"direction"} //= $link->related
$self->{"direction"}
$link->related
Truth table0%0/3
A //= B
A= $self->{"direction"}B= $link->related
| |||||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | #@returns Data::TagDB::Tag | ||||||||||||||||||||
| 67 | 0 | ▶ | sub target_tag { | ||||||||||||||||||
|
Subroutine
target_tag: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | return $self->{target_tag} if defined $self->{target_tag}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | { | ||||||||||||||||||||
| 75 | 0 | my Data::TagDB $db = $self->db; | |||||||||||||||||||
| 76 | 0 | my Data::TagDB::Relation $link = $db->relation(tag => $self->{tag}, relation => $db->tag_by_id(uuid => '9bfe73f4-c3ca-464c-8e46-548931aa1571'))->one; | |||||||||||||||||||
| 77 | 0 | ▶ | return $self->{target_tag} //= $link->related; | ||||||||||||||||||
|
Condition0%0/3
$self->{"target_tag"} //= $link->related
MC/DC0%0/2
$self->{"target_tag"} //= $link->related
$self->{"target_tag"}
$link->related
Truth table0%0/3
A //= B
A= $self->{"target_tag"}B= $link->related
| |||||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | # ---- Private helpers ---- | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | ▶ | sub _new { | ||||||||||||||||||
|
Subroutine
_new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 84 | 0 | my ($pkg, $tag, @opts) = @_; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | return bless {tag => $tag}, $pkg; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | # Data::TagDB::Tag claims to be a Data::Identifier::Interface::Simple, so we just forward most things: | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | ▶ | sub ise { | ||||||||||||||||||
|
Subroutine
ise: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 94 | 0 | my ($self, @args) = @_; | |||||||||||||||||||
| 95 | 0 | return $self->{tag}->ise(@args); | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | 0 | ▶ | sub as { | ||||||||||||||||||
|
Subroutine
as: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 98 | 0 | my ($self, @args) = @_; | |||||||||||||||||||
| 99 | 0 | return $self->{tag}->as(@args); | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | 0 | ▶ | sub displayname { | ||||||||||||||||||
|
Subroutine
displayname: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 102 | 0 | my ($self, @args) = @_; | |||||||||||||||||||
| 103 | 0 | ▶ | return $self->label unless scalar @args; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | 0 | return $self->{tag}->displayname(@args); | |||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 1 | 1; | |||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | __END__ | ||||||||||||||||||||