Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tadeusz Sośnierz
committed
Mar 19, 2015
0 parents
commit 92d0e1c
Showing
6 changed files
with
3,834 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
spells.json: parse-spells.pl spelllist.txt spelldescs.txt | ||
perl6 parse-spells.pl | json_pp -json_opt pretty,utf8,canonical > spells.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
This is a hopefully complete and mostly correct database of D&D 5e spells in a computer | ||
readable format. | ||
|
||
It may be a bit off in some places, as it was created by copypasting the list from the | ||
Basic Rules PDF, cleaning it up a bit manually and lazily parsing it line-by-line. | ||
The result is in spells.json, if you wish to generate it yourself you'll need a Perl 6 | ||
compiler with JSON::Tiny installed. | ||
|
||
Please report any issues and discrepancies with the original list (I know that tables either | ||
aren't there at all or are completely wrong), and I'll try to fix them. | ||
|
||
I'm not sure if Basic Rules license allows that (not too good at lawyerspeak), but if you | ||
Wizards are reading this, I'll happily comply to any DMCA takedown or whatever. | ||
|
||
Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use v6; | ||
use JSON::Tiny; | ||
|
||
my @list = 'spelllist.txt'.IO.lines; | ||
|
||
my @buf; | ||
my %spells; | ||
|
||
my @descs = 'spelldescs.txt'.IO.lines; | ||
|
||
sub parse-type($line) { | ||
my @words = $line.words; | ||
if @words[0] ~~ /^(\d)/ { | ||
return [+~$0, @words[1].tc] | ||
} else { | ||
return [0, @words[0].tc] | ||
} | ||
} | ||
|
||
sub parse(@buf) { | ||
my %props; | ||
my $type = parse-type(@buf.shift); | ||
%props<level> = $type[0]; | ||
%props<school> = $type[1]; | ||
%props<casting_time> = @buf.shift.subst(/^'Casting Time: '/, ''); | ||
%props<range> = @buf.shift.subst(/^'Range: '/, ''); | ||
%props<components> = @buf.shift.subst(/^'Components: '/, ''); | ||
%props<duration> = @buf.shift.subst(/^'Duration: '/, ''); | ||
%props<description> = @buf.join(" "); | ||
return %props; | ||
} | ||
|
||
my $current = @list.shift; | ||
for @descs -> $descline { | ||
if $descline eq (@list[0] // '') { | ||
if not %spells { | ||
@buf.shift; # fix for Acid Splash | ||
} | ||
%spells{$current} = parse(@buf); | ||
$current = @list.shift; | ||
@buf = (); | ||
} else { | ||
@buf.push: $descline | ||
} | ||
} | ||
%spells{$current} = parse(@buf); | ||
|
||
say to-json(%spells); |
Oops, something went wrong.