kypvalanx / Foundry-VTT-StarWars-SagaEdition

25 stars 7 forks source link

[bug] Armored Defense Not Working #479

Closed ClassyCrow closed 2 months ago

ClassyCrow commented 3 months ago

The Armored Defense trait is not adding the armor bonus to reflex. I tried pulling the bonus settings from a character before most recent update, but it still didn't work.

kypvalanx commented 2 months ago

without armored defense the character should use the reflex bonus from the armor if they are wearing armor and proficient. with armored defense the character should use the higher bonus between the heroic level and the armor reflex bonus. with the improved armor defense bonus it should be heroic level bonus + 1/2 reflex bonus from armor rounded down.

i've added this test and it confirms that this is being calculated correctly.

                    it('should change how reflex defense is resolved when armored defense is detected', async function () {
                        await withTestActor(async actor => {
                            actor.suppressDialog = true
                            await actor.sheet._onDropItem(getMockEvent(), {name: "Soldier", type: "class"})
                            await actor.sheet._onDropItem(getMockEvent(), {name: "Soldier", type: "class"})
                            await actor.sheet._onDropItem(getMockEvent(), {name: "Soldier", type: "class"})
                            await actor.sheet._onDropItem(getMockEvent(), {name: "Soldier", type: "class"})

                            assert.equal(actor.system.defense.reflex.total, 15) //4 heroic levels +1 from soldier

                            await actor.sheet._onDropItem(getMockEvent(), {name: "Padded Flight Suit", type: "item", equip: true})

                            assert.equal(actor.system.defense.reflex.total, 14) //3 from armor + 1 from soldier

                            await actor.sheet._onDropItem(getMockEvent(), {name: "Armored Defense", type: "talent"})
                            assert.equal(actor.system.defense.reflex.total, 15)//4 heroic levels +1 from soldier
                            await actor.sheet._onDropItem(getMockEvent(), {name: "Improved Armored Defense", type: "talent"})
                            assert.equal(actor.system.defense.reflex.total, 16)//4 heroic levels +1 from soldier + floor(3/2)
                        });
                    });