move from schema2 to schema
This commit is contained in:
parent
6bfcd30558
commit
b0a6151c36
30 changed files with 256 additions and 318 deletions
|
|
@ -1,16 +1,16 @@
|
|||
package dev.adamko.kafkatorio.schema2
|
||||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class KafkatorioPacket2(
|
||||
data class KafkatorioPacket(
|
||||
val modVersion: String,
|
||||
val tick: Tick,
|
||||
val data: KafkatorioPacketData2,
|
||||
val data: KafkatorioPacketData,
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
sealed class KafkatorioPacketData2
|
||||
sealed class KafkatorioPacketData
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package dev.adamko.kafkatorio.schema2
|
||||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
/** No key, no caching. Must be sent instantly. */
|
||||
@Serializable
|
||||
sealed class KafkatorioInstantPacketData2 : KafkatorioPacketData2()
|
||||
sealed class KafkatorioInstantPacketData : KafkatorioPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -20,7 +20,7 @@ data class ConfigurationUpdate(
|
|||
val allMods: List<ConfigurationUpdateModData>,
|
||||
val modStartupSettingsChange: Boolean,
|
||||
val migrationApplied: Boolean,
|
||||
) : KafkatorioInstantPacketData2() {
|
||||
) : KafkatorioInstantPacketData() {
|
||||
|
||||
@Serializable
|
||||
data class ConfigurationUpdateGameData(
|
||||
|
|
@ -41,7 +41,7 @@ data class ConfigurationUpdate(
|
|||
data class ConsoleChatUpdate(
|
||||
val authorPlayerIndex: PlayerIndex?,
|
||||
val content: String,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
@Serializable
|
||||
|
|
@ -49,13 +49,13 @@ data class ConsoleCommandUpdate(
|
|||
val authorPlayerIndex: PlayerIndex?,
|
||||
val command: String,
|
||||
val parameters: String,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
@Serializable
|
||||
data class PrototypesUpdate(
|
||||
val prototypes: List<FactorioPrototype2>,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
val prototypes: List<FactorioPrototype>,
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
@Serializable
|
||||
|
|
@ -63,7 +63,7 @@ data class SurfaceUpdate(
|
|||
val index: SurfaceIndex,
|
||||
val daytime: Double,
|
||||
val name: String,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.adamko.kafkatorio.schema2
|
||||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.Colour
|
||||
import dev.adamko.kafkatorio.schema.common.EntityIdentifiers
|
||||
|
|
@ -17,7 +17,7 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
/** Has a key, so it can be debounced */
|
||||
@Serializable
|
||||
sealed class KafkatorioKeyedPacketData2 : KafkatorioPacketData2() {
|
||||
sealed class KafkatorioKeyedPacketData : KafkatorioPacketData() {
|
||||
/** Count how many events this packet is aggregating data from */
|
||||
abstract val key: KafkatorioKeyedPacketKey2
|
||||
abstract val eventCounts: Map<String, UInt>?
|
||||
|
|
@ -54,7 +54,7 @@ data class EntityUpdate(
|
|||
val localisedDescription: String? = null,
|
||||
val localisedName: String? = null,
|
||||
val prototype: PrototypeName? = null,
|
||||
) : KafkatorioKeyedPacketData2()
|
||||
) : KafkatorioKeyedPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -79,7 +79,7 @@ data class MapChunkUpdate(
|
|||
/** updated tiles - might be partial and not all tiles in the chunk */
|
||||
val tileDictionary: MapTileDictionary? = null,
|
||||
val isDeleted: Boolean? = null,
|
||||
) : KafkatorioKeyedPacketData2()
|
||||
) : KafkatorioKeyedPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -120,7 +120,7 @@ data class PlayerUpdate(
|
|||
val disconnectReason: String? = null,
|
||||
/** `true` when a player is removed (deleted) from the game */
|
||||
val isRemoved: Boolean? = null,
|
||||
) : KafkatorioKeyedPacketData2()
|
||||
) : KafkatorioKeyedPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
|
||||
@Serializable
|
||||
sealed class FactorioPrototype2 {
|
||||
sealed class FactorioPrototype {
|
||||
|
||||
@Serializable
|
||||
data class MapTile(
|
||||
|
|
@ -19,5 +19,5 @@ sealed class FactorioPrototype2 {
|
|||
val order: String,
|
||||
/** Can the tile be mined for resources? */
|
||||
val canBeMined: Boolean,
|
||||
) : FactorioPrototype2()
|
||||
) : FactorioPrototype()
|
||||
}
|
||||
|
|
@ -6,14 +6,12 @@ import dev.adamko.kafkatorio.schema.common.PrototypeName
|
|||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdateKey
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdateKey
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.shouldBe
|
||||
import kotlin.math.exp
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
||||
class MapChunkUpdateTest : FunSpec({
|
||||
|
||||
|
|
@ -22,7 +20,7 @@ class MapChunkUpdateTest : FunSpec({
|
|||
val json = """
|
||||
{
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.MapChunkUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.MapChunkUpdate",
|
||||
"key": {
|
||||
"surfaceIndex": 1,
|
||||
"chunkPosition": [
|
||||
|
|
@ -57,7 +55,7 @@ class MapChunkUpdateTest : FunSpec({
|
|||
}
|
||||
""".trimIndent()
|
||||
|
||||
val expected = KafkatorioPacket2(
|
||||
val expected = KafkatorioPacket(
|
||||
tick = Tick(36u),
|
||||
modVersion = "0.4.0",
|
||||
data = MapChunkUpdate(
|
||||
|
|
@ -86,7 +84,7 @@ class MapChunkUpdateTest : FunSpec({
|
|||
)
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
packet shouldBe expected
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package dev.adamko.kafkatorio.events.schema
|
|||
import dev.adamko.kafkatorio.schema.common.Colour
|
||||
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import io.kotest.core.spec.style.BehaviorSpec
|
||||
import io.kotest.inspectors.forOne
|
||||
import io.kotest.matchers.shouldBe
|
||||
|
|
@ -20,10 +20,10 @@ class PrototypesTest : BehaviorSpec({
|
|||
"modVersion": "0.2.4",
|
||||
"tick": 534,
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PrototypesUpdate",
|
||||
"prototypes": [
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "tile-unknown",
|
||||
"order": "z-a",
|
||||
"layer": 0,
|
||||
|
|
@ -37,7 +37,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
""".trimIndent()
|
||||
|
||||
Then("expect can be parsed") {
|
||||
val data = jsonMapperKafkatorio.decodeFromString<KafkatorioPacket2>(raw)
|
||||
val data = jsonMapperKafkatorio.decodeFromString<KafkatorioPacket>(raw)
|
||||
println(data)
|
||||
}
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ class PrototypesTest : BehaviorSpec({
|
|||
"modVersion": "0.3.2",
|
||||
"tick": 534,
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PrototypesUpdate",
|
||||
"prototypes": [
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "stone-path",
|
||||
"order": "a[artificial]-a[tier-1]-a[stone-path]",
|
||||
"layer": 60,
|
||||
|
|
@ -64,7 +64,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "concrete",
|
||||
"order": "a[artificial]-b[tier-2]-a[concrete]",
|
||||
"layer": 61,
|
||||
|
|
@ -75,7 +75,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "hazard-concrete-left",
|
||||
"order": "a[artificial]-b[tier-2]-b[hazard-concrete-left]",
|
||||
"layer": 62,
|
||||
|
|
@ -86,7 +86,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "hazard-concrete-right",
|
||||
"order": "a[artificial]-b[tier-2]-c[hazard-concrete-right]",
|
||||
"layer": 62,
|
||||
|
|
@ -97,7 +97,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "refined-concrete",
|
||||
"order": "a[artificial]-c[tier-3]-a[refined-concrete]",
|
||||
"layer": 64,
|
||||
|
|
@ -108,7 +108,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "refined-hazard-concrete-left",
|
||||
"order": "a[artificial]-c[tier-3]-b[refined-hazard-concrete-left]",
|
||||
"layer": 65,
|
||||
|
|
@ -119,7 +119,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "refined-hazard-concrete-right",
|
||||
"order": "a[artificial]-c[tier-3]-c[refined-hazard-concrete-right]",
|
||||
"layer": 65,
|
||||
|
|
@ -130,7 +130,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "landfill",
|
||||
"order": "a[artificial]-d[utility]-a[landfill]",
|
||||
"layer": 57,
|
||||
|
|
@ -141,7 +141,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "acid-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-acid",
|
||||
"layer": 97,
|
||||
|
|
@ -152,7 +152,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "black-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-black",
|
||||
"layer": 88,
|
||||
|
|
@ -163,7 +163,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "blue-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-blue",
|
||||
"layer": 73,
|
||||
|
|
@ -174,7 +174,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "brown-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-brown",
|
||||
"layer": 91,
|
||||
|
|
@ -185,7 +185,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "cyan-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-cyan",
|
||||
"layer": 94,
|
||||
|
|
@ -196,7 +196,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "green-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-green",
|
||||
"layer": 70,
|
||||
|
|
@ -207,7 +207,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "orange-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-orange",
|
||||
"layer": 76,
|
||||
|
|
@ -218,7 +218,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "pink-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-pink",
|
||||
"layer": 82,
|
||||
|
|
@ -229,7 +229,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "purple-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-purple",
|
||||
"layer": 85,
|
||||
|
|
@ -240,7 +240,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-red",
|
||||
"layer": 67,
|
||||
|
|
@ -251,7 +251,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "yellow-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-yellow",
|
||||
"layer": 79,
|
||||
|
|
@ -262,7 +262,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-1",
|
||||
"order": "b[natural]-a[grass]-a[grass-1]",
|
||||
"layer": 26,
|
||||
|
|
@ -273,7 +273,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-2",
|
||||
"order": "b[natural]-a[grass]-b[grass-2]",
|
||||
"layer": 28,
|
||||
|
|
@ -284,7 +284,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-3",
|
||||
"order": "b[natural]-a[grass]-c[grass-3]",
|
||||
"layer": 29,
|
||||
|
|
@ -295,7 +295,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-4",
|
||||
"order": "b[natural]-a[grass]-d[grass-4]",
|
||||
"layer": 30,
|
||||
|
|
@ -306,7 +306,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dry-dirt",
|
||||
"order": "b[natural]-b[dirt]-a[dry-dirt]",
|
||||
"layer": 18,
|
||||
|
|
@ -317,7 +317,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-1",
|
||||
"order": "b[natural]-b[dirt]-b[dirt-1]",
|
||||
"layer": 19,
|
||||
|
|
@ -328,7 +328,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-2",
|
||||
"order": "b[natural]-b[dirt]-c[dirt-2]",
|
||||
"layer": 20,
|
||||
|
|
@ -339,7 +339,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-3",
|
||||
"order": "b[natural]-b[dirt]-d[dirt-3]",
|
||||
"layer": 21,
|
||||
|
|
@ -350,7 +350,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-4",
|
||||
"order": "b[natural]-b[dirt]-e[dirt-4]",
|
||||
"layer": 22,
|
||||
|
|
@ -361,7 +361,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-5",
|
||||
"order": "b[natural]-b[dirt]-f[dirt-5]",
|
||||
"layer": 23,
|
||||
|
|
@ -372,7 +372,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-6",
|
||||
"order": "b[natural]-b[dirt]-g[dirt-6]",
|
||||
"layer": 24,
|
||||
|
|
@ -383,7 +383,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-7",
|
||||
"order": "b[natural]-b[dirt]-h[dirt-7]",
|
||||
"layer": 25,
|
||||
|
|
@ -394,7 +394,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "sand-1",
|
||||
"order": "b[natural]-c[sand]-a[sand-1]",
|
||||
"layer": 8,
|
||||
|
|
@ -405,7 +405,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "sand-2",
|
||||
"order": "b[natural]-c[sand]-b[sand-2]",
|
||||
"layer": 9,
|
||||
|
|
@ -416,7 +416,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "sand-3",
|
||||
"order": "b[natural]-c[sand]-c[sand-3]",
|
||||
"layer": 10,
|
||||
|
|
@ -427,7 +427,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-0",
|
||||
"order": "b[natural]-d[red-desert]-a[red-desert-0]",
|
||||
"layer": 31,
|
||||
|
|
@ -438,7 +438,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-1",
|
||||
"order": "b[natural]-d[red-desert]-b[red-desert-1]",
|
||||
"layer": 14,
|
||||
|
|
@ -449,7 +449,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-2",
|
||||
"order": "b[natural]-d[red-desert]-c[red-desert-2]",
|
||||
"layer": 15,
|
||||
|
|
@ -460,7 +460,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-3",
|
||||
"order": "b[natural]-d[red-desert]-d[red-desert-3]",
|
||||
"layer": 16,
|
||||
|
|
@ -471,7 +471,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water",
|
||||
"order": "c[water]-a[water]",
|
||||
"layer": 3,
|
||||
|
|
@ -486,7 +486,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "deepwater",
|
||||
"order": "c[water]-b[deep-water]",
|
||||
"layer": 3,
|
||||
|
|
@ -501,7 +501,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-green",
|
||||
"order": "c[water]-c[water-green]",
|
||||
"layer": 3,
|
||||
|
|
@ -516,7 +516,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "deepwater-green",
|
||||
"order": "c[water]-d[deepwater-green]",
|
||||
"layer": 3,
|
||||
|
|
@ -531,7 +531,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-shallow",
|
||||
"order": "c[water]-e[water-shallow]",
|
||||
"layer": 6,
|
||||
|
|
@ -545,7 +545,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-mud",
|
||||
"order": "c[water]-g[water-mud]",
|
||||
"layer": 7,
|
||||
|
|
@ -559,7 +559,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "nuclear-ground",
|
||||
"order": "d[destruction]-a[nuclear]-a[nuclear-ground]",
|
||||
"layer": 33,
|
||||
|
|
@ -570,7 +570,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-wube",
|
||||
"order": "x[wube]-a[water-wube]",
|
||||
"layer": 2,
|
||||
|
|
@ -585,7 +585,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "tile-unknown",
|
||||
"order": "z-a",
|
||||
"layer": 0,
|
||||
|
|
@ -595,7 +595,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "out-of-map",
|
||||
"order": "z[other]-a[out-of-map]",
|
||||
"layer": 0,
|
||||
|
|
@ -613,7 +613,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "lab-dark-1",
|
||||
"order": "z[other]-b[lab]-a[lab-dark-1]",
|
||||
"layer": 70,
|
||||
|
|
@ -624,7 +624,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "lab-dark-2",
|
||||
"order": "z[other]-b[lab]-b[lab-dark-2]",
|
||||
"layer": 70,
|
||||
|
|
@ -635,7 +635,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "lab-white",
|
||||
"order": "z[other]-b[lab]-c[lab-white]",
|
||||
"layer": 70,
|
||||
|
|
@ -646,7 +646,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "tutorial-grid",
|
||||
"order": "z[other]-c[tutorial]-a[tutorial-grid]",
|
||||
"layer": 55,
|
||||
|
|
@ -662,13 +662,13 @@ class PrototypesTest : BehaviorSpec({
|
|||
""".trimIndent()
|
||||
|
||||
Then("expect can be parsed") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(raw)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(raw)
|
||||
// println(packet)
|
||||
|
||||
packet.data.shouldBeInstanceOf<PrototypesUpdate>()
|
||||
.prototypes
|
||||
.forOne {
|
||||
it.shouldBeInstanceOf<FactorioPrototype2.MapTile>()
|
||||
it.shouldBeInstanceOf<FactorioPrototype.MapTile>()
|
||||
it.name shouldBe PrototypeName("tutorial-grid")
|
||||
it.order shouldBe "z[other]-c[tutorial]-a[tutorial-grid]"
|
||||
it.layer shouldBe 55u
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
|||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import dev.adamko.kafkatorio.schema.common.UnitNumber
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdateKey
|
||||
import dev.adamko.kafkatorio.schema2.SurfaceUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdateKey
|
||||
import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.shouldBe
|
||||
import kotlinx.serialization.decodeFromString
|
||||
|
|
@ -27,7 +27,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
"tick": 66,
|
||||
"modVersion": "0.3.2",
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
"key": {"index": 1},
|
||||
"afkTime": 0,
|
||||
"chatColour": [1, 0.4, 0.6, 1],
|
||||
|
|
@ -54,9 +54,9 @@ class UpdatePacketsTest : FunSpec({
|
|||
""".trimIndent()
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
|
||||
packet shouldBe KafkatorioPacket2(
|
||||
packet shouldBe KafkatorioPacket(
|
||||
modVersion = "0.3.2",
|
||||
tick = Tick(66u),
|
||||
data = PlayerUpdate(
|
||||
|
|
@ -88,7 +88,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
}
|
||||
|
||||
test("encode") {
|
||||
val v = KafkatorioPacket2(
|
||||
val v = KafkatorioPacket(
|
||||
modVersion = "0.3.2",
|
||||
tick = Tick(66u),
|
||||
data = PlayerUpdate(
|
||||
|
|
@ -124,7 +124,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
"modVersion": "0.3.2",
|
||||
"tick": 66,
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
"key": {
|
||||
"index": 1
|
||||
},
|
||||
|
|
@ -151,7 +151,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
"tick": 227934,
|
||||
"modVersion": "0.3.2",
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
"key": {
|
||||
"index": 1
|
||||
},
|
||||
|
|
@ -172,9 +172,9 @@ class UpdatePacketsTest : FunSpec({
|
|||
""".trimIndent()
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
|
||||
packet shouldBe KafkatorioPacket2(
|
||||
packet shouldBe KafkatorioPacket(
|
||||
modVersion = "0.3.2",
|
||||
tick = Tick(227934u),
|
||||
data = PlayerUpdate(
|
||||
|
|
@ -215,7 +215,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
val json = """
|
||||
{
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.SurfaceUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.SurfaceUpdate",
|
||||
"name": "nauvis",
|
||||
"index": 1,
|
||||
"daytime": 0.73
|
||||
|
|
@ -225,7 +225,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
}
|
||||
""".trimIndent()
|
||||
|
||||
val expected = KafkatorioPacket2(
|
||||
val expected = KafkatorioPacket(
|
||||
tick = Tick(176000u),
|
||||
modVersion = "0.3.2",
|
||||
data = SurfaceUpdate(
|
||||
|
|
@ -238,7 +238,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
println(jsonMapperKafkatorio.encodeToString(expected))
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
packet shouldBe expected
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package dev.adamko.kafkatorio.events.schema
|
||||
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kxstsgen.KxsTsConfig
|
||||
import dev.adamko.kxstsgen.KxsTsGenerator
|
||||
import dev.adamko.kxstsgen.core.TsDeclaration.TsTypeAlias
|
||||
|
|
@ -36,7 +36,7 @@ fun main(args: Array<String>) {
|
|||
)
|
||||
|
||||
val definitions = gen2.generate(
|
||||
KafkatorioPacket2.serializer(),
|
||||
KafkatorioPacket.serializer(),
|
||||
// KafkatorioKeyedPacketKey2.serializer(),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue