Load troll data

Daniel Asher Resnick 2 years ago
parent aae021437a
commit 0e321daa9f
  1. 99
      src/data/troll/stock.json
  2. 2
      src/lib/data.rb
  3. 5
      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 def initialize
@data = {} @data = {}
@data[:stock_objs] = {}
puts 'loading gold' puts 'loading gold'
load_gold(@data) load_gold(@data)
@ -30,7 +31,6 @@ module Charred
@data[:traits] = @data[:traits].sort.to_h @data[:traits] = @data[:traits].sort.to_h
@data[:skills] = @data[:skills].sort.to_h @data[:skills] = @data[:skills].sort.to_h
@data[:stock_objs] = @data[:stocks].map { |s| Stock.new s }
end end
def verbose_merge(to, from) def verbose_merge(to, from)

@ -1,4 +1,5 @@
require 'json' require 'json'
require_relative '../stock'
module Charred module Charred
module Troll module Troll
@ -24,6 +25,10 @@ module Charred
file = File.read("data/troll/starting_stat_pts.json") file = File.read("data/troll/starting_stat_pts.json")
stats = JSON.parse(file) stats = JSON.parse(file)
data[:stat_pts]['troll'] = stats 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
end end

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

Loading…
Cancel
Save