22 lines
674 B
Kotlin
22 lines
674 B
Kotlin
package ru.dbotthepony.kstarbound.defs.npc
|
|
|
|
import com.google.common.collect.ImmutableMap
|
|
import it.unimi.dsi.fastutil.objects.Object2IntMap
|
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
|
import java.util.function.Predicate
|
|
|
|
@JsonFactory
|
|
data class TenantDefinition(
|
|
val name: String,
|
|
val colonyTagCriteria: ImmutableMap<String, Int>,
|
|
val priority: Double = 1.0
|
|
) : Predicate<Object2IntMap<String>>, Comparable<TenantDefinition> {
|
|
override fun test(t: Object2IntMap<String>): Boolean {
|
|
return colonyTagCriteria.all { t.getInt(it.key) >= it.value }
|
|
}
|
|
|
|
override fun compareTo(other: TenantDefinition): Int {
|
|
return priority.compareTo(other.priority)
|
|
}
|
|
}
|