Advertisement
Guest User

FW_skillcalc

a guest
Jan 7th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var nobody_cares = {'Author':'X-idor', 'License':'public domain'};
  2.  
  3. Skills = {
  4.     'Amulettkunde':{'t_base':130, 'Lmax':100},
  5.     'Angriffsenergie':{'t_base':466, 'Lmax':10},
  6.     'Auftragsbeziehungen':{'t_base':466, 'Lmax':40},
  7.     'Auftragsplanung':{'t_base':39, 'Lmax':70},
  8.     'Ausgrabungswissen':{'t_base':175, 'Lmax':70},
  9.    
  10.     'Bankwesen':{'t_base':163, 'Lmax':80},
  11.     'Bauwesen':{'t_base':145, 'Lmax':90},
  12.     'Blutwissen':{'t_base':151, 'Lmax':50},
  13.    
  14.     'Chaosmagie':{'t_base':145, 'Lmax':90},    
  15.     'Diebstahlschutzwissen':{'t_base':163, 'Lmax':50},
  16.    
  17.     'Getreideverarbeitung':{'t_base':93, 'Lmax':30},
  18.     'Gewebeforschung':{'t_base':67, 'Lmax':50},
  19.     'Glück':{'t_base':93, 'Lmax':15},
  20.     'Gold-Inspiration':{'t_base':150, 'Lmax':100},
  21.     'Goldabbau':{'t_base':276, 'Lmax':30},
  22.     'Goldraub':{'t_base':100, 'Lmax':100},
  23.     'Gruppenheilung':{'t_base':42, 'Lmax':120},
  24.    
  25.     'Handwerkskunst':{'t_base':1166, 'Lmax':20},
  26.     'Innere Macht':{'t_base':210, 'Lmax':50},
  27.     'Inspiration':{'t_base':157, 'Lmax':90},
  28.     'Jagd':{'t_base':135, 'Lmax':50},
  29.     'Kochkunst':{'t_base':128, 'Lmax':80},
  30.    
  31.     'Labortechnik':{'t_base':700, 'Lmax':32},
  32.     'Lagerlogistik':{'t_base':145, 'Lmax':90},
  33.     'Lebensenergie':{'t_base':151, 'Lmax':30},
  34.     'Lebenstraining':{'t_base':198, 'Lmax':50},
  35.     'Lerntechnik':{'t_base':583, 'Lmax':50},
  36.    
  37.     'Magieverlängerung':{'t_base':280, 'Lmax':30},
  38.     'Marktwirtschaft':{'t_base':58, 'Lmax':50},
  39.    
  40.     'Pflanzenkunde':{'t_base':233, 'Lmax':80},
  41.     'Phasenenergieeffizienz':{'t_base':134, 'Lmax':70},
  42.     'Phasenenergiemaximierung':{'t_base':145, 'Lmax':80},
  43.     'Phasenverständnis':{'t_base':58, 'Lmax':70},
  44.     'Plünderung':{'t_base':217, 'Lmax':30},
  45.    
  46.     'Rache':{'t_base':58, 'Lmax':80},
  47.     'Reparaturwissen':{'t_base':70, 'Lmax':30},
  48.    
  49.     'Schusswaffen':{'t_base':373, 'Lmax':17},
  50.     'Seelenverbindung':{'t_base':350, 'Lmax':60},
  51.     'Selbstheilung':{'t_base':186, 'Lmax':60},
  52.     'Stärketraining':{'t_base':175, 'Lmax':50},
  53.    
  54.     'Verjagen':{'t_base':133, 'Lmax':100},
  55.     'Waffenkunst':{'t_base':151, 'Lmax':30},
  56.     'Wissens-Inspiration':{'t_base':25, 'Lmax':100},
  57.     'Zauberkunst':{'t_base':1400, 'Lmax':8},
  58.     'Zaubertruhenwissen':{'t_base':583, 'Lmax':40},
  59.     'Zeit-Inspiration':{'t_base':50, 'Lmax':100},
  60.     'Ölverwaltung':{'t_base':151, 'Lmax':60},
  61.     'Überzeugungskraft':{'t_base':198, 'Lmax':50}
  62. }
  63.  
  64. range = function(a,b,step){
  65.     var A = [];
  66.     A[0] = a;
  67.     step = step||1;
  68.     while(a+step<=b){
  69.         A[A.length]=a+=step;
  70.     }
  71.     return A
  72. };
  73.  
  74. time_to_now = function(skillname, Lnow, Lboost){ /*the array.reduce(blah..) is apparently the easiest way to sum the elements */
  75.     return Skills[skillname]['t_base'] * Math.pow(0.99,Lboost) * range(0,Lnow,1).reduce(function(a, b){return a + b;},0);};
  76.  
  77. time_to_max = function(skillname, Lnow, Lboost){
  78.     return Skills[skillname]['t_base'] * Math.pow(0.99,Lboost) * range(Lnow, Skills[skillname]['Lmax'],1).reduce(function(a, b){return a + b;},0);};
  79.  
  80. parseselection = function(s){
  81.     /*Strg+A, Strg+C, Strg+V the skillframe into a textfield*/
  82.     s=s.split('higkeit\tStufe\tMax\n')[1].split('\n\n\n')[0]; /*not sure how umlauts work, better avoid them*/
  83.     strain=s.split('\n\n')[0].split(/\n|\t/);
  84.     smaxed=s.split('higkeit\tStufe\n')[1].split(/\n|\t/);
  85.     var skills={};
  86.     for(var i=0;i<strain.length;i++){skills[strain[i++]]=+strain[i++];}; /*str, int, junk, str, int, junk*/
  87.     for(var i=0;i<smaxed.length;i++){skills[smaxed[i]]=+smaxed[++i];}; /*str, int, str, int*/
  88.     return skills;
  89. }
  90.  
  91. /*this shit right here is one of 5+ different approaches which work everywhere except FW
  92. var paste = document.getSelection();
  93. var skills = parseselection(paste);
  94. */
  95.  
  96. time_spent = function(skills){ /*takes a dictionary of {'skillname': current_level} pairs as returned by parseselection */
  97.     /*total time spent so far on all availlable skills*/
  98.     if (!skills['Lerntechnik']) skills['Lerntechnik']=0;
  99.     var Lboost = skills['Lerntechnik']; /*assumes LT was skilled first*/
  100.     var tspent = [time_to_now(s, skills[s],Lboost) for (s in skills)].reduce(function(a, b){return a + b;},0);
  101.     /*LT is unaffected by itself*/
  102.     tspent = tspent - time_to_now('Lerntechnik', skills['Lerntechnik'],Lboost) + time_to_now('Lerntechnik', skills['Lerntechnik'],0);
  103.     return tspent;
  104. }
  105.  
  106. time_left = function(skills){ /*takes a dictionary of {'skillname': current_level} pairs as returned by parseselection */
  107.     /*time required so max all availlable skills*/
  108.     var Lboost = skills['Lerntechnik']||0
  109.     var tspent = [time_to_max(s, skills[s],Lboost) for (s in skills)].reduce(function(a, b){return a + b;},0);
  110.     /*if LT available but not maxed, assume it will be learned last*/
  111.     return tspent;
  112. }
  113.  
  114.  
  115. /*
  116. alert(time_spent(parseselection(copypasta))/60/24 );
  117. or or some other kind of output
  118. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement