reorganize data files

pull/1/head
Michael Hansen 5 years ago
parent 29aa8c8329
commit e0e4b869e7
  1. 6
      src/app.rb
  2. 296
      src/data/dark_elf/lifepath.json
  3. 1
      src/data/dark_elf/skills.json
  4. 46
      src/data/dark_elf/traits.json
  5. 0
      src/data/gold/lifepaths/dwarf.json
  6. 0
      src/data/gold/lifepaths/elf.json
  7. 1
      src/data/gold/lifepaths/man.json
  8. 0
      src/data/gold/lifepaths/orc.json
  9. 0
      src/data/gold/lifepaths/roden.json
  10. 0
      src/data/gold/lifepaths/wolf.json
  11. 0
      src/data/gold/resources/dwarf.json
  12. 0
      src/data/gold/resources/elf.json
  13. 0
      src/data/gold/resources/man.json
  14. 0
      src/data/gold/resources/orc.json
  15. 0
      src/data/gold/resources/roden.json
  16. 0
      src/data/gold/resources/wolf.json
  17. 0
      src/data/gold/skills.json
  18. 0
      src/data/gold/starting_stat_pts/dwarf.json
  19. 0
      src/data/gold/starting_stat_pts/elf.json
  20. 0
      src/data/gold/starting_stat_pts/man.json
  21. 0
      src/data/gold/starting_stat_pts/orc.json
  22. 0
      src/data/gold/starting_stat_pts/roden.json
  23. 0
      src/data/gold/starting_stat_pts/wolf.json
  24. 0
      src/data/gold/traits.json
  25. 0
      src/data/wizard/lifepaths.json
  26. 0
      src/data/wizard/skills.json
  27. 0
      src/data/wizard/traits.json
  28. 188
      src/lib/data.rb
  29. 15
      src/lib/data/dark_elf.rb
  30. 39
      src/lib/data/gold.rb
  31. 118
      src/lib/data/wizard.rb

@ -11,7 +11,7 @@ set :bind, ENV['HOST']
set :port, ENV['PORT']
CACHE = Mu::Cache.new :max_size => 128, :max_time => 30.0
DATA = CharredData.load_data
DATA = Charred::Data.new.data
helpers do
def logger
@ -23,6 +23,10 @@ get '/' do
erb :index
end
get '/list_chars/:user' do
"{}"
end
get /\/([\w]+)_partial/ do
partial = params['captures'].first
erb "partials/#{partial}".to_sym

