@@ -19,6 +19,16 @@ describe("TestDefence", function()
19
19
runCallback (" OnFrame" )
20
20
end
21
21
22
+ -- a small helper function to calculate damage taken from limited test parameters
23
+ local function takenHitFromTypeMaxHit (type , enemyDamageMulti )
24
+ return build .calcsTab .calcs .takenHitFromDamage (build .calcsTab .calcsOutput [type .. " MaximumHitTaken" ] * (enemyDamageMulti or 1 ), type , build .calcsTab .calcsEnv .player )
25
+ end
26
+
27
+ local function poolsRemainingAfterTypeMaxHit (type , enemyDamageMulti )
28
+ local _ , takenDamages = takenHitFromTypeMaxHit (type , enemyDamageMulti )
29
+ return build .calcsTab .calcs .reducePoolsByDamage (nil , takenDamages , build .calcsTab .calcsEnv .player )
30
+ end
31
+
22
32
it (" no armour max hits" , function ()
23
33
build .configTab .input .enemyIsBoss = " None"
24
34
build .configTab .input .customMods = " "
@@ -92,12 +102,29 @@ describe("TestDefence", function()
92
102
assert .are .equals (3000 , build .calcsTab .calcsOutput .ColdMaximumHitTaken )
93
103
assert .are .equals (3000 , build .calcsTab .calcsOutput .LightningMaximumHitTaken )
94
104
assert .are .equals (3000 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
105
+ local poolsRemaining = poolsRemainingAfterTypeMaxHit (" Lightning" )
106
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
107
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
108
+
109
+ build .configTab .input .customMods = " \z
110
+ +200 to all resistances\n\z
111
+ +200 to all maximum resistances\n\z
112
+ 50% reduced damage taken\n\z
113
+ 50% less damage taken\n\z
114
+ Nearby enemies deal 20% less damage\n\z
115
+ Gain 100% of life as extra maximum energy shield\n\z
116
+ intelligence provides no bonus to energy shield\n\z
117
+ "
118
+ pob1and2Compat ()
119
+ assert .are .equals (600 , build .calcsTab .calcsOutput .PhysicalMaximumHitTaken )
120
+ assert .are .equals (6000 , build .calcsTab .calcsOutput .FireMaximumHitTaken )
121
+ assert .are .equals (6000 , build .calcsTab .calcsOutput .ColdMaximumHitTaken )
122
+ assert .are .equals (6000 , build .calcsTab .calcsOutput .LightningMaximumHitTaken )
123
+ assert .are .equals (4500 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
124
+ assert .are .equals (0 , floor (poolsRemaining .EnergyShield ))
125
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
126
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
95
127
end )
96
-
97
- -- a small helper function to calculate damage taken from limited test parameters
98
- local function takenHitFromTypeMaxHit (type , enemyDamageMulti )
99
- return build .calcsTab .calcs .takenHitFromDamage (build .calcsTab .calcsOutput [type .. " MaximumHitTaken" ] * (enemyDamageMulti or 1 ), type , build .calcsTab .calcsEnv .player )
100
- end
101
128
102
129
it (" armoured max hits" , function ()
103
130
build .configTab .input .enemyIsBoss = " None"
@@ -269,9 +296,9 @@ describe("TestDefence", function()
269
296
Chaos Inoculation\n\z
270
297
"
271
298
pob1and2Compat ()
272
- local _ , takenDamages = takenHitFromTypeMaxHit (" Cold" )
273
- local poolsRemaining = build . calcsTab . calcs . reducePoolsByDamage ( nil , takenDamages , build . calcsTab . calcsEnv . player )
274
- assert .are .equals (0 , round (poolsRemaining .Life ))
299
+ local poolsRemaining = poolsRemainingAfterTypeMaxHit (" Cold" )
300
+ assert . are . equals ( 0 , floor ( poolsRemaining . Life ) )
301
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
275
302
end )
276
303
277
304
it (" damage conversion to different size pools" , function ()
@@ -286,10 +313,10 @@ describe("TestDefence", function()
286
313
10% of lightning damage taken as cold damage\n\z
287
314
" -- Small amount of conversion into a smaller pool leads to the higher pool damage type (lightning) draining it's own excess pool (mana), and then joining back on the shared pools (life)
288
315
pob1and2Compat ()
289
- local _ , takenDamages = takenHitFromTypeMaxHit (" Lightning" )
290
- local poolsRemaining = build . calcsTab . calcs . reducePoolsByDamage ( nil , takenDamages , build . calcsTab . calcsEnv . player )
291
- assert .are .equals (0 , round (poolsRemaining .Mana ))
292
- assert .are .not_false ( poolsRemaining .Life / 100 < 0.1 )
316
+ local poolsRemaining = poolsRemainingAfterTypeMaxHit (" Lightning" )
317
+ assert . are . equals ( 0 , floor ( poolsRemaining . Mana ) )
318
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
319
+ assert .are .equals ( 0 , floor ( poolsRemaining .OverkillDamage ) )
293
320
294
321
build .configTab .input .customMods = " \z
295
322
+140 to maximum life\n\z
@@ -301,10 +328,10 @@ describe("TestDefence", function()
301
328
20% of lightning damage taken as cold damage\n\z
302
329
" -- This is a case where cold damage drains the whole life pool and lightning damage drains the entire mana pool, leaving nothing
303
330
pob1and2Compat ()
304
- _ , takenDamages = takenHitFromTypeMaxHit (" Lightning" )
305
- poolsRemaining = build . calcsTab . calcs . reducePoolsByDamage ( nil , takenDamages , build . calcsTab . calcsEnv . player )
306
- assert .are .equals (0 , round (poolsRemaining .Life ))
307
- assert .are .equals (0 , round (poolsRemaining .Mana ))
331
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Lightning" )
332
+ assert . are . equals ( 0 , floor ( poolsRemaining . Mana ) )
333
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
334
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
308
335
309
336
build .configTab .input .customMods = " \z
310
337
+40 to maximum life\n\z
@@ -316,10 +343,10 @@ describe("TestDefence", function()
316
343
20% of lightning damage taken as cold damage\n\z
317
344
" -- Any extra mana in this case will not help and be left over after death, since life hits 0 from the cold damage alone
318
345
pob1and2Compat ()
319
- _ , takenDamages = takenHitFromTypeMaxHit (" Lightning" )
320
- poolsRemaining = build .calcsTab .calcs .reducePoolsByDamage (nil , takenDamages , build .calcsTab .calcsEnv .player )
321
- assert .are .equals (0 , round (poolsRemaining .Life ))
346
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Lightning" )
322
347
assert .are .not_false (1000 < round (poolsRemaining .Mana ))
348
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
349
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
323
350
324
351
-- conversion into a bigger pool
325
352
build .configTab .input .customMods = " \z
@@ -332,10 +359,10 @@ describe("TestDefence", function()
332
359
90% of cold damage taken as lightning damage\n\z
333
360
" -- With inverted conversion amounts the behaviour of converting into a bigger pool should be exactly the same as converting into a lower one.
334
361
pob1and2Compat ()
335
- _ , takenDamages = takenHitFromTypeMaxHit (" Cold" )
336
- poolsRemaining = build . calcsTab . calcs . reducePoolsByDamage ( nil , takenDamages , build . calcsTab . calcsEnv . player )
337
- assert .are .equals (0 , round (poolsRemaining .Mana ))
338
- assert .are .not_false ( poolsRemaining .Life / 100 < 0.1 )
362
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Cold" )
363
+ assert . are . equals ( 0 , floor ( poolsRemaining . Mana ) )
364
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
365
+ assert .are .equals ( 0 , floor ( poolsRemaining .OverkillDamage ) )
339
366
340
367
build .configTab .input .customMods = " \z
341
368
+140 to maximum life\n\z
@@ -347,10 +374,10 @@ describe("TestDefence", function()
347
374
80% of cold damage taken as lightning damage\n\z
348
375
"
349
376
pob1and2Compat ()
350
- _ , takenDamages = takenHitFromTypeMaxHit (" Cold" )
351
- poolsRemaining = build . calcsTab . calcs . reducePoolsByDamage ( nil , takenDamages , build . calcsTab . calcsEnv . player )
352
- assert .are .equals (0 , round (poolsRemaining .Life ))
353
- assert .are .equals (0 , round (poolsRemaining .Mana ))
377
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Cold" )
378
+ assert . are . equals ( 0 , floor ( poolsRemaining . Mana ) )
379
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
380
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
354
381
355
382
build .configTab .input .customMods = " \z
356
383
+40 to maximum life\n\z
@@ -362,10 +389,33 @@ describe("TestDefence", function()
362
389
80% of cold damage taken as lightning damage\n\z
363
390
"
364
391
pob1and2Compat ()
365
- _ , takenDamages = takenHitFromTypeMaxHit (" Cold" )
366
- poolsRemaining = build .calcsTab .calcs .reducePoolsByDamage (nil , takenDamages , build .calcsTab .calcsEnv .player )
367
- assert .are .equals (0 , round (poolsRemaining .Life ))
392
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Cold" )
368
393
assert .are .not_false (1000 < round (poolsRemaining .Mana ))
394
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
395
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
396
+
397
+ build .configTab .input .customMods = " \z
398
+ +940 to maximum life\n\z
399
+ +950 to mana\n\z
400
+ +1000 to energy shield\n\z
401
+ +10000 to armour\n\z
402
+ +110% to all elemental resistances\n\z
403
+ Armour applies to Fire, Cold and Lightning Damage taken from Hits instead of Physical Damage\n\z
404
+ 100% of Lightning Damage is taken from Mana before Life\n\z
405
+ 80% of cold damage taken as lightning damage\n\z
406
+ 50% of fire damage taken as chaos damage\n\z
407
+ "
408
+ pob1and2Compat ()
409
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Cold" )
410
+ assert .are .equals (0 , floor (poolsRemaining .EnergyShield ))
411
+ assert .are .equals (0 , floor (poolsRemaining .Mana ))
412
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
413
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
414
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Fire" )
415
+ assert .are .equals (0 , floor (poolsRemaining .EnergyShield ))
416
+ assert .are .equals (1000 , floor (poolsRemaining .Mana ))
417
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
418
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
369
419
end )
370
420
371
421
it (" energy shield bypass tests #pet" , function ()
@@ -378,25 +428,102 @@ describe("TestDefence", function()
378
428
+60% to all resistances
379
429
]]
380
430
pob1and2Compat ()
431
+ local poolsRemaining = poolsRemainingAfterTypeMaxHit (" Chaos" )
432
+ assert .are .equals (100 , round (poolsRemaining .EnergyShield ))
433
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
434
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
381
435
assert .are .equals (200 , build .calcsTab .calcsOutput .FireMaximumHitTaken )
382
436
assert .are .equals (200 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
383
437
384
438
-- Make sure we can't reach over 100% bypass
385
439
build .configTab .input .customMods = [[
386
440
+40 to maximum life
387
441
+100 to energy shield
388
- 50% of chaos damage taken does not bypass energy shield
442
+ physical damage taken bypasses energy shield
389
443
You have no intelligence
390
444
+60% to all resistances
391
445
]]
392
446
pob1and2Compat ()
447
+ assert .are .equals (100 , build .calcsTab .calcsOutput .PhysicalMaximumHitTaken )
393
448
assert .are .equals (200 , build .calcsTab .calcsOutput .FireMaximumHitTaken )
394
449
assert .are .equals (150 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
450
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Physical" )
451
+ assert .are .equals (100 , floor (poolsRemaining .EnergyShield ))
452
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
453
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
454
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Chaos" )
455
+ assert .are .equals (0 , floor (poolsRemaining .EnergyShield ))
456
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
457
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
395
458
-- Chaos damage should still bypass
396
459
build .configTab .input .customMods = build .configTab .input .customMods .. " \n All damage taken bypasses energy shield"
397
460
build .configTab :BuildModList ()
398
461
runCallback (" OnFrame" )
462
+ assert .are .equals (100 , build .calcsTab .calcsOutput .PhysicalMaximumHitTaken )
399
463
assert .are .equals (100 , build .calcsTab .calcsOutput .FireMaximumHitTaken )
400
464
assert .are .equals (100 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
465
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Physical" )
466
+ assert .are .equals (100 , floor (poolsRemaining .EnergyShield ))
467
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
468
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
469
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Chaos" )
470
+ assert .are .equals (100 , round (poolsRemaining .EnergyShield ))
471
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
472
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
473
+
474
+ -- Bypass + MoM
475
+ build .configTab .input .customMods = [[
476
+ +40 to maximum life
477
+ +50 to mana
478
+ +200 to energy shield
479
+ 50% of damage taken bypasses energy shield
480
+ 50% of Lightning Damage is taken from Mana before Life
481
+ intelligence provides no bonus to energy shield
482
+ +60% to all resistances
483
+ ]]
484
+ pob1and2Compat ()
485
+ assert .are .equals (400 , build .calcsTab .calcsOutput .LightningMaximumHitTaken )
486
+ assert .are .equals (200 , build .calcsTab .calcsOutput .FireMaximumHitTaken )
487
+ assert .are .equals (200 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
488
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Chaos" )
489
+ assert .are .equals (0 , round (poolsRemaining .EnergyShield ))
490
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
491
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
492
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Fire" )
493
+ assert .are .equals (100 , round (poolsRemaining .EnergyShield ))
494
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
495
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
496
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Lightning" )
497
+ assert .are .equals (0 , round (poolsRemaining .EnergyShield ))
498
+ assert .are .equals (0 , floor (poolsRemaining .Mana ))
499
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
500
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
501
+
502
+ build .configTab .input .customMods = [[
503
+ +40 to maximum life
504
+ +150 to mana
505
+ +300 to energy shield
506
+ 50% of damage taken bypasses energy shield
507
+ 50% of Lightning Damage is taken from Mana before Life
508
+ intelligence provides no bonus to energy shield
509
+ +60% to all resistances
510
+ ]]
511
+ pob1and2Compat ()
512
+ assert .are .equals (400 , build .calcsTab .calcsOutput .LightningMaximumHitTaken )
513
+ assert .are .equals (200 , build .calcsTab .calcsOutput .FireMaximumHitTaken )
514
+ assert .are .equals (200 , build .calcsTab .calcsOutput .ChaosMaximumHitTaken )
515
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Chaos" )
516
+ assert .are .equals (100 , round (poolsRemaining .EnergyShield ))
517
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
518
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
519
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Fire" )
520
+ assert .are .equals (200 , round (poolsRemaining .EnergyShield ))
521
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
522
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
523
+ poolsRemaining = poolsRemainingAfterTypeMaxHit (" Lightning" )
524
+ assert .are .equals (100 , round (poolsRemaining .EnergyShield ))
525
+ assert .are .equals (100 , floor (poolsRemaining .Mana ))
526
+ assert .are .equals (0 , floor (poolsRemaining .Life ))
527
+ assert .are .equals (0 , floor (poolsRemaining .OverkillDamage ))
401
528
end )
402
529
end )
0 commit comments