Replace references to stock_objs with just stocks

The stock object is now the universal interface to stock metadata.
Daniel Asher Resnick 2 years ago
parent e86325d6df
commit d9d95f5774
  1. 10
      src/app.rb
  2. 2
      src/lib/data.rb
  3. 10
      src/lib/data/gold.rb
  4. 2
      src/lib/data/troll.rb
  5. 6
      src/public/js/burning-service.js
  6. 4
      src/public/js/burning.js

@ -49,12 +49,12 @@ get '/traits' do
json DATA[:traits]
end
get '/stock_objs' do
json DATA[:stock_objs]
get '/stocks' do
json DATA[:stocks]
end
get '/lifepaths/:stock' do
if DATA[:stock_objs].keys.include? params['stock']
if DATA[:stocks].keys.include? params['stock']
json DATA[:lifepaths][params['stock']]
else
404
@ -62,7 +62,7 @@ get '/lifepaths/:stock' do
end
get '/starting_stat_pts/:stock' do
if DATA[:stock_objs].keys.include? params['stock']
if DATA[:stocks].keys.include? params['stock']
json DATA[:stat_pts][params['stock']]
else
404
@ -70,7 +70,7 @@ get '/starting_stat_pts/:stock' do
end
get '/resources/:stock' do
if DATA[:stock_objs].keys.include? params['stock']
if DATA[:stocks].keys.include? params['stock']
json DATA[:resources][params['stock']]
else
404

@ -15,7 +15,7 @@ module Charred
def initialize
@data = {}
@data[:stock_objs] = {}
@data[:stocks] = {}
puts 'loading gold'
load_gold(@data)

@ -13,11 +13,11 @@ module Charred
lifepaths = {}
resources = {}
stat_pts = {}
stock_objs = {}
stocks = {}
stocks = ['dwarf', 'elf', 'man', 'orc', 'roden', 'wolf']
gold_stocks = ['dwarf', 'elf', 'man', 'orc', 'roden', 'wolf']
stocks.each do |stock|
gold_stocks.each do |stock|
file = File.read("data/gold/lifepaths/#{stock}.json")
lifepaths[stock] = JSON.parse(file)
@ -25,7 +25,7 @@ module Charred
resources[stock] = JSON.parse(file)
file = File.read("data/gold/stocks/#{stock}.json")
stock_objs[stock] = Stock.new(JSON.parse(file))
stocks[stock] = Stock.new(JSON.parse(file))
end
data.merge!({
@ -34,7 +34,7 @@ module Charred
:lifepaths => lifepaths,
:resources => resources,
:stat_pts => stat_pts,
:stock_objs => stock_objs
:stocks => stocks
})
end
end

@ -22,7 +22,7 @@ module Charred
file = File.read("data/troll/stock.json")
stock = JSON.parse(file)
data[:stock_objs]['troll'] = Stock.new(stock)
data[:stocks]['troll'] = Stock.new(stock)
end
end
end

@ -292,10 +292,10 @@ function BurningDataService($http) {
var myself = this;
var stocks;
$http.get("/stock_objs", {'timeout': 3000}).
$http.get("/stocks", {'timeout': 3000}).
success(function(data,status,headers,config){
console.log(data);
myself.stock_objs = data;
myself.stocks = data;
stocks = Object.keys(data);
for (var i = 0; i < stocks.length; i++) {
loadLifepathsForStock(stocks[i]);
@ -334,7 +334,7 @@ function BurningDataService($http) {
console.log("Loading starting stat points failed: asked to load pts for invalid stock " + stock);
return
}
myself.startingStatPts[stock] = new StartingStatPoints(myself.stock_objs[stock].starting_stats);
myself.startingStatPts[stock] = new StartingStatPoints(myself.stocks[stock].starting_stats);
}
/* Load resources from server */

@ -1024,7 +1024,7 @@ function BurningCtrl($scope, $http, $modal, $timeout, settings, appropriateWeapo
return {"shade" : "", "exp" : 10 - $scope.statsByName["Will"].exp() + bonus};
}
else if ( "Stride" == name ){
var stride = burningData.stock_objs[$scope.stock].stride;
var stride = burningData.stocks[$scope.stock].stride;
stride += bonus;
return {"shade" : "", "exp" : stride};
}
@ -2316,7 +2316,7 @@ function setCommonTraits($scope, burningData){
if( $scope.selectedLifepaths.length == 0 )
return;
var common = burningData.stock_objs[$scope.stock].common_traits;
var common = burningData.stocks[$scope.stock].common_traits;
if(common.length > 0){
for(var j = 0; j < common.length; j++){
var name = common[j];

Loading…
Cancel
Save