@ -0,0 +1,296 @@
{
"Path Of Spite Subsetting": {
"Griever": {
"time": 3,
"res": 0,
"skills": [
[
3,
"Sorrow Of Truth",
"Dark Elf-wise"
]
],
"traits": [
1,
"Spite"
]
},
"Wastrel": {
"time": 25,
"res": 3,
"skills": [
[
6,
"Scavenging",
"Brawling",
"Forest-wise",
"Wasteland-wise",
"Animal-wise"
]
],
"traits": [
2,
"Filthy",
"Feral"
],
"requires": "Griever",
"requires_expr": [
"griever"
]
},
"Thief": {
"time": 18,
"res": 6,
"stat": [
[
1,
"pm"
]
],
"skills": [
[
6,
"Lock Pick",
"Stealthy",
"Climbing",
"Sleight Of Hand",
"Dirge Of Night"
]
],
"traits": [
1,
"Thief"
],
"requires": "Griever",
"requires_expr": [
"griever"
]
},
"Assassin": {
"time": 15,
"res": 6,
"stat": [
[
1,
"p"
]
],
"skills": [
[
7,
"Intimidation",
"Poisons",
"Escape Artist",
"Knives",
"Garotte",
"Keen Of Terror"
]
],
"traits": [
1,
"Murderous",
"Callous",
"Cold Blooded"
],
"requires": "Griever",
"requires_expr": [
"griever"
]
},
"Stalker": {
"time": 20,
"res": 8,
"skills": [
[
8,
"Hunting",
"Elf-wise",
"Tracking",
"Trapper",
"Observation",
"Stealthy",
"Throwing",
"Javelin",
"Supplication To Shadows"
]
],
"traits": [
1,
"Saturnine"
],
"requires": "Griever",
"requires_expr": [
"griever"
]
},
"Deceiver": {
"time": 35,
"res": 10,
"stat": [
[
1,
"m"
]
],
"skills": [
[
7,
"Sleight Of Hand",
"Disguise",
"Inconspicuous",
"Rhyme Of The Unraveller"
]
],
"traits": [
1,
"Deceptive"
],
"requires": "Griever",
"requires_expr": [
"griever"
]
},
"Liar": {
"time": 25,
"res": 8,
"stat": [
[
1,
"m"
]
],
"skills": [
[
6,
"Falsehood",
"Soothing Platitudes",
"Persuasion",
"Twisted Tongue"
]
],
"traits": [
1,
"Compulsive Liar"
],
"requires": "Griever",
"requires_expr": [
"griever"
]
},
"Siren": {
"time": 55,
"res": 20,
"stat": [
[
1,
"pm"
]
],
"skills": [
[
9,
"Seduction",
"Etiquette",
"Persuasion",
"Soothing Platitudes",
"Gossip-wise",
"Fugue Of Discord",
"Litany Of Fools"
]
],
"traits": [
2,
"Charismatic",
"Femme Fatale/Homme Fatale"
],
"requires": "Assassin, Deceiver or Liar",
"requires_expr": [
"assassin",
"deceiver",
"liar"
]
},
"Eremite": {
"time": 150,
"res": 15,
"stat": [
[
1,
"m"
]
],
"skills": [
[
12,
"Philosophy",
"Ugly Truth",
"Obscure History",
"Symbology",
"Strategy",
"Elf-wise",
"Orc-wise",
"Dwarf-wise",
"Man-wise",
"Paean To The Dark Fire"
]
],
"traits": [
2,
"Remote",
"Cold"
],
"requires": "Siren, Wastrel or Stalker",
"requires_expr": [
"siren",
"wastrel",
"stalker"
]
},
"Recluse": {
"time": 225,
"res": 25,
"stat": [
[
1,
"p"
]
],
"skills": [
[
2,
"Ancient History",
"Dwarf-wise",
"Elven Politics-wise",
"Cut Of The Quickened Mind"
],
[
5,
"General"
]
],
"traits": [
1,
"Vengeful"
],
"requires": "Eremite or any three Dark Elf lifepaths",
"requires_expr": [
"+or",
[
"eremite"
],
[
"+has_n_lifepaths_in",
3,
"path of spite subsetting:griever",
"path of spite subsetting:wastrel",
"path of spite subsetting:thief",
"path of spite subsetting:assassin",
"path of spite subsetting:stalker",
"path of spite subsetting:deceiver",
"path of spite subsetting:liar",
"path of spite subsetting:siren"
]
]
}
}
}

@ -0,0 +1,46 @@
{
"Callous": {
"cost": 1,
"type": "character"
},
"Cold": {
"cost": 1,
"type": "character"
},
"Compulsive Liar": {
"cost": 1,
"type": "character"
},
"Deceptive": {
"cost": 1,
"type": "character"
},
"Femme Fatale/Homme Fatale": {
"cost": 1,
"type": "character"
},
"Feral": {
"cost": 1,
"type": "character"
},
"Filthy": {
"cost": 1,
"type": "character"
},
"Murderous": {
"cost": 1,
"type": "character"
},
"Remote": {
"cost": 1,
"type": "character"
},
"Saturnine": {
"cost": 1,
"type": "character"
},
"Spite": {
"cost": 1,
"type": "character"
}
}

