From dd5cf6dcdcd30d017d39f4c875ed44982231b8df Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Tue, 20 Dec 2022 19:20:42 -0600 Subject: [PATCH] Stub expanded stock class --- src/lib/data.rb | 2 +- src/lib/stock.rb | 48 ++++++++++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/lib/data.rb b/src/lib/data.rb index 713f783..c9a07d3 100644 --- a/src/lib/data.rb +++ b/src/lib/data.rb @@ -30,7 +30,7 @@ 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, s } + @data[:stock_objs] = @data[:stocks].map { |s| Stock.new s } end def verbose_merge(to, from) diff --git a/src/lib/stock.rb b/src/lib/stock.rb index 77d623c..0086c68 100644 --- a/src/lib/stock.rb +++ b/src/lib/stock.rb @@ -1,22 +1,34 @@ module Charred - # module Stock - class Stock - attr :key - attr :name + class Stock + @@default_stride = 6 - def initialize(key, name) - @key = key - @name = name - end - def as_json(options = {}) - { - "key" => key, - "name" => name - } - end - def to_json(*a) - as_json.to_json(*a) - end - # end + attr :key + attr :name + attr :stride + attr :common_traits + attr :settings + attr :starting_stats + + def initialize(key, name = key, stride = @@default_stride) + @key = key + @name = name + @stride = stride + @common_traits = [] + @settings = [] + @starting_stats = [] + end + def as_json(options = {}) + { + "key" => key, + "name" => name, + "stride" => stride, + "common_traits" => common_traits, + "settings" => settings, + "starting_stats" => starting_stats + } + end + def to_json(*a) + as_json.to_json(*a) + end end end