Load troll data

pull/8/head
Daniel Asher Resnick 2 years ago
parent cf351b0c24
commit 8ec40eba13
  1. 99
      src/data/troll/stock.json
  2. 2
      src/lib/data.rb
  3. 7
      src/lib/data/troll.rb
  4. 17
      src/lib/stock.rb

@ -0,0 +1,99 @@
{
"key": "troll",
"name": "Troll",
"stride": 7,
"common_traits": [
"Black Nails",
"Fangs",
"Night Blooded",
"Night Eyed (Troll)",
"Massive Stature (Troll)",
"Stone's Age",
"Tough (Troll)",
"Troll Skin",
"Voracious Carnivore"
],
"starting_stats":
[
{
"range": [
1,
5
],
"m": 3,
"p": 11
},
{
"range": [
6,
12
],
"m": 4,
"p": 14
},
{
"range": [
13,
19
],
"m": 4,
"p": 17
},
{
"range": [
20,
27
],
"m": 4,
"p": 19
},
{
"range": [
28,
57
],
"m": 4,
"p": 20
},
{
"range": [
58,
80
],
"m": 4,
"p": 19
},
{
"range": [
81,
124
],
"m": 4,
"p": 18
},
{
"range": [
125,
213
],
"m": 5,
"p": 17
},
{
"range": [
214,
390
],
"m": 5,
"p": 16
},
{
"range": [
391,
712
],
"m": 6,
"p": 15
}
]
}

@ -15,6 +15,7 @@ module Charred
def initialize
@data = {}
@data[:stock_objs] = {}
puts 'loading gold'
load_gold(@data)
@ -30,7 +31,6 @@ module Charred
@data[:traits] = @data[:traits].sort.to_h
@data[:skills] = @data[:skills].sort.to_h
@data[:stock_objs] = @data[:stocks].map { |s| Stock.new s }
end
def verbose_merge(to, from)

@ -1,4 +1,5 @@
require 'json'
require_relative '../stock'
module Charred
module Troll
@ -24,6 +25,10 @@ module Charred
file = File.read("data/troll/starting_stat_pts.json")
stats = JSON.parse(file)
data[:stat_pts]['troll'] = stats
file = File.read("data/troll/stock.json")
stock = JSON.parse(file)
data[:stock_objs]['troll'] = Stock.new(stock)
end
end
end
end

@ -1,6 +1,6 @@
module Charred
class Stock
@@default_stride = 6
@@default_stride = 7
attr :key
attr :name
@ -9,14 +9,15 @@ module Charred
attr :settings
attr :starting_stats
def initialize(key, name = key, stride = @@default_stride)
@key = key
@name = name
@stride = stride
@common_traits = []
@settings = []
@starting_stats = []
def initialize(h)
@key = h["key"]
@name = h["name"]
@stride = h["stride"] || @@default_stride
@common_traits = h["common_traits"]
@settings = h["settings"]
@starting_stats = h["starting_stats"]
end
def as_json(options = {})
{
"key" => key,

Loading…
Cancel
Save