@blizzhackers/d2data 2.7.9 → 2.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/compile.js CHANGED
@@ -13,6 +13,7 @@ const lineEnd = /[\n\r]+/g, fieldEnd = /\t/g, full = {};
13
13
  const inDir = 'txt/';
14
14
  const outDir = 'json/';
15
15
  const files = fs.readdirSync(inDir).filter(fn => fn.slice(-4) === '.txt').map(fn => fn.slice(0, -4));
16
+ const decimalPrecision = 15;
16
17
 
17
18
  function keySort(obj) {
18
19
  let keys = Object.keys(obj).sort(), ret = {};
@@ -309,6 +310,7 @@ files.forEach(fn => {
309
310
  full[fn]['andariel'].areaId = 37;
310
311
  full[fn]['duriel'].areaId = 73;
311
312
  full[fn]['mephisto'].areaId = 102;
313
+ full[fn]['izual'].areaId = 105;
312
314
  full[fn]['diablo'].areaId = 108;
313
315
  full[fn]['baalcrab'].areaId = 132;
314
316
  full[fn]['ubermephisto'].areaId = 136;
@@ -443,17 +445,30 @@ function forEachMonster(level, diff, func) {
443
445
 
444
446
  let m = (num) => level[(diff ? "nmon" : type ? "umon" : "mon") + num];
445
447
 
448
+ let totalrarity = 0;
449
+ let rarity = {};
450
+
446
451
  for (let c = 1; c <= 9; c++) {
447
452
  if (m(c)) {
448
453
  let mon = full.monstats[m(c)];
449
454
 
450
455
  if (mon && mon.enabled && mon.killable) {
451
- let mlvl = monlevel(mon, level, diff) + [0, 2, 3][type];
452
-
453
- func(mon, mlvl, type);
456
+ totalrarity += mon.Rarity || 0;
457
+ rarity[mon.Id] = rarity[mon.Id] || 0;
458
+ rarity[mon.Id] += (mon.Rarity || 0);
454
459
  }
455
460
  }
456
461
  }
462
+
463
+ for (let key in rarity) {
464
+ let mon = full.monstats[key];
465
+
466
+ if (rarity[key] > 0 && mon && mon.enabled && mon.killable) {
467
+ let mlvl = monlevel(mon, level, diff) + [0, 2, 3][type];
468
+
469
+ func(mon, mlvl, type, rarity[key] / totalrarity);
470
+ }
471
+ }
457
472
  });
458
473
  }
459
474
 
@@ -512,35 +527,54 @@ let monpopulation = {};
512
527
  )
513
528
  );
514
529
  }, 0),
515
- ucount = avg(l(s("MonUMin")), l(s("MonUMax"))) * uniqueRatio * uniqueCount,
516
- ccount = avg(l(s("MonUMin")), l(s("MonUMax"))) * champRatio * champCount,
517
- count = acount - ucount - ccount - scount - bcount;
530
+ monucount = avg(l(s("MonUMin")), l(s("MonUMax"))),
531
+ ucount = monucount * uniqueRatio * uniqueCount,
532
+ ccount = 0;
533
+
534
+ forEachMonster(level, diff, (mon, mlvl, type, rarity) => {
535
+ if (type === 1) {
536
+ ccount += (monucount * rarity * champRatio) * (champCount + avg((mon["PartyMin"] || 0), (mon["PartyMax"] || 0)));
537
+ }
538
+ });
539
+
540
+ let count = acount - ucount - ccount - scount - bcount;
518
541
 
519
542
  if (count > 0) {
520
- let totalpackssize = 0,
521
- udiv = 0;
522
-
523
- forEachMonster(level, diff, (mon, mlvl, type) => {
524
- if (!type) {
525
- let m = (key) => mon[key] || 0;
526
- let packsize = avg(
527
- m("PartyMin") + m("PartyMax"),
528
- m("MinGrp") + m("MaxGrp")
529
- );
530
-
531
- totalpackssize += packsize;
543
+ let ratio = [{}, {}, {}, {}, {}];
544
+
545
+ forEachMonster(level, diff, (mon, mlvl, type, rarity) => {
546
+ let grp = [
547
+ avg(
548
+ (mon["MinGrp"] || 0),
549
+ (mon["MaxGrp"] || 0)
550
+ ),
551
+ 3,
552
+ 1,
553
+ ][type];
554
+ ratio[type][mon.Id] = rarity * grp +
555
+ avg(
556
+ (mon["PartyMin"] || 0),
557
+ (mon["PartyMax"] || 0)
558
+ );
559
+ });
560
+
561
+ for (let stype = 0; stype < 5; stype++) {
562
+ let totalratio = 0;
563
+
564
+ for (let skey in ratio[stype]) {
565
+ totalratio += ratio[stype][skey];
532
566
  }
533
567
 
534
- if (type === 2) {
535
- udiv++;
568
+ for (let skey in ratio[stype]) {
569
+ ratio[stype][skey] /= totalratio;
536
570
  }
537
- });
571
+ }
538
572
 
539
- forEachMonster(level, diff, (mon, mlvl, type) => {
573
+ forEachMonster(level, diff, (mon, mlvl, type, rarity) => {
540
574
  let mult = [
541
- count / totalpackssize,
542
- ccount / champCount / udiv,
543
- ucount / uniqueCount / udiv,
575
+ count * ratio[type][mon.Id] / (avg((mon["MinGrp"] || 0), (mon["MaxGrp"] || 0)) + avg((mon["PartyMin"] || 0), (mon["PartyMax"] || 0))),
576
+ monucount * rarity * champRatio,
577
+ monucount * rarity * uniqueRatio,
544
578
  ][type];
545
579
  monpopulation[level.Id][['normal', 'champion', 'unique'][type]][mon.Id] = monpopulation[level.Id][['normal', 'champion', 'unique'][type]][mon.Id] || {
546
580
  "mlvl": 0,
@@ -551,7 +585,7 @@ let monpopulation = {};
551
585
  "packCount(H)": 0,
552
586
  };
553
587
  monpopulation[level.Id][['normal', 'champion', 'unique'][type]][mon.Id][s('mlvl')] = mlvl;
554
- monpopulation[level.Id][['normal', 'champion', 'unique'][type]][mon.Id][s('packCount')] = mult;
588
+ monpopulation[level.Id][['normal', 'champion', 'unique'][type]][mon.Id][s('packCount')] = Math.round(mult * (10 ** decimalPrecision)) / (10 ** decimalPrecision);
555
589
  });
556
590
  }
557
591