Stub expanded stock class

Daniel Asher Resnick 2 years ago
parent ce4c372290
commit dd5cf6dcdc
  1. 2
      src/lib/data.rb
  2. 20
      src/lib/stock.rb

@ -30,7 +30,7 @@ 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, s } @data[:stock_objs] = @data[:stocks].map { |s| Stock.new s }
end end
def verbose_merge(to, from) def verbose_merge(to, from)

@ -1,22 +1,34 @@
module Charred module Charred
# module Stock
class Stock class Stock
@@default_stride = 6
attr :key attr :key
attr :name attr :name
attr :stride
attr :common_traits
attr :settings
attr :starting_stats
def initialize(key, name) def initialize(key, name = key, stride = @@default_stride)
@key = key @key = key
@name = name @name = name
@stride = stride
@common_traits = []
@settings = []
@starting_stats = []
end end
def as_json(options = {}) def as_json(options = {})
{ {
"key" => key, "key" => key,
"name" => name "name" => name,
"stride" => stride,
"common_traits" => common_traits,
"settings" => settings,
"starting_stats" => starting_stats
} }
end end
def to_json(*a) def to_json(*a)
as_json.to_json(*a) as_json.to_json(*a)
end end
# end
end end
end end

Loading…
Cancel
Save