### ----------------------------------------------------
### -- Terminal::Tests
### -- Licenses: Artistic-2.0
### -- Authors: Geoffrey Broadwell
### -- File: lib/Terminal/Tests/App/FullTest.rakumod
### ----------------------------------------------------
### -- Chunk 2 of 2
 Pieces (Unicode 11.0)
sub show-xiangqi-pieces() {
    my @rows;
    @rows.push: (0x1FA60 .. 0x1FA66).map(&chr);
    @rows.push: (0x1FA67 .. 0x1FA6D).map(&chr);
    my $desc = q:to/DESC/;
        Two rows of xiangqi pieces (red and black) in text outline form;
        from left to right on each row:

          * general, mandarin, elephant, horse, chariot, cannon, soldier

        Pieces should not be cut off or unreadable.  Spacing should be even,
        with no extra-wide or extra-narrow gaps.
        DESC
    show('games', 'xiangqi', "Xiangqi", $desc, @rows);
}



#     @rows.push: < ▤ ▥ ▦ ▧ ▨ ▩ >;
#     @rows.push: < ֍ ֎ >;
# ⚕


### EMOJI TESTS

my constant %icons =
    # Deactivations
    dead      => '💀',
    petrified => '',
    sleeping  => '💤',
    paralyzed => '⌁',
    stunned   => '😵',
    surprised => '😲',

    # Mental states
    confused  => '⁈',
    charmed   => '😍',
    enraged   => '😠',
    calmed    => '😑',

    # Disablements
    blinded   => '▆',
    silenced  => '🤐',
    nauseated => '🤮',

    # Debuffs
    burning   => '🔥',
    freezing  => '❄',
    poisoned  => '🕱',
    infected  => '☣',
    bleeding  => '🌢',
    drained   => '-',

    # Buffs
    boosted   => '+',
    regen     => '⚕',
    protected => '⛨',
    hasted    => '🏃',
;

sub fixup($char, $mod, $expected-width = 0) {
    my $spacer = ' ' x max 0, $expected-width - duospace-width($char);
    $char ~ $mod ~ $spacer
}

sub emojify($char)        { fixup($char, "\x[FE0F]", 2) }
sub textify($char)        { fixup($char, "\x[FE0E]") }
sub toneify($char, $tone) { fixup($char, chr(0x1f3f9 + $tone), 2) }

my @faces = < stunned surprised charmed enraged calmed silenced nauseated >;

# XXXX: Reverse or RGB outlines?
sub show-facial-outlines() {
    my $row = @faces.map({ textify(%icons{$_}) });
    my $desc = qq:to/DESC/;
        A row of seven face emoji showing conditions, all in text/icon
        outline form; from left to right:

          * {@faces.join(', ')}
        DESC
    show('emoji', 'face-outlines', "Face Outlines", $desc, [$row]);
}

sub show-facial-expressions() {
    my $row = @faces.map({ emojify(%icons{$_}) });
    my $desc = qq:to/DESC/;
        A row of seven face emoji showing conditions, all with default
        (solid yellow) "skin" color; from left to right:

          * {@faces.join(', ')}
        DESC
    show('emoji', 'face-emoji', "Faces", $desc, [$row]);
}

#| Skin tones (Unicode 6.0 and Unicode 10.0 bases, Unicode 8.0 Fitzpatrick tones)
sub show-skin-tones() {
    my @people = < 👶 🧒 👦 👧 🧑 👨 👩 🧓 👴 👵 >;
    my @rows;
    for 2..6 -> $tone {
        @rows.push: @people.map({ toneify($_, $tone) });
    }
    my $desc = q:to/DESC/;
        Five rows of ten faces, ranging from light skin tone at the top to
        dark skin tone at the bottom.  Each row's faces are, left to right:

          * baby, child, boy, girl, adult, man, woman; older: adult, man, woman

        If you see yellow faces next to separate tone swatches, this rates as 1.
        DESC
    show('emoji', 'skin-tones', "Skin Tones", $desc, @rows);
}

sub show-equipment() {
    my @equip = < dagger shield bow >;
    my $row = @equip.map({ emojify(%icons{$_}) });
    my $desc = qq:to/DESC/;
        A row of equipment emoji; from left to right:

          * {@equip.join(', ')}
        DESC
    show('emoji', 'face-emoji', "Faces", $desc, [$row]);
}


### MAIN DRIVER

sub MAIN(Bool :$json) is export {
    # Intro/instructions
    show-intro;

    # Color tests
    show-basic-attributes;
    show-four-bit-color;
    show-eight-bit-color;
    show-greyscale-color;
    show-full-color;

    # Block and box-drawing tests
    show-simple-blocks;
    show-vertical-bar-graph-blocks;
    show-horizontal-bar-graph-blocks;

    show-simple-boxes;
    show-styled-boxes;
    show-complex-boxes;

    # Icon and symbol tests
    show-ascii-printables;
    show-latin1-symbols;
    show-cp1252-symbols;
    show-w1g-math-symbols;
    show-wgl4-symbols;
    show-mes2-math-symbols;

    show-number-forms;
    show-super-sub-digits;
    show-basic-icons;
    show-tone-bars;
    show-danger-icons;

    # Arrow tests
    show-small-arrows;
    show-double-arrows;
    show-heavy-arrows;

    # Game piece tests
    show-chess-pieces;
    show-misc-game-pieces;
    show-mahjong-tiles;
    show-domino-tiles;
    show-playing-cards;
    show-playing-card-trumps;
    show-xiangqi-pieces;

    # Emoji tests
    show-facial-outlines;
    show-facial-expressions;
    show-skin-tones;

    # Show results
    $json ?? print-json-results() !! show-answers;
}


