Add unit tests for areas plugin

This commit is contained in:
Major
2018-08-20 21:46:15 +01:00
committed by Major-
parent 50d7e86302
commit 71158b3b5e
7 changed files with 179 additions and 112 deletions
+23
View File
@@ -0,0 +1,23 @@
import org.apollo.game.model.entity.Player
import org.apollo.game.model.event.impl.MobPositionUpdateEvent
import org.apollo.game.plugins.area.actions
/**
* Intercepts the [MobPositionUpdateEvent] and invokes area actions if necessary.
*/
on_event { MobPositionUpdateEvent::class }
.where { mob is Player }
.then {
for ((area, action) in actions) {
if (mob.position in area) {
if (next in area) {
action.inside(mob as Player, next)
} else {
action.exit(mob as Player, next)
}
} else if (next in area) {
action.entrance(mob as Player, next)
}
}
}