@ -10853,6 +10853,7 @@
[
"+has_n_lifepaths_in",
2,
"seafaring setting:son of a gun",
"seafaring setting:boy",
"seafaring setting:galley slave",
"seafaring setting:ratcatcher",

@ -1,176 +1,34 @@
require 'json'
require_relative 'data/gold'
require_relative 'data/wizard'
module CharredData
def self.merge_data!(to, from)
from.keys.each do |k|
to[k] = from[k]
end
end
def self.lifepath_requirements(expr)
if expr.is_a? Numeric
[]
elsif expr.is_a? String
if expr.start_with? "+"
[]
else
expr
end
elsif expr.is_a? Array
(expr.map { |e| self.lifepath_requirements(e) }).flatten
else
[]
end
end
def self.load_wizard_burner(data)
puts 'Loading wizard burner'
file = File.read('data/lifepaths/wizard.json')
wizard_data = JSON.parse(file)
file = File.read('data/wizard_skills.json')
wizard_skills = JSON.parse(file)
self.merge_data!(data[:skills], wizard_skills)
file = File.read('data/wizard_traits.json')
wizard_traits = JSON.parse(file)
self.merge_data!(data[:traits], wizard_traits)
module Charred
class Data
include Charred::Gold
include Charred::Wizard
man = data[:lifepaths]['man']
attr :data
man['College of Magic Setting'] = wizard_data['College of Magic Setting']
man['Death Cult Setting'] = wizard_data['Death Cult Setting']
def initialize
@data = {}
self.merge_data!(data[:lifepaths]['orc']['Servant Of The Dark Blood Subsetting'], wizard_data['Servant Of The Dark Blood Subsetting'])
[
'Peasant Setting',
'Villager Setting',
'City Dweller Setting',
'Noble Court Subsetting',
'Outcast Subsetting'
].each do |setting|
self.merge_data!(man[setting], wizard_data[setting])
end
[
'Peasant Setting',
'Villager Setting',
'City Dweller Setting',
'Seafaring Setting',
'Servitude And Captive Setting'
].each do |setting|
self.merge_data!(man[setting], {
'Gifted Child' => wizard_data['Special Gifted Lifepaths']['Gifted Child']
})
load_gold(@data)
load_wizard(@data)
end
[
'Noble Court Subsetting',
'Religious Subsetting',
'Outcast Subsetting',
'Professional Soldier Subsetting'
].each do |setting|
self.merge_data!(man[setting], {
'Apt Pupil' => wizard_data['Special Gifted Lifepaths']['Apt Pupil']
})
end
leads_short = {
'College of Magic Setting' => 'College',
'Death Cult Setting' => 'Death',
}
# backfill leads
leads_short.keys.each do |wiz_set|
wizard_data[wiz_set].keys.each do |wiz_lp|
lifepath = wizard_data[wiz_set][wiz_lp]
next if !lifepath['requires_expr']
requirements = self.lifepath_requirements(lifepath['requires_expr'])
requirements.each do |req|
setting = nil
req_lp = req
setting, req_lp = req.split(':') if req.include? ':'
man.keys.each do |man_set|
next if wiz_set.downcase == man_set.downcase
next if setting && setting != man_set.downcase
man[man_set].keys.each do |man_lp|
next if req_lp != man_lp.downcase
#puts "adding #{wiz_set}:#{wiz_lp} lead to #{man_set}:#{man_lp}"
man[man_set][man_lp]['key_leads'] |= [wiz_set]
man[man_set][man_lp]['leads'] |= [leads_short[wiz_set]]
end
end
end
end
end
# backfill Apt Pupil == Neophyte Sorcerer connection
man.keys.each do |man_set|
man[man_set].keys.each do |man_lp|
requirements = self.lifepath_requirements(man[man_set][man_lp]['requires_expr'])
next if requirements.include? 'apt pupil'
requirements.each do |req|
setting = nil
req_lp = req
setting, req_lp = req.split(':') if req.include? ':'
next unless req_lp.downcase == 'neophyte sorcerer'
if man[man_set][man_lp]['requires_expr'].include? 'neophyte sorcerer'
man[man_set][man_lp]['requires_expr'] |= ['apt pupil']
else
puts "warning, could not add apt pupil to deep requirements array at #{man_set}:#{man_lp}"
end
def lifepath_requirements(expr)
if expr.is_a? Numeric
[]
elsif expr.is_a? String
if expr.start_with? "+"
[]
else
expr
end
elsif expr.is_a? Array
(expr.map { |e| self.lifepath_requirements(e) }).flatten
else
[]
end
end
data[:lifepaths]['man'] = man
puts 'loaded!'
data
end
def self.load_data
file = File.read('data/skills.json')
skills = JSON.parse(file)
file = File.read('data/traits.json')
traits = JSON.parse(file)
lifepaths = {}
resources = {}
stat_pts = {}
stocks = ['dwarf', 'elf', 'man', 'orc', 'roden', 'wolf']
stocks.each do |stock|
file = File.read("data/lifepaths/#{stock}.json")
lifepaths[stock] = JSON.parse(file)
file = File.read("data/resources/#{stock}.json")
resources[stock] = JSON.parse(file)
file = File.read("data/starting_stat_pts/#{stock}.json")
stat_pts[stock] = JSON.parse(file)
end
data = {
:stocks => stocks,
:skills => skills,
:traits => traits,
:lifepaths => lifepaths,
:resources => resources,
:stat_pts => stat_pts
}
data = self.load_wizard_burner(data)
data
end
end

@ -0,0 +1,15 @@
require 'json'
module Charred
module DarkElf
def load_dark_elf(data)
file = File.read('data/dark_elf/skills.json')
skills = JSON.parse(file)
data[:skills].merge! skills
file = File.read('data/dark_elf/traits.json')
traits = JSON.parse(file)
data[:traits].merge! traits
end
end
end

@ -0,0 +1,39 @@
require 'json'
module Charred
module Gold
def load_gold(data)
file = File.read('data/gold/skills.json')
skills = JSON.parse(file)
file = File.read('data/gold/traits.json')
traits = JSON.parse(file)
lifepaths = {}
resources = {}
stat_pts = {}
stocks = ['dwarf', 'elf', 'man', 'orc', 'roden', 'wolf']
stocks.each do |stock|
file = File.read("data/gold/lifepaths/#{stock}.json")
lifepaths[stock] = JSON.parse(file)
file = File.read("data/gold/resources/#{stock}.json")
resources[stock] = JSON.parse(file)
file = File.read("data/gold/starting_stat_pts/#{stock}.json")
stat_pts[stock] = JSON.parse(file)
end
data.merge!({
:stocks => stocks,
:skills => skills,
:traits => traits,
:lifepaths => lifepaths,
:resources => resources,
:stat_pts => stat_pts
})
end
end
end

@ -0,0 +1,118 @@
require 'json'
module Charred
module Wizard
def load_wizard(data)
puts 'Loading wizard burner'
file = File.read('data/wizard/lifepaths.json')
wizard_data = JSON.parse(file)
file = File.read('data/wizard/skills.json')
wizard_skills = JSON.parse(file)
data[:skills].merge! wizard_skills
file = File.read('data/wizard/traits.json')
wizard_traits = JSON.parse(file)
data[:traits].merge! wizard_traits
man = data[:lifepaths]['man']
man['College of Magic Setting'] = wizard_data['College of Magic Setting']
man['Death Cult Setting'] = wizard_data['Death Cult Setting']
data[:lifepaths]['orc']['Servant Of The Dark Blood Subsetting'].merge!(wizard_data['Servant Of The Dark Blood Subsetting'])
[
'Peasant Setting',
'Villager Setting',
'City Dweller Setting',
'Noble Court Subsetting',
'Outcast Subsetting'
].each do |setting|
man[setting].merge!(wizard_data[setting])
end
[
'Peasant Setting',
'Villager Setting',
'City Dweller Setting',
'Seafaring Setting',
'Servitude And Captive Setting'
].each do |setting|
man[setting].merge!({
'Gifted Child' => wizard_data['Special Gifted Lifepaths']['Gifted Child']
})
end
[
'Noble Court Subsetting',
'Religious Subsetting',
'Outcast Subsetting',
'Professional Soldier Subsetting'
].each do |setting|
man[setting].merge!({
'Apt Pupil' => wizard_data['Special Gifted Lifepaths']['Apt Pupil']
})
end
leads_short = {
'College of Magic Setting' => 'College',
'Death Cult Setting' => 'Death',
}
# backfill leads
leads_short.keys.each do |wiz_set|
wizard_data[wiz_set].keys.each do |wiz_lp|
lifepath = wizard_data[wiz_set][wiz_lp]
next if !lifepath['requires_expr']
requirements = self.lifepath_requirements(lifepath['requires_expr'])
requirements.each do |req|
setting = nil
req_lp = req
setting, req_lp = req.split(':') if req.include? ':'
man.keys.each do |man_set|
next if wiz_set.downcase == man_set.downcase
next if setting && setting != man_set.downcase
man[man_set].keys.each do |man_lp|
next if req_lp != man_lp.downcase
#puts "adding #{wiz_set}:#{wiz_lp} lead to #{man_set}:#{man_lp}"
man[man_set][man_lp]['key_leads'] |= [wiz_set]
man[man_set][man_lp]['leads'] |= [leads_short[wiz_set]]
end
end
end
end
end
# backfill Apt Pupil == Neophyte Sorcerer connection
man.keys.each do |man_set|
man[man_set].keys.each do |man_lp|
requirements = self.lifepath_requirements(man[man_set][man_lp]['requires_expr'])
next if requirements.include? 'apt pupil'
requirements.each do |req|
setting = nil
req_lp = req
setting, req_lp = req.split(':') if req.include? ':'
next unless req_lp.downcase == 'neophyte sorcerer'
if man[man_set][man_lp]['requires_expr'].include? 'neophyte sorcerer'
man[man_set][man_lp]['requires_expr'] |= ['apt pupil']
else
puts "warning, could not add apt pupil to deep requirements array at #{man_set}:#{man_lp}"
end
end
end
end
data[:lifepaths]['man'] = man
puts 'loaded!'
data
end
end
end
Loading…
Cancel
Save