diff --git a/src/main/kotlin/wotw/server/api/LeagueEndpoint.kt b/src/main/kotlin/wotw/server/api/LeagueEndpoint.kt index 941d19cd..87c16e9c 100644 --- a/src/main/kotlin/wotw/server/api/LeagueEndpoint.kt +++ b/src/main/kotlin/wotw/server/api/LeagueEndpoint.kt @@ -9,7 +9,6 @@ import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.utils.io.core.* import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.exists import org.jetbrains.exposed.sql.notExists import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction @@ -24,8 +23,6 @@ import wotw.server.game.handlers.league.LeagueGameHandler import wotw.server.main.WotwBackendServer import wotw.server.util.NTuple5 import wotw.server.util.then -import java.time.Instant -import java.time.temporal.ChronoUnit import kotlin.math.floor class LeagueEndpoint(server: WotwBackendServer) : Endpoint(server) { diff --git a/src/main/kotlin/wotw/server/api/StateAggregation.kt b/src/main/kotlin/wotw/server/api/StateAggregation.kt index 4c57292a..e44bd252 100644 --- a/src/main/kotlin/wotw/server/api/StateAggregation.kt +++ b/src/main/kotlin/wotw/server/api/StateAggregation.kt @@ -20,7 +20,7 @@ data class UberStateSyncStrategy(val aggregation: (old: Double, new: Double) -> val KEEP = UberStateSyncStrategy({ v, _ -> v }) val AVG = UberStateSyncStrategy({ o, n -> (o + n) / 2 }) - fun MAX_THRESHOLD(threshold: Double): UberStateSyncStrategy { + fun maxThreshold(threshold: Double): UberStateSyncStrategy { return UberStateSyncStrategy({ old, new -> min(MAX.aggregation(old, new), threshold) }) } } diff --git a/src/main/kotlin/wotw/server/bingo/GoalGenerator.kt b/src/main/kotlin/wotw/server/bingo/GoalGenerator.kt index 07ceeb16..9ca8336f 100644 --- a/src/main/kotlin/wotw/server/bingo/GoalGenerator.kt +++ b/src/main/kotlin/wotw/server/bingo/GoalGenerator.kt @@ -25,18 +25,18 @@ fun generatePool() = mutableListOf( ), nof( 3, - pickupsIn.marsh, - pickupsIn.hollow, - pickupsIn.glades, - pickupsIn.wellspring, - pickupsIn.burrows, - pickupsIn.woods, - pickupsIn.depths, - pickupsIn.pools, - pickupsIn.reach, - pickupsIn.wastes, - pickupsIn.willow, - pickupsIn.houses, + PickupsByArea.marsh, + PickupsByArea.hollow, + PickupsByArea.glades, + PickupsByArea.wellspring, + PickupsByArea.burrows, + PickupsByArea.woods, + PickupsByArea.depths, + PickupsByArea.pools, + PickupsByArea.reach, + PickupsByArea.wastes, + PickupsByArea.willow, + PickupsByArea.houses, ).weighted(300), bool("Spin the Wheel outside Luma Pools", 945, 12852), @@ -734,7 +734,7 @@ fun generatePool() = mutableListOf( bool("Woods Entrance", 58674, 7071), bool("Woods Exit", 58674, 1965), bool("Feeding Grounds", 58674, 10029), - bool("Wastes", 20120, 49994), + bool("Central Wastes", 20120, 49994), bool("Outer Ruins", 20120, 41398), bool("Willow's End", 16155, 41465), bool("Inner Ruins", 10289, 4928, countOnly = true), @@ -881,7 +881,7 @@ fun generatePool() = mutableListOf( ), ) -object pickupsIn { +object PickupsByArea { val marsh = group( "Collect # Pickups In Inkwater Marsh", threshold("MarshPastOpher.SpiritTrial", 44964, 45951, threshold = 2, hideValue = true), diff --git a/src/main/kotlin/wotw/server/database/EntityCache.kt b/src/main/kotlin/wotw/server/database/EntityCache.kt index b7c451e3..2e8f0966 100644 --- a/src/main/kotlin/wotw/server/database/EntityCache.kt +++ b/src/main/kotlin/wotw/server/database/EntityCache.kt @@ -45,7 +45,7 @@ open class EntityCache( return null } - suspend fun put(key: KEY, value: VALUE?) = CacheEntry(value, currentTimeMillis()).let { + fun put(key: KEY, value: VALUE?) = CacheEntry(value, currentTimeMillis()).let { cache[key] = it it.value } diff --git a/src/main/kotlin/wotw/server/database/model/BingothonToken.kt b/src/main/kotlin/wotw/server/database/model/BingothonToken.kt index 742ebe68..b5dc42e3 100644 --- a/src/main/kotlin/wotw/server/database/model/BingothonToken.kt +++ b/src/main/kotlin/wotw/server/database/model/BingothonToken.kt @@ -10,7 +10,7 @@ import wotw.server.database.StringIdTable object BingothonTokens : StringIdTable("bingothon_tokens") { val owner = reference("owner_id", Users, ReferenceOption.CASCADE, ReferenceOption.CASCADE).uniqueIndex() - val multiverseId = BingothonTokens.reference("multiverse_id", Multiverses, ReferenceOption.CASCADE) + val multiverseId = reference("multiverse_id", Multiverses, ReferenceOption.CASCADE) val created = datetime("created_at").defaultExpression(CurrentDateTime) } diff --git a/src/main/kotlin/wotw/server/database/model/SeedSpoilerDownload.kt b/src/main/kotlin/wotw/server/database/model/SeedSpoilerDownload.kt index e21f3bc3..f990895f 100644 --- a/src/main/kotlin/wotw/server/database/model/SeedSpoilerDownload.kt +++ b/src/main/kotlin/wotw/server/database/model/SeedSpoilerDownload.kt @@ -11,7 +11,7 @@ object SeedSpoilerDownloads : LongIdTable("seed_spoiler_downloads") { val playerId = reference("user_id", Users, ReferenceOption.CASCADE) init { - uniqueIndex(SeedSpoilerDownloads.seedId, SeedSpoilerDownloads.playerId) + uniqueIndex(seedId, playerId) } } diff --git a/src/main/kotlin/wotw/server/database/model/Spectator.kt b/src/main/kotlin/wotw/server/database/model/Spectator.kt index a3a29221..230e655f 100644 --- a/src/main/kotlin/wotw/server/database/model/Spectator.kt +++ b/src/main/kotlin/wotw/server/database/model/Spectator.kt @@ -11,7 +11,7 @@ object Spectators : LongIdTable("spectators") { val playerId = reference("user_id", Users, ReferenceOption.CASCADE) init { - uniqueIndex(Spectators.gameId, Spectators.playerId) + uniqueIndex(gameId, playerId) } } diff --git a/src/main/kotlin/wotw/server/database/model/Universe.kt b/src/main/kotlin/wotw/server/database/model/Universe.kt index 69a77fad..cb2bbd85 100644 --- a/src/main/kotlin/wotw/server/database/model/Universe.kt +++ b/src/main/kotlin/wotw/server/database/model/Universe.kt @@ -49,7 +49,8 @@ class World(id: EntityID) : LongEntity(id) { val gameState = GameState.new { this.multiverse = universe.multiverse this.universe = universe - val world = World.new { + + val world = new { this.universe = universe this.name = name this.seed = seed diff --git a/src/main/kotlin/wotw/server/game/GameHandlerRegistry.kt b/src/main/kotlin/wotw/server/game/GameHandlerRegistry.kt index f2a11efd..0aabc120 100644 --- a/src/main/kotlin/wotw/server/game/GameHandlerRegistry.kt +++ b/src/main/kotlin/wotw/server/game/GameHandlerRegistry.kt @@ -78,7 +78,7 @@ class GameHandlerRegistry(val server: WotwBackendServer) { return handler } - public fun purgeFromCache(multiverseId: Long) { + fun purgeFromCache(multiverseId: Long) { handlers.remove(multiverseId) } diff --git a/src/main/kotlin/wotw/server/game/handlers/NormalGameHandler.kt b/src/main/kotlin/wotw/server/game/handlers/NormalGameHandler.kt index d969a4ca..3c36d329 100644 --- a/src/main/kotlin/wotw/server/game/handlers/NormalGameHandler.kt +++ b/src/main/kotlin/wotw/server/game/handlers/NormalGameHandler.kt @@ -11,6 +11,7 @@ import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransacti import wotw.io.messages.json import wotw.io.messages.protobuf.* import wotw.server.api.* +import wotw.server.bingo.Point import wotw.server.bingo.UberStateMap import wotw.server.database.model.* import wotw.server.exception.ConflictException @@ -336,13 +337,13 @@ class NormalGameHandler(multiverseId: Long, server: WotwBackendServer) : GameHan this.finishedTime = finishedTime } - multiverse.universes.forEach() { universe -> + multiverse.universes.forEach { universe -> val team = RaceTeam.new { this.race = race this.finishedTime = state.universeFinishedTimes[universe.id.value] } - universe.memberships.forEach() { worldMembership -> + universe.memberships.forEach { worldMembership -> RaceTeamMember.new { this.raceTeam = team this.user = worldMembership.user diff --git a/src/main/kotlin/wotw/server/game/handlers/league/LeagueManager.kt b/src/main/kotlin/wotw/server/game/handlers/league/LeagueManager.kt index e9445530..fe1a3d93 100644 --- a/src/main/kotlin/wotw/server/game/handlers/league/LeagueManager.kt +++ b/src/main/kotlin/wotw/server/game/handlers/league/LeagueManager.kt @@ -7,7 +7,6 @@ import dev.kord.common.entity.optional.Optional import dev.kord.common.entity.optional.OptionalBoolean import dev.kord.core.Kord import dev.kord.rest.builder.component.ActionRowBuilder -import dev.kord.rest.builder.message.AttachmentBuilder import dev.kord.rest.builder.message.addFile import dev.kord.rest.builder.message.allowedMentions import dev.kord.rest.builder.message.embed @@ -31,7 +30,6 @@ import wotw.server.util.logger import java.time.Duration import java.time.Instant import java.util.concurrent.TimeUnit -import kotlin.io.path.Path /** @@ -177,7 +175,7 @@ class LeagueManager(val server: WotwBackendServer) { } } - suspend fun setup() { + fun setup() { scheduler.scheduleExecution(Every(60, TimeUnit.SECONDS)) /* diff --git a/src/main/kotlin/wotw/server/game/inventory/WorldInventory.kt b/src/main/kotlin/wotw/server/game/inventory/WorldInventory.kt index e49e894d..79f53ffd 100644 --- a/src/main/kotlin/wotw/server/game/inventory/WorldInventory.kt +++ b/src/main/kotlin/wotw/server/game/inventory/WorldInventory.kt @@ -24,7 +24,7 @@ class WorldInventory(private val gameState: GameState) { gameState.uberStateData[target.uberId] = target.value } - var value = request.amount.toDouble(); + var value = request.amount.toDouble() if (request.relative) { value += gameState.uberStateData[request.resourceUberId] ?: 0.0 } diff --git a/src/main/kotlin/wotw/server/io/ClientConnection.kt b/src/main/kotlin/wotw/server/io/ClientConnection.kt index 4365da39..6e15d950 100644 --- a/src/main/kotlin/wotw/server/io/ClientConnection.kt +++ b/src/main/kotlin/wotw/server/io/ClientConnection.kt @@ -8,7 +8,7 @@ import io.ktor.network.sockets.* import io.ktor.server.auth.jwt.* import io.ktor.server.websocket.* import io.ktor.utils.io.core.* -import io.ktor.utils.io.errors.* +import io.ktor.utils.io.errors.IOException import io.ktor.websocket.* import kotlinx.coroutines.channels.ClosedReceiveChannelException import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction @@ -31,7 +31,7 @@ fun DecodedJWT.parsePayload(): Payload { class ClientConnectionUDPRegistry() { companion object { - private val availableUdpIDs = HashSet((0..65535).toList()); + private val availableUdpIDs = HashSet((0..65535).toList()) private val connections: HashMap = hashMapOf() fun register(connection: ClientConnection): Int { diff --git a/src/main/kotlin/wotw/server/main/WotwBackendServer.kt b/src/main/kotlin/wotw/server/main/WotwBackendServer.kt index 5c8e3557..c1c24274 100644 --- a/src/main/kotlin/wotw/server/main/WotwBackendServer.kt +++ b/src/main/kotlin/wotw/server/main/WotwBackendServer.kt @@ -76,7 +76,7 @@ class WotwBackendServer { if (System.getenv("SENTRY_DSN") != null) { Sentry.init { options -> options.dsn = System.getenv("SENTRY_DSN") - options.setEnableUncaughtExceptionHandler(false) + options.isEnableUncaughtExceptionHandler = false } Thread.setDefaultUncaughtExceptionHandler { _, throwable -> diff --git a/src/main/kotlin/wotw/server/services/InfoMessagesService.kt b/src/main/kotlin/wotw/server/services/InfoMessagesService.kt index 129c134e..0ee419c0 100644 --- a/src/main/kotlin/wotw/server/services/InfoMessagesService.kt +++ b/src/main/kotlin/wotw/server/services/InfoMessagesService.kt @@ -6,7 +6,7 @@ import wotw.server.game.handlers.league.LeagueGameHandler import wotw.server.main.WotwBackendServer class InfoMessagesService(private val server: WotwBackendServer) { - val COLORS = arrayOf( + val colors = arrayOf( "#1565c0", "#388e3c", "#ad1457", @@ -46,7 +46,7 @@ class InfoMessagesService(private val server: WotwBackendServer) { suspend fun generateMultiverseInfoMessage(multiverse: Multiverse) = MultiverseInfoMessage( multiverse.id.value, multiverse.universes.sortedBy { it.id } - .mapIndexed { index, universe -> generateUniverseInfo(universe, COLORS[index % COLORS.size]) }, + .mapIndexed { index, universe -> generateUniverseInfo(universe, colors[index % colors.size]) }, multiverse.cachedBoard != null, multiverse.spectators.map(::generateUserInfo), multiverse.seed?.takeIf { it.allowDownload }?.id?.value, @@ -63,9 +63,9 @@ class InfoMessagesService(private val server: WotwBackendServer) { fun generateUniverseInfo(universe: Universe, color: String? = null) = UniverseInfo( universe.id.value, universe.name, - color ?: COLORS[universe.multiverse.universes.sortedBy { it.id }.indexOf(universe) % COLORS.size], + color ?: colors[universe.multiverse.universes.sortedBy { it.id }.indexOf(universe) % colors.size], universe.worlds.sortedBy { it.id }.mapIndexed { index, world -> - generateWorldInfo(world, COLORS[index % COLORS.size]) + generateWorldInfo(world, colors[index % colors.size]) } ) @@ -79,7 +79,7 @@ class InfoMessagesService(private val server: WotwBackendServer) { WorldInfo( world.id.value, world.name, - color ?: COLORS[world.universe.worlds.sortedBy { it.id }.indexOf(world) % COLORS.size], + color ?: colors[world.universe.worlds.sortedBy { it.id }.indexOf(world) % colors.size], world.memberships.map(::generateWorldMembershipInfo), world.seed?.id?.value, ) diff --git a/src/main/kotlin/wotw/server/sync/CoopStates.kt b/src/main/kotlin/wotw/server/sync/CoopStates.kt index b2a2d36a..3308231f 100644 --- a/src/main/kotlin/wotw/server/sync/CoopStates.kt +++ b/src/main/kotlin/wotw/server/sync/CoopStates.kt @@ -1762,7 +1762,7 @@ val normalWorldSyncAggregationStrategy by lazy { /// Quests // TODO: Add all quests here - sync(14019, 33776).with(UberStateSyncStrategy.MAX_THRESHOLD(3.0)), // Acorn Quest + sync(14019, 33776).with(UberStateSyncStrategy.maxThreshold(3.0)), // Acorn Quest ) } } diff --git a/src/main/kotlin/wotw/server/util/MultiverseUtil.kt b/src/main/kotlin/wotw/server/util/MultiverseUtil.kt index 8a5e35d3..8d8a37e4 100644 --- a/src/main/kotlin/wotw/server/util/MultiverseUtil.kt +++ b/src/main/kotlin/wotw/server/util/MultiverseUtil.kt @@ -38,7 +38,7 @@ class MultiverseUtil(val server: WotwBackendServer) { server.connections.broadcastMultiverseInfoMessage(worldMembership.multiverse) } - suspend fun movePlayerToWorld(player: User, world: World): WorldMembership { + fun movePlayerToWorld(player: User, world: World): WorldMembership { var worldMembership = WorldMembership.find { (WorldMemberships.userId eq player.id) and (WorldMemberships.multiverseId eq world.universe.multiverse.id) }.firstOrNull()