Advertisement
Guest User

Hash trouble

a guest
Jan 20th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var trace_DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  2. var trace_bool = false
  3. DataManager.isDatabaseLoaded = function() {
  4.   if (!trace_DataManager_isDatabaseLoaded.call(this)) return false;
  5.   if (!trace_bool) {
  6.     this.alchemyItemScan($dataItems);
  7.     this.alchemyItemScan($dataWeapons);
  8.     this.alchemyItemScan($dataArmors);
  9.     trace_bool = true;
  10.   }
  11.   return true;
  12. };
  13.  
  14. Trace.alchemyRecipe = {};
  15.  
  16. DataManager.alchemyItemScan = function (group) {
  17.     var recipe = /<alchemyRecipe:\s*([iwa]\d+(?:\s*,\s*[iwa]\d+)*)>/im;
  18.     for (var n = 1; n < group.length; n++) {
  19.         var obj = group[n];
  20.         obj.alchemyRecipe = false;
  21.         obj.alchemyExp = 0;
  22.         obj.alchemyResult = false;
  23.        
  24.        
  25.         if (obj.meta.alchemyCategory) {
  26.             obj.alchemyCategory = obj.meta.alchemyCategory;
  27.         };
  28.        
  29.         if (obj.meta.alchemyExp) {
  30.             obj.alchemyExp = Number(obj.meta.alchemyExp);
  31.         };
  32.        
  33.         if (obj.meta.alchemyResult) {
  34.             obj.alchemyResult = obj.meta.alchemyResult;
  35.         };
  36.        
  37.         var notedata = obj.note.split(/[\r\n]+/);
  38.         for (var i = 0; i < notedata.length; i++) {
  39.             var line = notedata[i];
  40.             if (line.match(recipe)) {
  41.                 var arr = []
  42.                 var pieces = RegExp.$1.split(/,\s*/g);
  43.                 for (var i = 0; i < pieces.length; i++) {
  44.                     var piece = pieces[i];
  45.                     arr.push(piece);
  46.                 };
  47.                
  48.                 obj.alchemyRecipe = arr;
  49.             };
  50.         };
  51.         if (obj.meta.alchemyResult) {
  52.             Trace.alchemyRecipe[obj.name] = {};
  53.             Trace.alchemyRecipe[obj.name].recipe = obj.alchemyRecipe;
  54.             Trace.alchemyRecipe[obj.name].result = obj.alchemyResult;
  55.             Trace.alchemyRecipe[obj.name].exp = obj.alchemyExp;
  56.         };
  57.     };
  58. };
  59.  
  60. console.log(Trace.alchemyRecipe);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement