|
| 1 | +describe("MiscCalculator", function() |
| 2 | + before_each(function() |
| 3 | + newBuild() |
| 4 | + end) |
| 5 | + describe("repItem behaviour", function() |
| 6 | + local calcFunc |
| 7 | + before_each(function () |
| 8 | + calcFunc = build.calcsTab:GetMiscCalculator() |
| 9 | + end) |
| 10 | + |
| 11 | + local function pasteAndEquipItem(itemText) |
| 12 | + build.itemsTab:CreateDisplayItemFromRaw(itemText) |
| 13 | + build.itemsTab:AddDisplayItem() |
| 14 | + runCallback("OnFrame") |
| 15 | + end |
| 16 | + |
| 17 | + local function allocateKeystone(keystoneText) |
| 18 | + build.configTab.input.customMods = keystoneText |
| 19 | + build.configTab:BuildModList() |
| 20 | + runCallback("OnFrame") |
| 21 | + calcFunc = build.calcsTab:GetMiscCalculator() |
| 22 | + end |
| 23 | + |
| 24 | + local function equipInSlot(item, slotName) |
| 25 | + build.itemsTab:AddItem(item, true) |
| 26 | + build.itemsTab.slots[slotName]:SetSelItemId(item.id) |
| 27 | + runCallback("OnFrame") |
| 28 | + end |
| 29 | + local focus = [[Rarity: RARE |
| 30 | ++2 Energy Shield |
| 31 | +Hallowed Focus |
| 32 | +Energy Shield: 57 |
| 33 | +Crafted: true |
| 34 | +Prefix: {range:0.8}LocalIncreasedEnergyShield8 |
| 35 | +Prefix: {range:0.8}LocalIncreasedEnergyShieldPercent6 |
| 36 | +Prefix: None |
| 37 | +Suffix: {range:0.8}GlobalSpellGemsLevel2 |
| 38 | +Suffix: None |
| 39 | +Suffix: None |
| 40 | +Quality: 0 |
| 41 | +LevelReq: 61 |
| 42 | +Implicits: 0 |
| 43 | ++71 to maximum Energy Shield |
| 44 | +89% increased Energy Shield |
| 45 | ++2 to Level of all Spell Skills]] |
| 46 | + |
| 47 | + local quiver = [[Test Subject |
| 48 | +Rarity: Rare |
| 49 | +Toxic Quiver |
| 50 | +Crafted: true |
| 51 | +Implicits: 1 |
| 52 | ++100 to maximum energy shield]] |
| 53 | + |
| 54 | + local bow = new("Item", [[Rarity: Rare |
| 55 | +Test Subject |
| 56 | +Gemini Bow]]) |
| 57 | + |
| 58 | + local talisman = new("Item", [[Rarity: Rare |
| 59 | +Test Subject |
| 60 | +Spiny Talisman]]) |
| 61 | + |
| 62 | + local staff = new("Item", [[Rarity: Rare |
| 63 | +Test Subject |
| 64 | +Chiming Staff]]) |
| 65 | + |
| 66 | + local mace = new("Item", [[Rarity: Rare |
| 67 | +Test Subject |
| 68 | +Ironwood Greathammer]]) |
| 69 | + |
| 70 | + local sceptre = new("Item", [[Rarity: Rare |
| 71 | +Test Subject |
| 72 | +Rattling Sceptre |
| 73 | ++100 to maximum Energy Shield]]) |
| 74 | + local wand = new("Item", [[Rarity: Rare |
| 75 | +Test Subject |
| 76 | +Dueling Wand]]) |
| 77 | + it("calculates off-hand without a weapon", function () |
| 78 | + pasteAndEquipItem(focus) |
| 79 | + local output = calcFunc() |
| 80 | + assert.True(output.EnergyShield > 0) |
| 81 | + end) |
| 82 | + it("unequips the off-hand focus when replacing weapon 1 with two-handed weapons", function() |
| 83 | + pasteAndEquipItem(focus) |
| 84 | + for _, item in ipairs({ bow, talisman, staff, mace }) do |
| 85 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = item }) |
| 86 | + assert.True(output.EnergyShield == 0) |
| 87 | + end |
| 88 | + end) |
| 89 | + it("keeps the off-hand quiver when using bow", function() |
| 90 | + -- quivers need a bow to be equipped first |
| 91 | + pasteAndEquipItem(bow:BuildRaw()) |
| 92 | + pasteAndEquipItem(quiver) |
| 93 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = bow }) |
| 94 | + assert.True(output.EnergyShield > 0) |
| 95 | + end) |
| 96 | + it("keeps the off-hand focus when using a two-handed weapon with Giant's Blood", function() |
| 97 | + pasteAndEquipItem(focus) |
| 98 | + allocateKeystone("You can wield Two-Handed Axes, Maces and Swords in one hand") |
| 99 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = mace }) |
| 100 | + assert.True(output.EnergyShield > 0) |
| 101 | + end) |
| 102 | + it("keeps the off-hand focus when using a staff with Instruments of Power", function() |
| 103 | + pasteAndEquipItem(focus) |
| 104 | + allocateKeystone("You can equip a Focus while wielding a Staff") |
| 105 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = staff }) |
| 106 | + assert.True(output.EnergyShield > 0) |
| 107 | + end) |
| 108 | + it("keeps rare off-hand sceptre when using a talisman with Lord of the Wilds", function() |
| 109 | + equipInSlot(sceptre, "Weapon 2") |
| 110 | + allocateKeystone("You can equip a non-Unique Sceptre while wielding a Talisman") |
| 111 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = talisman }) |
| 112 | + assert.True(output.EnergyShield > 0) |
| 113 | + end) |
| 114 | + it("unequips unique off-hand sceptre when using a talisman with Lord of the Wilds", function() |
| 115 | + equipInSlot(new("Item", "Rarity: Unique\n" .. sceptre:BuildRaw()), "Weapon 2") |
| 116 | + allocateKeystone("You can equip a non-Unique Sceptre while wielding a Talisman") |
| 117 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = talisman }) |
| 118 | + assert.True(output.EnergyShield == 0) |
| 119 | + end) |
| 120 | + it("keeps off-hand when using one-handed weapon", function() |
| 121 | + pasteAndEquipItem(focus) |
| 122 | + local output = calcFunc({ repSlotName = "Weapon 1", repItem = wand }) |
| 123 | + assert.True(output.EnergyShield > 0) |
| 124 | + end) |
| 125 | + end) |
| 126 | +end) |
0 commit comments