view spellnames.pl @ 374:10d030b85117 misc tip

Switch Convent map to SVG version, add link to PNG render to the caption.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 01 Mar 2024 10:02:38 +0200
parents 23d445908f41
children
line wrap: on
line source

#!/usr/bin/perl -w
use strict;

# Define the various spell chant prefixes here, we need them
# for matching the spell cast lines themselves.
my @spellchants = (
"claps its hands and says",
"claps his hands and whispers",
"fills up his cheeks with air and exhales",
"booms in sinister voice",
"throws a pinch of magic dust in air and chants",
"rolls her eyes wildly and exclaims",
"rolls its eyes frantically and states",
"utters the magic words",
"spreads her fingers and whispers",
"waves its index finger while uttering",
"points an accusing finger and cries",
"gets an evil gleam in its eyes and chants",
"flaps arms and utters the magic words",
"flaps his arms and utters the magic words",
"taps its foot three times and utters the words",
"is surrounded by blue waves as you hear the words:",
"closes his eyes and with a dry, dark voice entones",
"shakes with firey rage and yells",
"traces fiery demonic night runes in the air",
"weaves a mystic matrix with glowing red lines in arcane ways and chants",
#"",
);

### Convert spellchants array to regexp
my $spellregexps = join("|", map { s/ (his|its|her) / ... /g; $_ } @spellchants);

my $sp_words = "";
my $sp_mob = "";
my $sp_flag = 0;
my $line = 0;
my %spells = ();

while (defined(my $s = <STDIN>)) {
  $line++;
  chomp($s);
  if ($s =~ /^([A-Za-z][A-Za-z\ -]+?)\ ($spellregexps)\ '(.+)'$/o) {
    $sp_mob = $1;
    $sp_words = $3;
    $sp_flag = 1;
    $spells{$sp_words} = "#$line ($sp_mob): ";
  }
  elsif ($s =~ /^([A-Za-z][A-Za-z\ -]+?) hesitates as (he|she|it) casts (.+?)\.$/o) {
    my $sp_name = $3;
    if ($sp_flag && $1 eq $sp_mob && $sp_words =~ /^[^\(].+[^\)]$/) {
      $spells{$sp_words} = $sp_name;
      $sp_flag = 0;
    }
  }
  else
  {
    if ($sp_flag) {
      $spells{$sp_words} .= $s;
    }
    $sp_flag = 0;
  }
}


foreach my $words (sort { $a cmp $b } keys %spells) {
  printf "%-25s | %s\n", $words, $spells{$words};
}