Removed lots of dead code

This commit is contained in:
Ceikry
2022-09-17 16:28:52 +00:00
parent f406b8aa98
commit d2283e6716
396 changed files with 1117 additions and 19344 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ object TestUtils {
}
fun advanceTicks(amount: Int, skipPulseUpdates: Boolean = true) {
SystemLogger.logInfo("Advancing ticks by $amount.")
SystemLogger.logInfo(this::class.java, "Advancing ticks by $amount.")
for(i in 0 until amount) {
GameWorld.majorUpdateWorker.handleTickActions(skipPulseUpdates)
}
+11 -10
View File
@@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test
import org.rs09.consts.Items
import rs09.game.content.global.action.EquipHandler
import rs09.game.interaction.InteractionListener
import rs09.game.interaction.IntType
import rs09.game.interaction.InteractionListeners
class EquipTests {
@@ -27,7 +28,7 @@ class EquipTests {
val p = TestUtils.getMockPlayer("bill")
p.inventory.add(Item(4151))
InteractionListeners.run(4151, InteractionListener.ITEM, "equip", p, p.inventory[0])
InteractionListeners.run(4151, IntType.ITEM, "equip", p, p.inventory[0])
Assertions.assertEquals(true, didRun)
}
@@ -61,7 +62,7 @@ class EquipTests {
p.equipment.replace(Item(4151), EquipmentSlot.WEAPON.ordinal)
p.inventory.add(Item(1333))
p.skills.staticLevels[Skills.ATTACK] = 40
InteractionListeners.run(1333, InteractionListener.ITEM, "equip", p, p.inventory[0])
InteractionListeners.run(1333, IntType.ITEM, "equip", p, p.inventory[0])
Assertions.assertEquals(true, didRun, p.equipment.toString())
}
@@ -73,7 +74,7 @@ class EquipTests {
p.inventory.add(Item(Items.BRONZE_DART_806, 1000))
p.inventory.add(Item(Items.RUNE_SCIMITAR_1333))
InteractionListeners.run(Items.RUNE_SCIMITAR_1333, InteractionListener.ITEM, "equip", p, p.inventory[1])
InteractionListeners.run(Items.RUNE_SCIMITAR_1333, IntType.ITEM, "equip", p, p.inventory[1])
Assertions.assertEquals(2000, p.inventory.getAmount(Items.BRONZE_DART_806), "\n" + p.inventory.toString() + "\n" + p.equipment.toString())
}
@@ -87,7 +88,7 @@ class EquipTests {
Assertions.assertEquals(1, p.inventory.freeSlots())
InteractionListeners.run(Items.BRONZE_2H_SWORD_1307, InteractionListener.ITEM, "equip", p, p.inventory[26])
InteractionListeners.run(Items.BRONZE_2H_SWORD_1307, IntType.ITEM, "equip", p, p.inventory[26])
Assertions.assertEquals(0, p.inventory.freeSlots())
Assertions.assertEquals(Items.BRONZE_SWORD_1277, p.inventory[26].id)
Assertions.assertEquals(Items.WOODEN_SHIELD_1171, p.inventory[27].id)
@@ -98,10 +99,10 @@ class EquipTests {
p.inventory.add(Item(Items.BRONZE_2H_SWORD_1307))
p.inventory.add(Item(Items.WOODEN_SHIELD_1171))
InteractionListeners.run(Items.BRONZE_2H_SWORD_1307, InteractionListener.ITEM, "equip", p, p.inventory[0])
InteractionListeners.run(Items.BRONZE_2H_SWORD_1307, IntType.ITEM, "equip", p, p.inventory[0])
Assertions.assertEquals(Items.BRONZE_2H_SWORD_1307, p.equipment.get(EquipmentSlot.WEAPON.ordinal).id)
InteractionListeners.run(Items.WOODEN_SHIELD_1171, InteractionListener.ITEM, "equip", p, p.inventory[1])
InteractionListeners.run(Items.WOODEN_SHIELD_1171, IntType.ITEM, "equip", p, p.inventory[1])
Assertions.assertEquals(Items.BRONZE_2H_SWORD_1307, p.inventory[1]?.id ?: -1)
}
@@ -110,10 +111,10 @@ class EquipTests {
p.inventory.add(Item(Items.BRONZE_SWORD_1277))
p.inventory.add(Item(Items.WOODEN_SHIELD_1171))
InteractionListeners.run(Items.BRONZE_SWORD_1277, InteractionListener.ITEM, "equip", p, p.inventory[0])
InteractionListeners.run(Items.BRONZE_SWORD_1277, IntType.ITEM, "equip", p, p.inventory[0])
Assertions.assertEquals(Items.BRONZE_SWORD_1277, p.equipment[EquipmentSlot.WEAPON.ordinal].id)
InteractionListeners.run(Items.WOODEN_SHIELD_1171, InteractionListener.ITEM, "equip", p, p.inventory[1])
InteractionListeners.run(Items.WOODEN_SHIELD_1171, IntType.ITEM, "equip", p, p.inventory[1])
Assertions.assertEquals(Items.BRONZE_SWORD_1277, p.equipment[EquipmentSlot.WEAPON.ordinal]?.id ?: -1)
}
@@ -122,7 +123,7 @@ class EquipTests {
p.equipment.replace(Item(Items.BRONZE_ARROW_882, 100), EquipmentSlot.AMMO.ordinal)
p.inventory.add(Item(Items.BRONZE_ARROW_882, 200))
InteractionListeners.run(Items.BRONZE_ARROW_882, InteractionListener.ITEM, "equip", p, p.inventory[0])
InteractionListeners.run(Items.BRONZE_ARROW_882, IntType.ITEM, "equip", p, p.inventory[0])
Assertions.assertEquals(300, p.equipment[EquipmentSlot.AMMO.ordinal].amount)
}
@@ -135,7 +136,7 @@ class EquipTests {
p.inventory.add(Item(Items.DRAGON_CLAWS_14484), true, 25)
Assertions.assertEquals(p.inventory.getSlot(Item(Items.DRAGON_CLAWS_14484)), 25)
InteractionListeners.run(Items.DRAGON_CLAWS_14484, InteractionListener.ITEM, "equip", p, p.inventory[25])
InteractionListeners.run(Items.DRAGON_CLAWS_14484, IntType.ITEM, "equip", p, p.inventory[25])
Assertions.assertEquals(Items.DRAGON_CLAWS_14484, p.equipment.get(EquipmentSlot.WEAPON.ordinal).id)
Assertions.assertEquals(p.inventory.getSlot(Item(Items.ABYSSAL_WHIP_4151)), 25)
Assertions.assertEquals(p.inventory.getSlot(Item(Items.RUNE_DEFENDER_8850)), 0)
@@ -0,0 +1,46 @@
package content
import TestUtils
import core.game.node.item.Item
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import rs09.game.interaction.InteractionListener
import rs09.game.interaction.IntType
import rs09.game.interaction.InteractionListeners
class ListenerTests : InteractionListener {
@Test fun doubleDefinedListenerShouldThrowIllegalStateException() {
on(0, IntType.ITEM, "touch") {_,_ -> return@on true}
Assertions.assertThrows(IllegalStateException::class.java) {
on(0, IntType.ITEM, "touch") {_,_ -> return@on true}
}
}
@Test fun doubleDefinedUseWithShouldThrowIllegalStateException() {
onUseWith(IntType.SCENERY, 0, 1) {_,_,_ -> return@onUseWith true}
Assertions.assertThrows(IllegalStateException::class.java) {
onUseWith(IntType.SCENERY, 0, 1) {_,_,_ -> return@onUseWith true}
}
}
@Test fun conflictingCatchallShouldThrowIllegalStateException() {
on(IntType.ITEM, "boop"){_,_ -> return@on true}
Assertions.assertThrows(IllegalStateException::class.java) {
on(IntType.ITEM, "boop") {_,_ -> return@on true}
}
}
@Test fun specificListenerShouldOverrideCatchallListener() {
var specificRan = false
var catchAllRan = false
on(IntType.ITEM, "zap") { _, _ -> catchAllRan = true; return@on true}
on(1, IntType.ITEM, "zap") {_,_ -> specificRan = true; return@on true}
InteractionListeners.run(1, IntType.ITEM, "zap", TestUtils.getMockPlayer("bilbots"), Item(1))
Assertions.assertEquals(false, catchAllRan)
Assertions.assertEquals(true, specificRan)
}
override fun defineListeners() {}
}
@@ -7,6 +7,7 @@ import core.game.world.map.RegionManager
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import rs09.game.interaction.InteractionListener
import rs09.game.interaction.IntType
import rs09.game.interaction.InteractionListeners
import rs09.game.node.entity.skill.gather.GatheringSkillOptionListeners
@@ -41,7 +42,7 @@ class PathfinderTests {
p.location = start
p.init()
Assertions.assertEquals(true, InteractionListeners.run(1307, InteractionListener.SCENERY, "chop-down", p, dest!!))
Assertions.assertEquals(true, InteractionListeners.run(1307, IntType.SCENERY, "chop-down", p, dest!!))
TestUtils.advanceTicks(20, false)
Assertions.assertEquals(Location.create(2722, 3475, 0), p.location)
}
@@ -23,9 +23,9 @@ class SQLStorageProviderTests {
}
@AfterAll @JvmStatic fun cleanup() {
SystemLogger.logInfo("Cleaning up unit test accounts")
SystemLogger.logInfo(this::class.java, "Cleaning up unit test accounts")
testAccountNames.forEach {name ->
SystemLogger.logInfo("Removing test account $name")
SystemLogger.logInfo(this::class.java, "Removing test account $name")
val info = UserAccountInfo.createDefault()
info.username = name
storage.remove(info)