From b518fa9849d528ae835cd1c8a61712b59e2adf29 Mon Sep 17 00:00:00 2001 From: Ziggy Date: Mon, 4 Jul 2022 02:23:14 +0200 Subject: [PATCH] Wrote a couple of automated tests for "Your modified Speed" to ensure it works as intended We were checking for weird behavior, but it seems to work like it should according to these tests --- .../objects/swg/weapon/WeaponObjectTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/java/com/projectswg/holocore/resources/support/objects/swg/weapon/WeaponObjectTest.java diff --git a/src/test/java/com/projectswg/holocore/resources/support/objects/swg/weapon/WeaponObjectTest.java b/src/test/java/com/projectswg/holocore/resources/support/objects/swg/weapon/WeaponObjectTest.java new file mode 100644 index 000000000..3f1d055e0 --- /dev/null +++ b/src/test/java/com/projectswg/holocore/resources/support/objects/swg/weapon/WeaponObjectTest.java @@ -0,0 +1,32 @@ +package com.projectswg.holocore.resources.support.objects.swg.weapon; + +import com.projectswg.holocore.resources.support.objects.ObjectCreator; +import com.projectswg.holocore.test.resources.GenericCreatureObject; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class WeaponObjectTest { + + @Test + public void yourModifiedAttackSpeedTakesPresentSpeedModsIntoAccount() { + WeaponObject weaponObject = (WeaponObject) ObjectCreator.createObjectFromTemplate("object/weapon/melee/unarmed/shared_unarmed_default_player.iff"); + weaponObject.setType(WeaponType.UNARMED); + weaponObject.setAttackSpeed(2.5f); + GenericCreatureObject genericCreatureObject = new GenericCreatureObject(1); + genericCreatureObject.adjustSkillmod("melee_speed", 0, 25); + genericCreatureObject.adjustSkillmod("unarmed_speed", 0, 25); + + assertEquals(1.25, weaponObject.getModdedWeaponAttackSpeedWithCap(genericCreatureObject), 0); + } + + @Test + public void yourModifiedAttackSpeedTakesMissingSpeedModsIntoAccount() { + WeaponObject weaponObject = (WeaponObject) ObjectCreator.createObjectFromTemplate("object/weapon/melee/unarmed/shared_unarmed_default_player.iff"); + weaponObject.setType(WeaponType.UNARMED); + weaponObject.setAttackSpeed(2.5f); + GenericCreatureObject genericCreatureObject = new GenericCreatureObject(1); + + assertEquals(2.5f, weaponObject.getModdedWeaponAttackSpeedWithCap(genericCreatureObject), 0); + } +} \ No newline at end of file