package ru.dbotthepony.kstarbound.defs import com.google.common.collect.ImmutableList import ru.dbotthepony.kstarbound.defs.world.FloatingDungeonWorldParameters import ru.dbotthepony.kstarbound.defs.world.TerrestrialWorldParameters import ru.dbotthepony.kstarbound.defs.world.VisitableWorldParameters import ru.dbotthepony.kstarbound.json.builder.JsonFactory import java.util.function.Predicate @JsonFactory data class UniverseServerConfig( // in milliseconds val clockUpdatePacketInterval: Long = 500L, val findStarterWorldParameters: StarterWorld, val queuedFlightWaitTime: Double = 0.0, val useNewWireProcessing: Boolean = true, ) { @JsonFactory data class WorldPredicate( val terrestrialBiome: String? = null, val terrestrialSize: String? = null, val floatingDungeon: String? = null, ) : Predicate { override fun test(t: VisitableWorldParameters): Boolean { if (terrestrialBiome != null) { if (t !is TerrestrialWorldParameters) return false if (t.primaryBiome != terrestrialBiome) return false } if (terrestrialSize != null) { if (t !is TerrestrialWorldParameters) return false if (t.sizeName != terrestrialSize) return false } if (floatingDungeon != null) { if (t !is FloatingDungeonWorldParameters) return false if (t.primaryDungeon.key.left() != floatingDungeon) return false } return true } } @JsonFactory data class StarterWorld( val tries: Int, val range: Int, val starterWorld: WorldPredicate, val requiredSystemWorlds: ImmutableList = ImmutableList.of(), ) }