Fixed regression causing random events to trigger for bots
This commit is contained in:
@@ -37,7 +37,7 @@ class AntiMacro : PersistTimer(0, "antimacro", isAuto = true), Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onRegister(entity: Entity) {
|
override fun onRegister(entity: Entity) {
|
||||||
if (entity !is Player)
|
if (entity !is Player || entity.isArtificial)
|
||||||
entity.timers.removeTimer(this)
|
entity.timers.removeTimer(this)
|
||||||
|
|
||||||
if (runInterval == 0)
|
if (runInterval == 0)
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ object TestUtils {
|
|||||||
var uidCounter = 0
|
var uidCounter = 0
|
||||||
const val PLAYER_DEATH_TICKS = 14
|
const val PLAYER_DEATH_TICKS = 14
|
||||||
|
|
||||||
fun getMockPlayer(name: String, ironman: IronmanMode = IronmanMode.NONE, rights: Rights = Rights.ADMINISTRATOR): MockPlayer {
|
fun getMockPlayer(name: String, ironman: IronmanMode = IronmanMode.NONE, rights: Rights = Rights.ADMINISTRATOR, isBot: Boolean = false): MockPlayer {
|
||||||
val p = MockPlayer(name)
|
val p = MockPlayer(name, isBot)
|
||||||
p.ironmanManager.mode = ironman
|
p.ironmanManager.mode = ironman
|
||||||
p.details.accountInfo.uid = uidCounter++
|
p.details.accountInfo.uid = uidCounter++
|
||||||
p.setPlaying(true);
|
p.setPlaying(true);
|
||||||
@@ -114,7 +114,7 @@ object TestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockPlayer(name: String) : Player(PlayerDetails(name)), AutoCloseable {
|
class MockPlayer(name: String, val isBot: Boolean) : Player(PlayerDetails(name)), AutoCloseable {
|
||||||
var hasInit = false
|
var hasInit = false
|
||||||
init { configureBasicProperties(); flagTutComplete(false); init(); flagTutComplete(true) }
|
init { configureBasicProperties(); flagTutComplete(false); init(); flagTutComplete(true) }
|
||||||
|
|
||||||
@@ -122,6 +122,7 @@ class MockPlayer(name: String) : Player(PlayerDetails(name)), AutoCloseable {
|
|||||||
this.details.session = MockSession()
|
this.details.session = MockSession()
|
||||||
this.location = ServerConstants.HOME_LOCATION
|
this.location = ServerConstants.HOME_LOCATION
|
||||||
this.properties.attackStyle = WeaponInterface.AttackStyle(0, WeaponInterface.BONUS_CRUSH)
|
this.properties.attackStyle = WeaponInterface.AttackStyle(0, WeaponInterface.BONUS_CRUSH)
|
||||||
|
this.artificial = isBot
|
||||||
}
|
}
|
||||||
|
|
||||||
fun flagTutComplete(complete: Boolean) {
|
fun flagTutComplete(complete: Boolean) {
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ class RandomEventTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun shouldNotSpawnForArtificialPlayer() {
|
||||||
|
TestUtils.getMockPlayer("antimacroshouldspawnrandom", isBot = true).use {p ->
|
||||||
|
val timer = getTimer<AntiMacro>(p)
|
||||||
|
Assertions.assertEquals(null, timer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun teleportAndNotePunishmentShouldNotAffectAlreadyNotedItems() {
|
@Test fun teleportAndNotePunishmentShouldNotAffectAlreadyNotedItems() {
|
||||||
TestUtils.getMockPlayer("teleportpunishment1").use {p ->
|
TestUtils.getMockPlayer("teleportpunishment1").use {p ->
|
||||||
val timer = getTimer<AntiMacro>(p) ?: Assertions.fail("AntiMacro timer is null!")
|
val timer = getTimer<AntiMacro>(p) ?: Assertions.fail("AntiMacro timer is null!")
|
||||||
|
|||||||
Reference in New Issue
Block a user