mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Add unit tests for areas plugin
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package org.apollo.game.plugins.area
|
||||
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.plugins.api.Position.component1
|
||||
import org.apollo.game.plugins.api.Position.component2
|
||||
import org.apollo.game.plugins.api.Position.component3
|
||||
|
||||
/**
|
||||
* An area in the game world.
|
||||
*/
|
||||
interface Area {
|
||||
|
||||
/**
|
||||
* Returns whether or not the specified [Position] is inside this [Area].
|
||||
*/
|
||||
operator fun contains(position: Position): Boolean
|
||||
|
||||
}
|
||||
|
||||
internal class RectangularArea(private val x: IntRange, private val y: IntRange, private val height: Int) : Area {
|
||||
|
||||
override operator fun contains(position: Position): Boolean {
|
||||
val (x, y, z) = position
|
||||
return x in this.x && y in this.y && z == height
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user