-
-
Save palikhov/2b3038c878554ee1798767124efe5f96 to your computer and use it in GitHub Desktop.
A quickie script to turn the monsters scraped with [this script](https://gist.github.com/tkfu/bc5dc2c6cee4d1e582a3d369c3077bb5) into cards you can use [here](https://crobi.github.io/rpg-cards/generator/generate.html)
This file contains hidden or 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
# Probably only works on Ruby 2.5.0 | |
require 'json' | |
def create_monster mon | |
cont = [] | |
cont.append("subtitle | #{mon['meta']}") | |
cont.append("rule") | |
cont.append("property | Armor class | #{mon['Armor Class']}") | |
cont.append("property | Hit points | #{mon['Hit Points']}") | |
cont.append("property | Speed | #{mon['Speed']}") | |
cont.append("rule") | |
cont.append("dndstats | #{mon['STR']} | #{mon['DEX']} | #{mon['CON']} | #{mon['INT']} | #{mon['WIS']} | #{mon['CHA']}") | |
cont.append("rule") | |
tidbits = ["Saving Throws","Skills","Damage Vulnerabilities","Damage Immunities","Damage Resistances","Senses","Condition Immunities","Languages","Challenge"] | |
tidbits.each do |tidbit| | |
cont.append("property | #{tidbit} | #{mon[tidbit]}") if mon.key? tidbit | |
end | |
sections = ["Traits","Actions","Reactions","Legendary Actions"] | |
sections.each do |section| | |
if mon.key? section | |
cont.append("section | #{section}") | |
cont.append("text | #{mon[section]}") | |
end | |
end | |
card = { | |
"title" => mon['name'], | |
"icon" => "imp-laugh", | |
"contents" => cont, | |
"background_image" => mon['img_url'] | |
} | |
card | |
end | |
monster_cards = [] | |
monsters = JSON.parse(File.open('beyond_monsters.json').read) | |
monsters.each do |mon| | |
monster_cards.push(create_monster(mon)) | |
end | |
File.open("beyond_monster_cards.json","w") {|f| f.write(monster_cards.to_json)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment